Skip to content

Commit

Permalink
Update inspector-protocol/css/css-style-sheet-events.js to work with …
Browse files Browse the repository at this point in the history
…RenderDocument

We can't expect stylesheet removal events from the agent associated to a frame being
navigated away, as this may involve a frame swap.

Change-Id: I24a5a374eed2be1015f82876044a2247de1118d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4936757
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Auto-Submit: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Peter Kvitek <kvitekp@chromium.org>
Commit-Queue: Peter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209098}
  • Loading branch information
caseq authored and Chromium LUCI CQ committed Oct 12, 2023
1 parent f992354 commit 9fa8874
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(async function(testRunner) {
var {page, session, dp} = await testRunner.startHTML(`
const {session, dp} = await testRunner.startHTML(`
<style>
#test {
box-sizing: border-box;
Expand All @@ -13,9 +13,8 @@
await cssHelper.requestDocumentNodeId();

// Add Event
const addEventPromise = dp.CSS.onceStyleSheetAdded();
await dp.CSS.enable();
const addEvent = await addEventPromise;
dp.CSS.enable();
const addEvent = await dp.CSS.onceStyleSheetAdded();
testRunner.log(addEvent, '', [ ...TestRunner.stabilizeNames, 'length' ]);
const styleSheetId = addEvent.params.header.styleSheetId;

Expand All @@ -39,7 +38,9 @@
testRunner.log(addEventAfterChange, '', [ ...TestRunner.stabilizeNames, 'length' ]);

// Remove event
await dp.Page.navigate({url: 'about:blank'});
session.evaluate(`
[...document.head.getElementsByTagName('style')].forEach(item => item.remove())
`);
const removeEvent = await dp.CSS.onceStyleSheetRemoved();
testRunner.log(removeEvent);
testRunner.completeTest();
Expand Down

0 comments on commit 9fa8874

Please sign in to comment.