Skip to content

Add sandbox attribute timing tests - #20411

Open
clelland wants to merge 3 commits into
masterfrom
add-sandbox-timing-tests
Open

clelland wants to merge 3 commits into
masterfrom
add-sandbox-timing-tests

Conversation

@clelland

Copy link
Copy Markdown
Contributor

This adds tests that ensure that changes to the iframe sandbox
attribute after a navigation starts do not affect the document which
is loaded into the iframe. The value of the attribute should be
snapshotted at the beginning of a navigation, to take effect when
the navigation completes.

This adds tests that ensure that changes to the iframe sandbox
attribute after a navigation starts do not affect the document which
is loaded into the iframe. The value of the attribute should be
snapshotted at the beginning of a navigation, to take effect when
the navigation completes.
@clelland

Copy link
Copy Markdown
Contributor Author

FYI, these are the current results in Chrome tip-of-tree and Firefox nightly 72.0a1 (haven't tried Safari yet; I don't have the WPT server running on my mac)

  • sandbox-navigation-timing: Fails in Chrome because final document is sandboxed. Fails in Firefox without inspector because initial about:blank document is sandboxed. Passes with inspector open.
  • sandbox-navigation-timing-2: Fails in Chrome and Firefox (without inspector) because final document has allow-same-origin. Passes in Firefox with inspector open.
  • sandbox-navigation-timing-3: Passes in Chrome. Fails in Firefox because final document does not allow scripts.

This adds an h1 element to the framed document which will read 'No
scripts' if scripts are not allowed in the document, and 'Allows
scripts' if they are.
@zcorpan

zcorpan commented Nov 26, 2019

Copy link
Copy Markdown
Member

@clelland you can view results on wpt.fyi (linked from e.g. the wpt.fyi - chrome[experimental] check).

https://wpt.fyi/results/html/browsers/sandboxing?label=pr_head&max-count=1&pr=20411

@clelland

Copy link
Copy Markdown
Contributor Author

Ooh, thanks -- the &pr= is rather useful!

@clelland

clelland commented Nov 26, 2019 •

Copy link
Copy Markdown
Contributor Author

So Safari appears to match Chrome's behaviour for sandbox-navigation-timing, match Chrome and Firefox for sandbox-navigation-timing-2, and matches Firefox for sandbox-navigation-timing-3 (all 3 fail). I'll file a bug there as well.

@clelland

clelland commented Dec 2, 2019

Copy link
Copy Markdown
Contributor Author

I've added a separate set of tests for 'srcdoc' iframes. in those, Firefox passes all three, while Chrome is currently failing.

@clelland

clelland commented Dec 3, 2019

Copy link
Copy Markdown
Contributor Author

@bzbarsky, can you take a look at these tests and see if they cover the relevant cases for sandbox timing?

There's still the issue of having the navigation initiated by the framed document, while the attribute is changed by the parent, but that may be fundamentally racy when the two are in separate processes. Otherwise, I think these tests should cover most of the potential paths.

@gsnedders gsnedders closed this Jan 24, 2020
@gsnedders
gsnedders deleted the add-sandbox-timing-tests branch January 24, 2020 18:01
@gsnedders
gsnedders restored the add-sandbox-timing-tests branch January 24, 2020 18:47
@Hexcles Hexcles reopened this Jan 24, 2020

@bzbarsky bzbarsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for the lag here. Two things:

  1. Ideally we would test flags other than the allows-same-origin flag. I say this because for a while in Firefox that flag was captured at navigation start but the other flags were captured at new-document-creation time.

  2. The test naming is a bit confusing, because these have nothing to do with the Navigation Timing spec. Might be better to call these sandbox-flag-timing or something?

} catch (e) {
window.parent.postMessage("Sandboxed", "*");
}
document.querySelector('h1').innerText = "Allows scripts"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use textContent instead of innerText? It's much more interoperable in terms of behavior....

Though I'm not sure why this line is here.

</head>
<body>
<script>
const resourcePath =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this works, but this might have been simpler:

const resourceURL = new URL("resources/", location);

and then later:

iframe.src = new URL("post-sandbox-state-to-parent.html", resourceURL);

or so. Similar elsewhere.

This branch was successfully deployed

1 active deployment
wpt-preview-20411 — 6fc6217a Deployed Mar 13, 2020 by wpt-pr-bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants