summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/testlib
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/testlib
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/testlib')
-rw-r--r--testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/testlib/testlib.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/testlib/testlib.js b/testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/testlib/testlib.js
new file mode 100644
index 000000000..7b556b150
--- /dev/null
+++ b/testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/testlib/testlib.js
@@ -0,0 +1,43 @@
+/*
+* Utility functions for script scheduler test
+*/
+(function(){ /* namespace hiding local variables like arOrderOfAllEvents from global scope */
+ window.testlib = {};
+ window.eventOrder = [];
+ var arNumberOfScriptsParsedPerEvent=[];
+ window.log = function (str){
+ eventOrder.push(str);
+ arNumberOfScriptsParsedPerEvent.push(document.getElementsByTagName('script').length);
+ }
+
+ window.testlib.addScript = function(source, attributes, parent, firstInParent,funcPrepare) {
+ try{
+ parent = parent||document.body;
+ var script = document.createElement('script');
+ if(funcPrepare) {
+ funcPrepare(script);
+ }
+ if(source)script.appendChild( document.createTextNode(source) );
+ for( var name in attributes){
+ if(/^on/i.test(name)) {
+ script[name] = attributes[name];
+ } else {
+ script.setAttribute(name, attributes[name]);
+ }
+ }
+ if (firstInParent && parent.firstChild) {
+ parent.insertBefore(script, parent.firstChild);
+ } else {
+ parent.appendChild(script);
+ }
+ } catch(e) {
+ log('ERROR when adding script to DOM!');
+ alert(e);
+ }
+ return script;
+ }
+
+ window.testlib.urlParam = function(relativeURL) {
+ return location.href.replace( /\d*\.html$/, relativeURL);
+ }
+})(); \ No newline at end of file