diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /layout/base/tests/browser_bug839103.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | layout/base/tests/browser_bug839103.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/layout/base/tests/browser_bug839103.js b/layout/base/tests/browser_bug839103.js new file mode 100644 index 0000000000..fd20b82029 --- /dev/null +++ b/layout/base/tests/browser_bug839103.js @@ -0,0 +1,82 @@ +const gTestRoot = getRootDirectory(gTestPath).replace( + "chrome://mochitests/content/", + "http://127.0.0.1:8888/" +); + +add_task(async function test() { + await BrowserTestUtils.withNewTab( + { gBrowser, url: gTestRoot + "file_bug839103.html" }, + async function (browser) { + await SpecialPowers.spawn(browser, [gTestRoot], testBody); + } + ); +}); + +// This function runs entirely in the content process. It doesn't have access +// any free variables in this file. +async function testBody(testRoot) { + const gStyleSheet = "bug839103.css"; + + function unexpectedContentEvent(event) { + ok(false, "Received a " + event.type + " event on content"); + } + + // We've seen the original stylesheet in the document. + // Now add a stylesheet on the fly and make sure we see it. + let doc = content.document; + doc.styleSheetChangeEventsEnabled = true; + doc.addEventListener( + "StyleSheetApplicableStateChanged", + unexpectedContentEvent + ); + doc.defaultView.addEventListener( + "StyleSheetApplicableStateChanged", + unexpectedContentEvent + ); + + let link = doc.createElement("link"); + link.setAttribute("rel", "stylesheet"); + link.setAttribute("type", "text/css"); + link.setAttribute("href", testRoot + gStyleSheet); + + let stateChanged = ContentTaskUtils.waitForEvent( + docShell.chromeEventHandler, + "StyleSheetApplicableStateChanged", + true + ); + doc.body.appendChild(link); + + info("waiting for applicable state change event"); + let evt = await stateChanged; + info("received dynamic style sheet applicable state change event"); + is( + evt.type, + "StyleSheetApplicableStateChanged", + "evt.type has expected value" + ); + is(evt.target, doc, "event targets correct document"); + is(evt.stylesheet, link.sheet, "evt.stylesheet has the right value"); + is(evt.applicable, true, "evt.applicable has the right value"); + + stateChanged = ContentTaskUtils.waitForEvent( + docShell.chromeEventHandler, + "StyleSheetApplicableStateChanged", + true + ); + link.sheet.disabled = true; + + evt = await stateChanged; + is( + evt.type, + "StyleSheetApplicableStateChanged", + "evt.type has expected value" + ); + info( + 'received dynamic style sheet applicable state change event after media="" changed' + ); + is(evt.target, doc, "event targets correct document"); + is(evt.stylesheet, link.sheet, "evt.stylesheet has the right value"); + is(evt.applicable, false, "evt.applicable has the right value"); + + doc.body.removeChild(link); +} |