Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/WebKit/LayoutTests/resources/testharnessreport.js

Issue 2789723003: Migrate WebUSB LayoutTests into external/wpt (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Per-test automation scripts. 121 // Per-test automation scripts.
122 src = automationPath + pathAndBase + '-automation.js'; 122 src = automationPath + pathAndBase + '-automation.js';
123 } else { 123 } else {
124 return; 124 return;
125 } 125 }
126 var script = document.createElement('script'); 126 var script = document.createElement('script');
127 script.src = src; 127 script.src = src;
128 document.head.appendChild(script); 128 document.head.appendChild(script);
129 } 129 }
130 130
131 function importTestPolyfils() {
132 var pathAndBase = pathAndBaseNameInWPT();
133 if (!pathAndBase)
134 return;
135 var automationPath = location.pathname.replace(/\/external\/wpt\/.*$/, ' /external/wpt_automation');
ortuno 2017/04/03 01:47:19 wpt_automation has a very specific purpose: Turn m
Reilly Grant (use Gerrit) 2017/04/05 18:39:37 Created a new wpt_polyfill directory for these.
136 if (location.hostname == 'web-platform.test')
137 automationPath = '/wpt_automation';
138
139 var script = document.createElement('script');
140 if (pathAndBase.startsWith('/webusb/')) {
141 // WebUSB tests require a polyfil for navigator.usb.test. This
142 // script will be loaded asynchronously so we need to patch in
143 // a version of navigator.usb.test.initialize() that will wait for
144 // the script to load.
145 script.src = automationPath + '/webusb/webusb-test.js';
146 let initializePromise = null;
147 navigator.usb.test = {
148 initialize: function() {
149 if (!initializePromise) {
150 initializePromise = new Promise(resolve => {
151 script.onload = () => {
152 resolve(navigator.usb.test.initialize());
153 }
154 });
155 }
156 return initializePromise;
157 }
158 };
159 } else {
160 return;
161 }
162 document.head.appendChild(script);
163 }
164
131 var didDispatchLoadEvent = false; 165 var didDispatchLoadEvent = false;
132 window.addEventListener('load', function() { 166 window.addEventListener('load', function() {
133 didDispatchLoadEvent = true; 167 didDispatchLoadEvent = true;
134 if (isWPTManualTest()) { 168 if (isWPTManualTest()) {
135 setTimeout(loadAutomationScript, 0); 169 setTimeout(loadAutomationScript, 0);
136 } 170 }
137 }, { once: true }); 171 }, { once: true });
138 172
139 add_start_callback(function(properties) { 173 add_start_callback(function(properties) {
140 if (properties.output_document) 174 if (properties.output_document)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // This function might not be the last 'completion callback', and 293 // This function might not be the last 'completion callback', and
260 // another completion callback might generate more results. So, we 294 // another completion callback might generate more results. So, we
261 // don't dump the results immediately. 295 // don't dump the results immediately.
262 setTimeout(done, 0); 296 setTimeout(done, 0);
263 } else { 297 } else {
264 // Parsing the test HTML isn't finished yet. 298 // Parsing the test HTML isn't finished yet.
265 window.addEventListener('load', done); 299 window.addEventListener('load', done);
266 } 300 }
267 }); 301 });
268 302
303 importTestPolyfils();
269 })(); 304 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698