-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not processing non-browsing-context-connected <style>s
Fixes #2553. The spec actually does not cover this; see spec issue at whatwg/html#4547.
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...s/to-upstream/html/semantics/document-metadata/the-style-element/no-browsing-context.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Style should not apply with no browsing context</title> | ||
<!-- https://github.com/whatwg/html/issues/4547 --> | ||
|
||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
"use strict"; | ||
test(() => { | ||
const doc = document.implementation.createHTMLDocument(); | ||
const style = document.createElement("style"); | ||
style.textContent = ` | ||
p { color: red; } | ||
`; | ||
|
||
doc.head.appendChild(style); | ||
doc.body.appendChild(doc.createElement("p")); | ||
|
||
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue last step falls back to empty string | ||
assert_equals(window.getComputedStyle(doc.querySelector("p")).color, ""); | ||
}, "no impact on getComputedStyle"); | ||
|
||
async_test(t => { | ||
const doc = document.implementation.createHTMLDocument(); | ||
const style = document.createElement("style"); | ||
style.textContent = ` | ||
@import url('https://fonts.googleapis.com/css?family=Poppins:200,300,800'); | ||
`; | ||
|
||
style.onload = t.unreached_func("load event must not be fired"); | ||
style.onerror = t.unreached_func("error event must not be fired"); | ||
doc.head.appendChild(style); | ||
|
||
t.step_timeout(() => t.done(), 200); | ||
}, "no load or error events"); | ||
</script> |