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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/stylesheet-tracking-restart.js

Issue 2951183002: [DevTools] Move inspector-protocol/accessibility tests to new harness (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/resources/accessibility-dumpAccessibilityNodes.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (async function(testRunner) { 1 (async function(testRunner) {
2 testRunner.log('This test checks that if style sheet is removed between two in spector launches it is not reported to frontend.'); 2 testRunner.log('This test checks that if style sheet is removed between two in spector launches it is not reported to frontend.');
3 var page = await testRunner.createPage(); 3 var page = await testRunner.createPage();
4 var session = await page.createSession(); 4 var session = await page.createSession();
5 await session.evaluate(` 5 await session.evaluate(`
6 function createStyleSheet(textContent) 6 function createStyleSheet(textContent)
7 { 7 {
8 var styleElement = document.createElement('style'); 8 var styleElement = document.createElement('style');
9 styleElement.textContent = textContent; 9 styleElement.textContent = textContent;
10 document.head.appendChild(styleElement); 10 document.head.appendChild(styleElement);
11 return styleElement; 11 return styleElement;
12 } 12 }
13 window.styleElement1 = createStyleSheet('body.class1 { color: red; } \\n /*# sourceURL=foo.css */'); 13 window.styleElement1 = createStyleSheet('body.class1 { color: red; } \\n /*# sourceURL=foo.css */');
14 window.styleElement2 = createStyleSheet('body.class2 { color: green; } \\n / *# sourceURL=bar.css */'); 14 window.styleElement2 = createStyleSheet('body.class2 { color: green; } \\n / *# sourceURL=bar.css */');
15 `); 15 `);
16 testRunner.log('\nRunning test'); 16 testRunner.log('\nRunning test');
17 testRunner.log('Opening front-end for the first time'); 17 testRunner.log('Opening front-end for the first time');
18 await runTest(session); 18 await runTest(session);
19 testRunner.log('Closing inspector.'); 19 testRunner.log('Closing inspector.');
20 testRunner.log('\nRemoving style sheet.\n'); 20 testRunner.log('\nRemoving style sheet.\n');
21 session.evaluate('setTimeout(() => document.head.removeChild(styleElement1), 0 )'); 21 session.evaluate('setTimeout(() => { document.head.removeChild(styleElement1); document.body.offsetWidth; }, 0)');
22 await session.disconnect(); 22 await session.disconnect();
23 testRunner.log('Reopening inspector.'); 23 testRunner.log('Reopening inspector.');
24 session = await page.createSession(); 24 session = await page.createSession();
25 testRunner.log('Running test'); 25 testRunner.log('Running test');
26 testRunner.log('Opening front-end second time'); 26 testRunner.log('Opening front-end second time');
27 await runTest(session); 27 await runTest(session);
28 testRunner.completeTest(); 28 testRunner.completeTest();
29 async function runTest(session) { 29 async function runTest(session) {
30 var headersAdded = []; 30 var headersAdded = [];
31 session.protocol.CSS.onStyleSheetAdded(response => headersAdded.push(respons e.params.header)); 31 session.protocol.CSS.onStyleSheetAdded(response => headersAdded.push(respons e.params.header));
32 var headersRemoved = []; 32 var headersRemoved = [];
33 session.protocol.CSS.onStyleSheetRemoved(response => headersRemoved.push(res ponse.params.styleSheetId)); 33 session.protocol.CSS.onStyleSheetRemoved(response => headersRemoved.push(res ponse.params.styleSheetId));
34 testRunner.log('Enabling CSS domain.'); 34 testRunner.log('Enabling CSS domain.');
35 session.protocol.DOM.enable(); 35 session.protocol.DOM.enable();
36 await session.protocol.CSS.enable(); 36 await session.protocol.CSS.enable();
37 var headers = {}; 37 var headers = {};
38 headersAdded.sort((a, b) => a.styleSheetId - b.styleSheetId); 38 headersAdded.sort((a, b) => a.styleSheetId - b.styleSheetId);
39 for (var header of headersAdded) { 39 for (var header of headersAdded) {
40 headers[header.styleSheetId] = header.sourceURL; 40 headers[header.styleSheetId] = header.sourceURL;
41 testRunner.log(' - style sheet added: ' + header.sourceURL); 41 testRunner.log(' - style sheet added: ' + header.sourceURL);
42 } 42 }
43 headersRemoved.sort(); 43 headersRemoved.sort();
44 for (var styleSheetId of headersRemoved) 44 for (var styleSheetId of headersRemoved)
45 testRunner.log(' - style sheet removed: ' + headers[styleSheetId]); 45 testRunner.log(' - style sheet removed: ' + headers[styleSheetId]);
46 } 46 }
47 }) 47 })
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/resources/accessibility-dumpAccessibilityNodes.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698