| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Escape carriage returns as they break rietveld's difftools. | 71 // Escape carriage returns as they break rietveld's difftools. |
| 72 text = text.replace(/\r/g, "\\r"); | 72 text = text.replace(/\r/g, "\\r"); |
| 73 // Replace machine-dependent path with "...". | 73 // Replace machine-dependent path with "...". |
| 74 if (localPathRegExp) | 74 if (localPathRegExp) |
| 75 text = text.replace(localPathRegExp, "..."); | 75 text = text.replace(localPathRegExp, "..."); |
| 76 return text; | 76 return text; |
| 77 } | 77 } |
| 78 | 78 |
| 79 function isWPTManualTest() { | 79 function isWPTManualTest() { |
| 80 var path = location.pathname; | 80 var path = location.pathname; |
| 81 if (location.hostname == 'web-platform.test' && path.endsWith('-manual.h
tml')) | 81 if (location.hostname == 'web-platform.test' |
| 82 && /.*-manual(\.https)?\.html$/.test(path)) { |
| 82 return true; | 83 return true; |
| 83 return /\/external\/wpt\/.*-manual\.html$/.test(path); | 84 } |
| 85 return /\/external\/wpt\/.*-manual(\.https)?\.html$/.test(path); |
| 84 } | 86 } |
| 85 | 87 |
| 86 // Returns a directory part relative to WPT root and a basename part of the | 88 // Returns a directory part relative to WPT root and a basename part of the |
| 87 // current test. e.g. | 89 // current test. e.g. |
| 88 // Current test: file:///.../LayoutTests/external/wpt/pointerevents/foobar.h
tml | 90 // Current test: file:///.../LayoutTests/external/wpt/pointerevents/foobar.h
tml |
| 89 // Output: "/pointerevents/foobar" | 91 // Output: "/pointerevents/foobar" |
| 90 function pathAndBaseNameInWPT() { | 92 function pathAndBaseNameInWPT() { |
| 91 var path = location.pathname; | 93 var path = location.pathname; |
| 92 if (location.hostname == 'web-platform.test') { | 94 if (location.hostname == 'web-platform.test') { |
| 93 var matches = path.match(/^(\/.*)\.html$/); | 95 var matches = path.match(/^(\/.*)\.html$/); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 106 automationPath = '/wpt_automation'; | 108 automationPath = '/wpt_automation'; |
| 107 | 109 |
| 108 // Export importAutomationScript for use by the automation scripts. | 110 // Export importAutomationScript for use by the automation scripts. |
| 109 window.importAutomationScript = function(relativePath) { | 111 window.importAutomationScript = function(relativePath) { |
| 110 var script = document.createElement('script'); | 112 var script = document.createElement('script'); |
| 111 script.src = automationPath + relativePath; | 113 script.src = automationPath + relativePath; |
| 112 document.head.appendChild(script); | 114 document.head.appendChild(script); |
| 113 } | 115 } |
| 114 | 116 |
| 115 var src; | 117 var src; |
| 116 if (pathAndBase.startsWith('/fullscreen/')) { | 118 if (pathAndBase.startsWith('/fullscreen/') |
| 117 // Fullscreen tests all use the same automation script. | 119 || pathAndBase.startsWith('/webusb/')) { |
| 120 // Fullscreen tests all use the same automation script and WebUSB |
| 121 // tests borrow it. |
| 118 src = automationPath + '/fullscreen/auto-click.js'; | 122 src = automationPath + '/fullscreen/auto-click.js'; |
| 119 } else if (pathAndBase.startsWith('/pointerevents/') | 123 } else if (pathAndBase.startsWith('/pointerevents/') |
| 120 || pathAndBase.startsWith('/uievents/') | 124 || pathAndBase.startsWith('/uievents/') |
| 121 || pathAndBase.startsWith('/pointerlock/') | 125 || pathAndBase.startsWith('/pointerlock/') |
| 122 || pathAndBase.startsWith('/html/') | 126 || pathAndBase.startsWith('/html/') |
| 123 || pathAndBase.startsWith('/input-events/')) { | 127 || pathAndBase.startsWith('/input-events/')) { |
| 124 // Per-test automation scripts. | 128 // Per-test automation scripts. |
| 125 src = automationPath + pathAndBase + '-automation.js'; | 129 src = automationPath + pathAndBase + '-automation.js'; |
| 126 } else { | 130 } else { |
| 127 return; | 131 return; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (didDispatchLoadEvent || output_document.readyState != 'loading') { | 265 if (didDispatchLoadEvent || output_document.readyState != 'loading') { |
| 262 // This function might not be the last 'completion callback', and | 266 // This function might not be the last 'completion callback', and |
| 263 // another completion callback might generate more results. So, we | 267 // another completion callback might generate more results. So, we |
| 264 // don't dump the results immediately. | 268 // don't dump the results immediately. |
| 265 setTimeout(done, 0); | 269 setTimeout(done, 0); |
| 266 } else { | 270 } else { |
| 267 // Parsing the test HTML isn't finished yet. | 271 // Parsing the test HTML isn't finished yet. |
| 268 window.addEventListener('load', done); | 272 window.addEventListener('load', done); |
| 269 } | 273 } |
| 270 }); | 274 }); |
| 271 | |
| 272 })(); | 275 })(); |
| OLD | NEW |