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

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

Issue 2468283004: wptserve: Support wpt_automation (Closed)
Patch Set: rebase Created 4 years, 1 month 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 content = flags ? flags.getAttribute('content') : null; 74 content = flags ? flags.getAttribute('content') : null;
75 return content && content.match(/\bdom\b/); 75 return content && content.match(/\bdom\b/);
76 } 76 }
77 77
78 function isJSTest() { 78 function isJSTest() {
79 return !!document.querySelector('script[src*="/resources/testharness"]') ; 79 return !!document.querySelector('script[src*="/resources/testharness"]') ;
80 } 80 }
81 81
82 function isWPTManualTest() { 82 function isWPTManualTest() {
83 var path = location.pathname; 83 var path = location.pathname;
84 if (location.hostname == 'web-platform.test' && path.endsWith('-manual.h tml'))
85 return true;
84 return /\/imported\/wpt\/.*-manual\.html$/.test(path); 86 return /\/imported\/wpt\/.*-manual\.html$/.test(path);
85 } 87 }
86 88
89 // Returns a directory part relative to WPT root and a basename part of the
90 // current test. e.g.
91 // Current test: file:///.../LayoutTests/imported/wpt/pointerevents/foobar.h tml
92 // Output: "/pointerevents/foobar"
93 function pathAndBaseNameInWPT() {
94 var path = location.pathname;
95 if (location.hostname == 'web-platform.test') {
96 var matches = path.match(/^(\/.*)\.html$/);
97 return matches ? matches[1] : null;
98 }
99 var matches = path.match(/imported\/wpt(\/.*)\.html$/);
100 return matches ? matches[1] : null;
101 }
102
87 function loadAutomationScript() { 103 function loadAutomationScript() {
88 var testPath = location.pathname; 104 var pathAndBase = pathAndBaseNameInWPT();
89 var automationPath = testPath.replace(/\/imported\/wpt\/.*$/, '/imported /wpt_automation'); 105 if (!pathAndBase)
106 return;
107 var automationPath = location.pathname.replace(/\/imported\/wpt\/.*$/, ' /imported/wpt_automation');
108 if (location.hostname == 'web-platform.test')
109 automationPath = '/wpt_automation';
90 110
91 // Export importAutomationScript for use by the automation scripts. 111 // Export importAutomationScript for use by the automation scripts.
92 window.importAutomationScript = function(relativePath) { 112 window.importAutomationScript = function(relativePath) {
93 var script = document.createElement('script'); 113 var script = document.createElement('script');
94 script.src = automationPath + relativePath; 114 script.src = automationPath + relativePath;
95 document.head.appendChild(script); 115 document.head.appendChild(script);
96 } 116 }
97 117
98 var src; 118 var src;
99 if (testPath.includes('/imported/wpt/fullscreen/')) { 119 if (pathAndBase.startsWith('/fullscreen/')) {
100 // Fullscreen tests all use the same automation script. 120 // Fullscreen tests all use the same automation script.
101 src = automationPath + '/fullscreen/auto-click.js'; 121 src = automationPath + '/fullscreen/auto-click.js';
102 } else if (testPath.includes('/imported/wpt/pointerevents/') 122 } else if (pathAndBase.startsWith('/pointerevents/')
103 || testPath.includes('/imported/wpt/uievents/')) { 123 || pathAndBase.startsWith('/uievents/')) {
104 // Per-test automation scripts. 124 // Per-test automation scripts.
105 src = testPath.replace(/\/imported\/wpt\/(.*)\.html$/, "/imported/wp t_automation/$1-automation.js"); 125 src = automationPath + pathAndBase + '-automation.js';
106 } else { 126 } else {
107 return; 127 return;
108 } 128 }
109 var script = document.createElement('script'); 129 var script = document.createElement('script');
110 script.src = src; 130 script.src = src;
111 document.head.appendChild(script); 131 document.head.appendChild(script);
112 } 132 }
113 133
114 var didDispatchLoadEvent = false; 134 var didDispatchLoadEvent = false;
115 window.addEventListener('load', function() { 135 window.addEventListener('load', function() {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // another completion callback might generate more results. So, we 227 // another completion callback might generate more results. So, we
208 // don't dump the results immediately. 228 // don't dump the results immediately.
209 setTimeout(done, 0); 229 setTimeout(done, 0);
210 } else { 230 } else {
211 // Parsing the test HTML isn't finished yet. 231 // Parsing the test HTML isn't finished yet.
212 window.addEventListener('load', done); 232 window.addEventListener('load', done);
213 } 233 }
214 }); 234 });
215 235
216 })(); 236 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698