whatwg / whatwg/html

Event handler IDL attributes for non-fully-active documents

Open
#11,618 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: multiple globals
Dominant language
HTML
Stars
9.4k
Forks
3.2k
PR merge metrics
PR metrics pending

Description

What is the issue with the HTML Standard?

I believe that per spec, something like:

frames[0].document.body.setAttribute("onclick", "void(0)");
const frames0Document = frames[0].document;
await navigate0thFrame();
const f = frames0Document.body.onclick;

gives different results depending on whether frames[0] is in bfcache or not. Reasoning: the onclick getter algorithm will return null in step 3.2 if evicted from bfcache, because in that case frames[0].document does not have a browsing context. Whereas, if it is still in bfcache, then the algorithm will proceed, and f will become a Function from the frames[0].document.defaultView global.

Similarly, if instead of "void(0)" I'd put "++++++syntaxerror+++++", if the document is in bfcache an error event would be fired on frames[0].document.defaultView, whereas if it's evicted then nothing would happen.

In practice I believe this is not a problem because no browser allows bfcaching of iframes (or of windows with openers), so there is no way to actually run the code frames0Document.body.onclick while in bfcache.

If people wanted to fix this, some possibilities:

  • Expand "scripting is disabled" to say that scripting is disabled whenever the document is not fully active, instead of only when the document has no browsing context. (This could have unintended consequences.)
  • Add a fully active check to "get the current value of the event handler".
  • Codify the requirement not to bfcache globals for which there exists a JavaScript reference (i.e., iframes or windows with openers).

A bit of related discussion in https://github.com/web-platform-tests/wpt/pull/4089#issuecomment-3248026536.

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 with the HTML Standard's "getting the current value of the event handler" algorithm and the scripting-disabled definition referenced in the issue. Read the related discussion in web-platform-tests pull request 4089, then compare the proposed specification changes. Done means the behavior for non-fully-active documents is resolved and the corresponding standard requirements are agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
web-dev
Issue type
Feature
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.