зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1768215 - Use the right referrer info for constructable stylesheets. r=jfkthame
Document::GetReferrerInfo is not what we want (that is the referrer of the document itself). What we want is to use the document _as_ the referrer. That's what regular stylesheets do, and that fixes our chrome only rules enabled check. Differential Revision: https://phabricator.services.mozilla.com/D145794
This commit is contained in:
Родитель
bd7a7312d0
Коммит
47ef79d1a6
|
@ -123,7 +123,8 @@ already_AddRefed<StyleSheet> StyleSheet::Constructor(
|
|||
sheet->SetURIs(sheetURI, originalURI, baseURI);
|
||||
|
||||
sheet->SetPrincipal(constructorDocument->NodePrincipal());
|
||||
sheet->SetReferrerInfo(constructorDocument->GetReferrerInfo());
|
||||
auto referrerInfo = MakeRefPtr<ReferrerInfo>(*constructorDocument);
|
||||
sheet->SetReferrerInfo(referrerInfo);
|
||||
sheet->mConstructorDocument = constructorDocument;
|
||||
if (constructorDocument) {
|
||||
sheet->mRelevantGlobal = constructorDocument->GetParentObject();
|
||||
|
|
|
@ -28,3 +28,4 @@ skip-if = true # bug 1346353
|
|||
[test_moz_document_rules.html]
|
||||
[test_stylesheet_clone_import_rule.html]
|
||||
support-files = import_useless1.css import_useless2.css
|
||||
[test_constructable_stylesheets_chrome_only_rules.html]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for chrome-only rules in constructable stylesheets</title>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script>
|
||||
add_task(async function chrome_rules_constructable_stylesheets() {
|
||||
let sheet = new CSSStyleSheet();
|
||||
sheet.replaceSync(".foo { -moz-default-appearance: none }");
|
||||
is(sheet.cssRules[0].style.length, 1, "Should parse chrome-only property in chrome document");
|
||||
});
|
||||
</script>
|
|
@ -208,6 +208,7 @@ skip-if = toolkit == 'android'
|
|||
[test_computed_style_no_pseudo.html]
|
||||
[test_computed_style_prefs.html]
|
||||
[test_condition_text.html]
|
||||
[test_constructable_stylesheets_chrome_only_rules_in_content.html]
|
||||
[test_counter_descriptor_storage.html]
|
||||
[test_counter_style.html]
|
||||
[test_crash_with_content_policy.html]
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for chrome-only rules in constructable stylesheets (in content)</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script>
|
||||
add_task(async function chrome_rules_constructable_stylesheets_in_content() {
|
||||
let sheet = new CSSStyleSheet();
|
||||
sheet.replaceSync(".foo { -moz-default-appearance: none }");
|
||||
is(sheet.cssRules[0].style.length, 0, "Should not parse chrome-only property in content document");
|
||||
});
|
||||
|
||||
add_task(async function chrome_rules_constructable_stylesheets_in_content() {
|
||||
let sheet = new CSSStyleSheet({ baseURL: "chrome://browser/content/browser.xhtml" })
|
||||
sheet.replaceSync(".foo { -moz-default-appearance: none }");
|
||||
is(sheet.cssRules[0].style.length, 0, "Should not parse chrome-only property in content document, even with chrome baseURL");
|
||||
});
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче