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

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: Protocol -> dp 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(testRunner) {
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();
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 testRunner.log('\nRunning test');
20 testRunner.log('Opening front-end for the first time');
21 await runTest(session);
22 testRunner.log('Closing inspector.');
23 testRunner.log('\nRemoving style sheet.\n');
24 session.evaluate('setTimeout(() => document.head.removeChild(styleElement1), 0 )');
25 await session.disconnect();
26
27 testRunner.log('Reopening inspector.');
28 session = await page.createSession();
29 testRunner.log('Running test');
30 testRunner.log('Opening front-end second time');
31 await runTest(session);
32 testRunner.completeTest();
33
34 async function runTest(session) {
35 var headersAdded = [];
36 session.protocol.CSS.onStyleSheetAdded(response => headersAdded.push(respons e.params.header));
37
38 var headersRemoved = [];
39 session.protocol.CSS.onStyleSheetRemoved(response => headersRemoved.push(res ponse.params.styleSheetId));
40
41 testRunner.log('Enabling CSS domain.');
42 session.protocol.DOM.enable();
43 await session.protocol.CSS.enable();
44
45 var headers = {};
46 headersAdded.sort((a, b) => a.styleSheetId - b.styleSheetId);
47 for (var header of headersAdded) {
48 headers[header.styleSheetId] = header.sourceURL;
49 testRunner.log(' - style sheet added: ' + header.sourceURL);
50 }
51
52 headersRemoved.sort();
53 for (var styleSheetId of headersRemoved)
54 testRunner.log(' - style sheet removed: ' + headers[styleSheetId]);
55 }
56 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698