whatwg / whatwg/html

"mute iframe load" flag doesn't seem to accurately capture what UAs do

Open
#4,292 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: document lifecycle topic: document.open()
Dominant language
HTML
Stars
9.4k
Forks
3.2k
Avg merge
3d 9h
Merged PRs (30d)
38

Description

I don't quite know how to reconcile this with https://github.com/whatwg/html/issues/4291 but...

Consider the following testcase:

<script>
function doIt() {
  log.textContent += "called";
  var doc = frames[0].document;
  doc.open();
  doc.defaultView.addEventListener("load", () => console.log('load'));
  doc.write("testing");
  doc.close();
}
</script>
<div id=log></div>
<iframe onload="doIt()"> </iframe>

Per spec as written, it should log "load" at some point, but it does not. The spec's "mute iframe load" flag prevents doIt being called a second time, but what UAs are doing is more than that: they're not firing the load event at all on the window in the iframe in this case after the close() call, as far as I can see. And that's even true if I add an <img src> to that DOM...

I haven't tested what happens if I call doIt from the load event firing on the window in the subframe instead of from the load event firing on the iframe element, by the way. At least in Gecko I expect that to also suppress the load event for the written document.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the iframe testcase included in the issue and comparing its behavior with the specification's "mute iframe load" handling. Review the relationship to whatwg/html#4291 and determine whether the specification should describe suppression of the iframe window's load event. Done means reaching agreement on the intended behavior and identifying the required specification change.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.