| OLD | NEW |
| 1 /* | 1 /* |
| 2 * THIS FILE INTENTIONALLY LEFT BLANK | 2 * THIS FILE INTENTIONALLY LEFT BLANK |
| 3 * | 3 * |
| 4 * More specifically, this file is intended for vendors to implement | 4 * More specifically, this file is intended for vendors to implement |
| 5 * code needed to integrate testharness.js tests with their own test systems. | 5 * code needed to integrate testharness.js tests with their own test systems. |
| 6 * | 6 * |
| 7 * Typically such integration will attach callbacks when each test is | 7 * Typically such integration will attach callbacks when each test is |
| 8 * has run, using add_result_callback(callback(test)), or when the whole test fi
le has | 8 * has run, using add_result_callback(callback(test)), or when the whole test fi
le has |
| 9 * completed, using add_completion_callback(callback(tests, harness_status)). | 9 * completed, using add_completion_callback(callback(tests, harness_status)). |
| 10 * | 10 * |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 function isCSSWGTest() { | 59 function isCSSWGTest() { |
| 60 var flags = document.querySelector('meta[name=flags]'), | 60 var flags = document.querySelector('meta[name=flags]'), |
| 61 content = flags ? flags.getAttribute('content') : null; | 61 content = flags ? flags.getAttribute('content') : null; |
| 62 return content && content.match(/\bdom\b/); | 62 return content && content.match(/\bdom\b/); |
| 63 } | 63 } |
| 64 | 64 |
| 65 function isJSTest() { | 65 function isJSTest() { |
| 66 return !!document.querySelector('script[src*="/resources/testharness"]')
; | 66 return !!document.querySelector('script[src*="/resources/testharness"]')
; |
| 67 } | 67 } |
| 68 | 68 |
| 69 | |
| 70 function injectSyntheticInput() { | 69 function injectSyntheticInput() { |
| 71 var path = window.location.pathname; | 70 var path = window.location.pathname; |
| 72 if (path.match(/imported\/wpt\/.*\.html$/)) { | 71 if (path.match(/imported\/wpt\/.*\.html$/)) { |
| 73 // Set a global variable for the address of automated input script i
f they need to use it. | |
| 74 var automated_input_scripts_folder = path.replace(/imported\/wpt\/(.
*)\.html$/, 'imported/wpt_automation'); | |
| 75 | |
| 76 importAutomationScript = function(relativePath) { | |
| 77 var common_script = document.createElement('script'); | |
| 78 common_script.setAttribute('src', automated_input_scripts_folder +
relativePath); | |
| 79 document.head.appendChild(common_script); | |
| 80 } | |
| 81 | |
| 82 path = path.replace(/imported\/wpt\/(.*)\.html$/, "imported/wpt_auto
mation/$1-input.js"); | 72 path = path.replace(/imported\/wpt\/(.*)\.html$/, "imported/wpt_auto
mation/$1-input.js"); |
| 83 var input_script = document.createElement('script'); | 73 var input_script = document.createElement('script'); |
| 84 input_script.setAttribute('src', path); | 74 input_script.setAttribute('src', path); |
| 85 document.head.appendChild(input_script); | 75 document.head.appendChild(input_script); |
| 86 } | 76 } |
| 87 } | 77 } |
| 88 | 78 |
| 89 var didDispatchLoadEvent = false; | 79 var didDispatchLoadEvent = false; |
| 90 var handleLoad = function() { | 80 var handleLoad = function() { |
| 91 didDispatchLoadEvent = true; | 81 didDispatchLoadEvent = true; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // another completion callback might generate more results. So, we | 146 // another completion callback might generate more results. So, we |
| 157 // don't dump the results immediately. | 147 // don't dump the results immediately. |
| 158 setTimeout(done, 0); | 148 setTimeout(done, 0); |
| 159 } else { | 149 } else { |
| 160 // Parsing the test HTML isn't finished yet. | 150 // Parsing the test HTML isn't finished yet. |
| 161 window.addEventListener('load', done); | 151 window.addEventListener('load', done); |
| 162 } | 152 } |
| 163 }); | 153 }); |
| 164 | 154 |
| 165 })(); | 155 })(); |
| OLD | NEW |