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

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

Issue 2950713002: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: addressed comments, 4 tests 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 await session.evaluate(`
6 function createStyleSheet(textContent)
7 {
8 var styleElement = document.createElement('style');
9 styleElement.textContent = textContent;
10 document.head.appendChild(styleElement);
11 return styleElement;
12 }
13 window.styleElement1 = createStyleSheet('body.class1 { color: red; } \\n /*# sourceURL=foo.css */');
14 window.styleElement2 = createStyleSheet('body.class2 { color: green; } \\n / *# sourceURL=bar.css */');
15 `);
16 testRunner.log('\nRunning test');
17 testRunner.log('Opening front-end for the first time');
18 await runTest(session);
19 testRunner.log('Closing inspector.');
20 testRunner.log('\nRemoving style sheet.\n');
21 session.evaluate('setTimeout(() => document.head.removeChild(styleElement1), 0 )');
22 await session.disconnect();
23 testRunner.log('Reopening inspector.');
24 session = await page.createSession();
25 testRunner.log('Running test');
26 testRunner.log('Opening front-end second time');
27 await runTest(session);
28 testRunner.completeTest();
29 async function runTest(session) {
30 var headersAdded = [];
31 session.protocol.CSS.onStyleSheetAdded(response => headersAdded.push(respons e.params.header));
32 var headersRemoved = [];
33 session.protocol.CSS.onStyleSheetRemoved(response => headersRemoved.push(res ponse.params.styleSheetId));
34 testRunner.log('Enabling CSS domain.');
35 session.protocol.DOM.enable();
36 await session.protocol.CSS.enable();
37 var headers = {};
38 headersAdded.sort((a, b) => a.styleSheetId - b.styleSheetId);
39 for (var header of headersAdded) {
40 headers[header.styleSheetId] = header.sourceURL;
41 testRunner.log(' - style sheet added: ' + header.sourceURL);
42 }
43 headersRemoved.sort();
44 for (var styleSheetId of headersRemoved)
45 testRunner.log(' - style sheet removed: ' + headers[styleSheetId]);
46 }
47 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698