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/style/test/test_computed_style_bfcache_display_none.html | |
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 'layout/style/test/test_computed_style_bfcache_display_none.html')
-rw-r--r-- | layout/style/test/test_computed_style_bfcache_display_none.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/layout/style/test/test_computed_style_bfcache_display_none.html b/layout/style/test/test_computed_style_bfcache_display_none.html new file mode 100644 index 0000000000..8322e4977a --- /dev/null +++ b/layout/style/test/test_computed_style_bfcache_display_none.html @@ -0,0 +1,60 @@ +<!doctype html> +<title>Test for getting the computed style on the root node of a display:none subtree in a document in the bfcache</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1377010">Mozilla Bug 1377010</a> +<p id="display"></p> +<script> +SimpleTest.waitForExplicitFinish(); + +let testDiv; +let loadedPromiseResolve; + +const TEST_PATH = "http://mochi.test:8888/tests/layout/style/test/"; +const TEST_FILE1 = TEST_PATH + "file_computed_style_bfcache_display_none.html"; +const TEST_FILE2 = TEST_PATH + "file_computed_style_bfcache_display_none2.html"; + +// Open a new window. +const w = window.open(TEST_FILE1); +waitForLoadMessage().then(() => { + // Take a reference to a node in the new window. + testDiv = w.document.getElementById('div'); + + // Open a new document so that the test div now refers to a node in a + // document in the bfcache. + w.location = TEST_FILE2; + return waitForLoadMessage(); +}).then(() => { + // Compute styles for the node in the bfcache document. + is(w.getComputedStyle(testDiv).opacity, '1'); + + // Restore the bfcache document. + return goBack(w); +}).then(() => { + // Fetch the style once again. + is(w.getComputedStyle(testDiv).opacity, '1'); + + w.close(); + SimpleTest.finish(); +}); + +window.addEventListener('message', e => { + if (e.data === 'loaded' && loadedPromiseResolve) { + loadedPromiseResolve(); + loadedPromiseResolve = undefined; + } +}); + +function waitForLoadMessage() { + return new Promise(resolve => { + loadedPromiseResolve = resolve; + }); +} + +function goBack(win) { + return new Promise(resolve => { + win.onpagehide = e => resolve(win); + win.history.back(); + }); +} +</script> |