| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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' && path.endsWith('-manual.h
tml')) |
| 82 return true; | 82 return true; |
| 83 return /\/imported\/wpt\/.*-manual\.html$/.test(path); | 83 return /\/external\/wpt\/.*-manual\.html$/.test(path); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Returns a directory part relative to WPT root and a basename part of the | 86 // Returns a directory part relative to WPT root and a basename part of the |
| 87 // current test. e.g. | 87 // current test. e.g. |
| 88 // Current test: file:///.../LayoutTests/external/wpt/pointerevents/foobar.h
tml | 88 // Current test: file:///.../LayoutTests/external/wpt/pointerevents/foobar.h
tml |
| 89 // Output: "/pointerevents/foobar" | 89 // Output: "/pointerevents/foobar" |
| 90 function pathAndBaseNameInWPT() { | 90 function pathAndBaseNameInWPT() { |
| 91 var path = location.pathname; | 91 var path = location.pathname; |
| 92 if (location.hostname == 'web-platform.test') { | 92 if (location.hostname == 'web-platform.test') { |
| 93 var matches = path.match(/^(\/.*)\.html$/); | 93 var matches = path.match(/^(\/.*)\.html$/); |
| 94 return matches ? matches[1] : null; | 94 return matches ? matches[1] : null; |
| 95 } | 95 } |
| 96 var matches = path.match(/imported\/wpt(\/.*)\.html$/); | 96 var matches = path.match(/external\/wpt(\/.*)\.html$/); |
| 97 return matches ? matches[1] : null; | 97 return matches ? matches[1] : null; |
| 98 } | 98 } |
| 99 | 99 |
| 100 function loadAutomationScript() { | 100 function loadAutomationScript() { |
| 101 var pathAndBase = pathAndBaseNameInWPT(); | 101 var pathAndBase = pathAndBaseNameInWPT(); |
| 102 if (!pathAndBase) | 102 if (!pathAndBase) |
| 103 return; | 103 return; |
| 104 var automationPath = location.pathname.replace(/\/imported\/wpt\/.*$/, '
/external/wpt_automation'); | 104 var automationPath = location.pathname.replace(/\/external\/wpt\/.*$/, '
/external/wpt_automation'); |
| 105 if (location.hostname == 'web-platform.test') | 105 if (location.hostname == 'web-platform.test') |
| 106 automationPath = '/wpt_automation'; | 106 automationPath = '/wpt_automation'; |
| 107 | 107 |
| 108 // Export importAutomationScript for use by the automation scripts. | 108 // Export importAutomationScript for use by the automation scripts. |
| 109 window.importAutomationScript = function(relativePath) { | 109 window.importAutomationScript = function(relativePath) { |
| 110 var script = document.createElement('script'); | 110 var script = document.createElement('script'); |
| 111 script.src = automationPath + relativePath; | 111 script.src = automationPath + relativePath; |
| 112 document.head.appendChild(script); | 112 document.head.appendChild(script); |
| 113 } | 113 } |
| 114 | 114 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // another completion callback might generate more results. So, we | 253 // another completion callback might generate more results. So, we |
| 254 // don't dump the results immediately. | 254 // don't dump the results immediately. |
| 255 setTimeout(done, 0); | 255 setTimeout(done, 0); |
| 256 } else { | 256 } else { |
| 257 // Parsing the test HTML isn't finished yet. | 257 // Parsing the test HTML isn't finished yet. |
| 258 window.addEventListener('load', done); | 258 window.addEventListener('load', done); |
| 259 } | 259 } |
| 260 }); | 260 }); |
| 261 | 261 |
| 262 })(); | 262 })(); |
| OLD | NEW |