mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Bug 1576229 - Account for user stylesheets for Shadow DOM invalidation. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D43992 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
521211a377
commit
4505c339ab
@ -53,6 +53,7 @@ support-files =
|
||||
[test_acid3_test46.html]
|
||||
[test_addSheet.html]
|
||||
support-files = additional_sheets_helper.html
|
||||
[test_user_sheet_shadow_dom.html]
|
||||
[test_additional_sheets.html]
|
||||
support-files = additional_sheets_helper.html
|
||||
[test_align_justify_computed_values.html]
|
||||
|
48
layout/style/test/test_user_sheet_shadow_dom.html
Normal file
48
layout/style/test/test_user_sheet_shadow_dom.html
Normal file
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE HTML>
|
||||
<title>Test for bug 1576229 - Nodes in Shadow DOM react properly to dynamic changes in user sheets</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
||||
<div></div>
|
||||
<span id="host" style="display: block"></span>
|
||||
<script>
|
||||
const gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIIOService)
|
||||
|
||||
const gSSService = SpecialPowers.Cc["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIStyleSheetService);
|
||||
|
||||
const windowUtils = SpecialPowers.getDOMWindowUtils(window);
|
||||
|
||||
function loadUserSheet(style) {
|
||||
const uri = gIOService.newURI("data:text/css," + style);
|
||||
windowUtils.loadSheet(uri, windowUtils.USER_SHEET);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
onload = function() {
|
||||
loadUserSheet(`
|
||||
div {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: red;
|
||||
}
|
||||
.foo {
|
||||
background-color: green;
|
||||
}
|
||||
`);
|
||||
let host = document.querySelector("#host");
|
||||
host.attachShadow({ mode: "open" }).innerHTML = `
|
||||
<div></div>
|
||||
`;
|
||||
let light = document.querySelector('div');
|
||||
let shadow = host.shadowRoot.querySelector('div');
|
||||
is(getComputedStyle(light).backgroundColor, "rgb(255, 0, 0)", "User sheet works in light DOM");
|
||||
is(getComputedStyle(shadow).backgroundColor, "rgb(255, 0, 0)", "User sheet works in shadow DOM");
|
||||
light.classList.add("foo");
|
||||
shadow.classList.add("foo");
|
||||
is(getComputedStyle(light).backgroundColor, "rgb(0, 128, 0)", "Dynamic change for user sheet works in light DOM");
|
||||
is(getComputedStyle(shadow).backgroundColor, "rgb(0, 128, 0)", "Dynamic change for user sheet works in shadow DOM");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
@ -16,7 +16,7 @@ use crate::invalidation::element::invalidator::{Invalidation, InvalidationProces
|
||||
use crate::invalidation::element::restyle_hints::RestyleHint;
|
||||
use crate::selector_map::SelectorMap;
|
||||
use crate::selector_parser::Snapshot;
|
||||
use crate::stylesheets::origin::{Origin, OriginSet};
|
||||
use crate::stylesheets::origin::OriginSet;
|
||||
use crate::{Atom, WeakAtom};
|
||||
use selectors::attr::CaseSensitivity;
|
||||
use selectors::matching::matches_selector;
|
||||
@ -246,7 +246,7 @@ where
|
||||
};
|
||||
|
||||
let document_origins = if !matches_document_author_rules {
|
||||
Origin::UserAgent.into()
|
||||
OriginSet::ORIGIN_USER_AGENT | OriginSet::ORIGIN_USER
|
||||
} else {
|
||||
OriginSet::all()
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user