web-platform-tests/wpt

Add coverage for discarded browsing contexts

Open

#3,310 opened on Jul 19, 2016

View on GitHub
 (1 comment) (0 reactions) (0 assignees)HTML (4,581 stars) (2,898 forks)batch import
good first issuehtmltype:missing-coverage

Description

In https://github.com/whatwg/html/pull/1539 and linked issues we are having a voyage of discovery over what happens when you remove an iframe from a document. The browsing context is "discarded," but what does that imply?

Browsers vary wildly in exactly how they implement this. Most seem to agree on things "going away" in some fashion. But sometimes they return undefined instead of null, and Edge likes to give a strange "Object expected" error.

After that PR, the following are some good test cases I think could be added, per new spec. Assume iframeWindow and iframeDocument are saved references to an iframe's contentWindow and contentDocument, saved before removing the iframe.

  • iframeWindow.{top, parent, frameElement} should be null
  • iframeWindow.{window, self, frames} should be iframeWindow
  • iframeWindow.document should be iframeDocument
  • iframeDocument.defaultView should be null
  • iframeDocument.location should be null

There are also a series of possible tests around ensuring that such documents do not have a browsing context:

  • Inserting a stylesheet into iframeDocument should not cause fetches
  • Inserting an image into iframeDocument should not cause fetches
  • Inserting a script into iframeDocument should not cause script execution

Here are some live dom viewers that can give a start:

Contributor guide