Skip to content

Commit ca9cee0

Browse files
author
Alan Jeffrey
committed
Fix document.write check for activity.
1 parent a43c842 commit ca9cee0

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

components/script/dom/document.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,8 +3271,7 @@ impl DocumentMethods for Document {
32713271

32723272
// Step 2.
32733273
// TODO: handle throw-on-dynamic-markup-insertion counter.
3274-
// FIXME: this should check for being active rather than fully active
3275-
if !self.is_fully_active() {
3274+
if !self.is_active() {
32763275
// Step 3.
32773276
return Ok(());
32783277
}

components/script/script_thread.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,7 @@ impl ScriptThread {
13041304

13051305
/// Handles activity change message
13061306
fn handle_set_document_activity_msg(&self, id: PipelineId, activity: DocumentActivity) {
1307+
debug!("Setting activity of {} to be {:?}.", id, activity);
13071308
let document = self.documents.borrow().find_document(id);
13081309
if let Some(document) = document {
13091310
document.set_activity(activity);

tests/wpt/metadata/MANIFEST.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45873,6 +45873,12 @@
4587345873
"url": "/cssom/stylesheet-same-origin.sub.html"
4587445874
}
4587545875
],
45876+
"html/dom/dynamic-markup-insertion/document-write/write-active-document.html": [
45877+
{
45878+
"path": "html/dom/dynamic-markup-insertion/document-write/write-active-document.html",
45879+
"url": "/html/dom/dynamic-markup-insertion/document-write/write-active-document.html"
45880+
}
45881+
],
4587645882
"html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html": [
4587745883
{
4587845884
"path": "html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[write-active-document.html]
2+
type: testharness
3+
[document.write only writes to active documents]
4+
expected: FAIL
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<html><body></body></html>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!doctype html>
2+
<title>document.write only writes to active documents</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<body><div id="log"></div></body>
6+
<script>
7+
async_test(function(t) {
8+
var child = document.createElement("iframe");
9+
child.src = "empty.html?1";
10+
child.onload = t.step_func(function() {
11+
var child1 = child.contentDocument;
12+
var link = child1.createElement("a");
13+
link.href = "data:text/html,Clicked.";
14+
link.innerText = "Link.";
15+
child1.body.appendChild(link);
16+
var grandchild = child1.createElement("iframe");
17+
grandchild.src = "empty.html?2";
18+
grandchild.onload = t.step_func(function() {
19+
var grandchild1 = grandchild.contentDocument;
20+
child.onload = t.step_func(function() {
21+
// This is a write to an inactive document
22+
child1.write('WRITE HAPPENED');
23+
assert_equals(child1.body.lastChild.tagName, "IFRAME");
24+
// This is a write to an active but not fully active document
25+
grandchild1.write('WRITE HAPPENED');
26+
assert_equals(grandchild1.body.innerHTML, "WRITE HAPPENED");
27+
t.done();
28+
});
29+
link.click();
30+
});
31+
child1.body.appendChild(grandchild);
32+
});
33+
document.body.appendChild(child);
34+
});
35+
</script>

0 commit comments

Comments
 (0)