write-active-document.html expects document.write() on an inactive document to be ignored; the spec has no such check and no engine ignores it
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- html, javascript
- Domain
- testing-qa, web-dev
Research direction
Read html/webappapis/dynamic-markup-insertion/document-write/write-active-document.html and compare its first assertion with the reported behavior and the HTML Standard steps described in the issue. Update the expectation for writing to the inactive document to match the observed result, then run that test; it is done when the test passes and its second half still checks the active but not fully active document case.
Written by the indexing model from the issue text.
Description
html/webappapis/dynamic-markup-insertion/document-write/write-active-document.html navigates an iframe away with a link click to a data: URL. In the frame's next load event it calls write() on the frame's previous document, which is now inactive, and expects the write to be ignored:
// This is a write to an inactive document
child1.write('WRITE HAPPENED');
assert_equals(child1.body.lastChild.tagName, "IFRAME");
Neither the document write steps nor the document open steps in the HTML Standard check whether the document is active or fully active. Their only early returns are:
- write steps 8-9: the active parser was aborted; or the insertion point is undefined and the unload counter or the ignore-destructive-writes counter is nonzero.
- open steps 5-7: an active parser whose script nesting level is nonzero, a nonzero unload counter, or the active parser was aborted.
None of these applies to child1, whose parser finished before the navigation. So the write runs the document open steps on child1, which replace all of its children, and the written text becomes the body's last child. The only part of the open steps restricted to fully active documents is step 12, the URL and history update.
That is what every engine does. lastChild is the text node, so its tagName is undefined:
assert_equals: expected (string) "IFRAME" but got (undefined) undefined
The message is the same in all six wpt.fyi runs aligned at 71b58bb191. Stable: Chrome 158.0.8127.36 (run 5091530419994624), Firefox 160.0.1 (5102456061820928), Safari 27.2 (5121161130934272). Experimental: Chrome 160.0.8168.0 (5165587534446592), Firefox 162.0a1 (5188734707040256), Safari Technology Preview 256 (5096019650674688).
The test's second half agrees with the spec: a write to an active but not fully active document replaces its content.
Suggested fix
Expect the write to happen, for example assert_equals(child1.body.textContent, "WRITE HAPPENED"). If writes to inactive documents should be ignored, that needs a whatwg/html issue first. As written, the test asserts behaviour that no specification states and no engine has.
- Dominant language
- HTML
- Stars
- 6.3k
- Forks
- 4.1k
- Avg merge
- 17h 20m
- Merged PRs (30d)
- 841
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from web-platform-tests/wpt
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
web-platform-tests/wpt#65844 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
web-platform-tests/wpt#65836 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
web-platform-tests/wpt#65831 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
web-platform-tests/wpt#65826 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
web-platform-tests/wpt#65823 ·
Maintainers usually reply within 1 day
All issues in web-platform-tests/wpt
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
agent/scanner bug stage/010-actionable
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
torch-spyre/spyre-inference#1849 ·
Maintainers usually reply within 2 days
-
tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day