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

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

Issue 2942573003: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: unified 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
OLDNEW
(Empty)
1 (async function() {
2 InspectorTest.log('This test checks that if style sheet is removed between two inspector launches it is not reported to frontend.');
3 var page = await InspectorTest.createPage();
4 var session = await page.createSession();
5
6 await session.evaluate(`
7 function createStyleSheet(textContent)
8 {
9 var styleElement = document.createElement('style');
10 styleElement.textContent = textContent;
11 document.head.appendChild(styleElement);
12 return styleElement;
13 }
14
15 window.styleElement1 = createStyleSheet('body.class1 { color: red; } \\n /*# sourceURL=foo.css */');
16 window.styleElement2 = createStyleSheet('body.class2 { color: green; } \\n / *# sourceURL=bar.css */');
17 `);
18
19 InspectorTest.log('\nRunning test');
20 InspectorTest.log('Opening front-end for the first time');
21 await runTest(session);
22 InspectorTest.log('Closing inspector.');
23 InspectorTest.log('\nRemoving style sheet.\n');
24 session.evaluate('setTimeout(() => document.head.removeChild(styleElement1), 0 )');
25 await session.disconnect();
26
27 InspectorTest.log('Reopening inspector.');
28 session = await page.createSession();
29 InspectorTest.log('Running test');
30 InspectorTest.log('Opening front-end second time');
31 await runTest(session);
32 InspectorTest.completeTest();
33 })();
34
35 async function runTest(session) {
36 var headersAdded = [];
37 session.Protocol.CSS.onStyleSheetAdded(response => headersAdded.push(response. params.header));
38
39 var headersRemoved = [];
40 session.Protocol.CSS.onStyleSheetRemoved(response => headersRemoved.push(respo nse.params.styleSheetId));
41
42 InspectorTest.log('Enabling CSS domain.');
43 session.Protocol.DOM.enable();
44 await session.Protocol.CSS.enable();
45
46 var headers = {};
47 headersAdded.sort((a, b) => a.styleSheetId - b.styleSheetId);
48 for (var header of headersAdded) {
49 headers[header.styleSheetId] = header.sourceURL;
50 InspectorTest.log(' - style sheet added: ' + header.sourceURL);
51 }
52
53 headersRemoved.sort();
54 for (var styleSheetId of headersRemoved)
55 InspectorTest.log(' - style sheet removed: ' + headers[styleSheetId]);
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698