Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPT for initial empty document history replacement behaviors #28541

Merged
merged 1 commit into from
Aug 27, 2022

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Apr 16, 2021

Adds WPTs for various ways navigation can happen on initial empty
documents, and their impact on session history.

Bug: 1215096
Change-Id: If8754e600e5feb6860ebf9aa4df481330b746eaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2831564
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Rakina Zata Amni <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1039711}

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

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

The review process for this patch is being conducted in the Chromium project.


// Do a fragment navigation within the initial empty document through iframe.src.
iframe.src = url1;
await new Promise(resolve => setTimeout(setTimeout(resolve, 100), 100));
Copy link
Member

Choose a reason for hiding this comment

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

setTimeout() takes a function, so passing it the result of setTimeout() (an integer) doesn't really work. I think this should be just await new Promise(resolve => setTimeout(resolve, 100))

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, of course. Thank you!


promise_test(async t => {
const startingHistoryLength = history.length;
// Create an ifame with src set to about:blank but navigate away from it immediately below.
Copy link
Member

Choose a reason for hiding this comment

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

"ifame" -> "iframe" here and elsewhere

window.addEventListener("message", t.step_func((event) => {
if (event.data == message)
resolve();
}), { once: true });
Copy link
Member

Choose a reason for hiding this comment

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

You could try removing { once: true } here to see if that helps the tests pass, e.g. if multiple messages are being sent somehow. If it doesn't help though then keeping it is best.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I think this helped some tests

if (iframe.contentDocument.readyState === 'complete') {
// Wait a bit longer in case the about:blank navigation after the
// initial empty document is asynchronous.
setTimeout(resolve, 100);
Copy link
Member

Choose a reason for hiding this comment

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

In general all uses of setTimeout should instead be t.step_timeout, which gives them extra time on slow test runners.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, changed!

const openedWindow = windowOpen204(t);

// Do a fragment navigation within the initial empty document through setting location.href.
openedWindow.location.href = url1;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this test is breaking because it's parsing #foo relative to this document, and not relative to 204-url.

Try openedWindow.location.hash = "foo" instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried that and it seems to fail a lot more (then again I changed a lot of other parts as well). Do you think we should use location.hash now?

Copy link
Member

Choose a reason for hiding this comment

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

I'm just worried that this is trying to load window-open-204-fragment.html#foo instead of /common/blank.html?pipe=status(204)#foo. Maybe just explicitly do openedWindow.location.href = "/common/blank.html?pipe=status(204)#foo"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think that's one of the source of flakiness. I changed it to navigate to about:blank#foo explicitly now!

openedWindow.location.href = url1;
await waitForMessage(t, "loaded");
assert_equals(openedWindow.history.length, 1,
"history.length must be 1 after normal navigation on initial empty document");
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised Chrome is failing this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this is failing because of https://bugs.chromium.org/p/chromium/issues/detail?id=524208#c22, which is being fixed in crrev.com/c/2794069

@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-2831564 branch 2 times, most recently from 34be15c to 89abc91 Compare April 20, 2021 21:54
@domenic
Copy link
Member

domenic commented Apr 21, 2021

It's unfortunate that this fails the stability checker, but it seems like this is just an inherently flaky area and we might need to ask for a stability checker override. Still, maybe you could debug at least on Chromium; see the command in https://github.com/web-platform-tests/wpt/pull/28541/checks?check_run_id=2395119277 . Maybe the timeouts just need to be longer or something.

@rakina
Copy link
Contributor

rakina commented Apr 22, 2021

It's unfortunate that this fails the stability checker, but it seems like this is just an inherently flaky area and we might need to ask for a stability checker override.

It passes the stability checker now! Looks like we need to wait for the window.open()-ed document to load first before continuing the navigation. Here's the latest Chrome, Firefox, Safari results. Firefox times out in most cases though, maybe they don't fire load for initial empty document loads? Or the load here is actually caused by Chrome and potentially Safari's non-initial empty document about:blank commit, hmm...

Also, unfortunately it looks like the behavior for iframe vs window.open() on is different for navigations after fragment navigations. For iframes, even after fragment navigations, we will still do replacement. For window.open(), we won't do a replace after the initial empty document. Not sure which behavior is nicer here :/

@domenic
Copy link
Member

domenic commented Apr 22, 2021

Oh, I'm so glad we were able to get a non-flaky version!

I'll discuss next steps in the spec issue based on these results.

@hsivonen
Copy link
Member

Is this PR expected to be the full extent of WPT changes for this spec change? That is, is it expected that there aren't modifications to existing tests?

@rakina
Copy link
Contributor

rakina commented Jan 12, 2022

Is this PR expected to be the full extent of WPT changes for this spec change? That is, is it expected that there aren't modifications to existing tests?

I think so, the "always replace" behavior landed in Chromium and no existing WPTs needed an update

@hsivonen
Copy link
Member

Is this PR expected to be the full extent of WPT changes for this spec change? That is, is it expected that there aren't modifications to existing tests?

I think so, the "always replace" behavior landed in Chromium and no existing WPTs needed an update

That surprises me. Thanks!

@rakina
Copy link
Contributor

rakina commented Aug 25, 2022

Looks like I completely forgot to land this, even after the relevant spec PRs had merged. Before we land, @hsivonen - do you have any comments?

@hsivonen
Copy link
Member

I think the easiest way forward is to land these and let them propagate to mozilla-central. I'm currently working on about:blank changes, so it's good to have these land, and I'll file follow-ups if I find concerns. Thanks.

@hsivonen
Copy link
Member

Previously, I wrote:

Is this PR expected to be the full extent of WPT changes for this spec change? That is, is it expected that there aren't modifications to existing tests?

Today, I discovered that https://github.com/web-platform-tests/wpt/blob/master/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1-1.html#L11 and https://github.com/web-platform-tests/wpt/blob/master/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_2-1.html#L12 need changing.

(I intend to eventually change these two lines myself; I already have a pending patch, but it's going to take some time to get landed due to what else is in the same patch.)

@rakina
Copy link
Contributor

rakina commented Aug 26, 2022

Thanks @hsivonen! Regarding the tests you mentioned, looks like Chrome is already failing those since long ago (see expectations 1 and 2, we don't increase the history.length when the iframe loads), so looks like we do need to change the expectations in the WPT itself if Firefox starts behaving similarly.

Also, it looks like some cases are flakily failing only on Firefox: https://github.com/web-platform-tests/wpt/pull/28541/checks?check_run_id=8030346986. Not really sure why only some types of navigations are hitting that... are we OK landing the WPTs as is with the flakiness, or do you have suggestions to handle those (maybe disable the tests on Firefox somehow?)

@hsivonen
Copy link
Member

Also, it looks like some cases are flakily failing only on Firefox: https://github.com/web-platform-tests/wpt/pull/28541/checks?check_run_id=8030346986. Not really sure why only some types of navigations are hitting that... are we OK landing the WPTs as is with the flakiness, or do you have suggestions to handle those (maybe disable the tests on Firefox somehow?)

My preference is landing these into WPT as flaky, letting them sync to mozilla-central, and then annotating them there. I'm actively working on a change that I expect to fix these on the Firefox side.

@chromium-wpt-export-bot chromium-wpt-export-bot changed the title WPT for initial empty document on iframes WPT for initial empty document history replacement behaviors Aug 26, 2022
Adds WPTs for various ways navigation can happen on initial empty
documents, and their impact on session history.

Bug: 1215096
Change-Id: If8754e600e5feb6860ebf9aa4df481330b746eaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2831564
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Rakina Zata Amni <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1039711}
@rakina
Copy link
Contributor

rakina commented Aug 26, 2022

My preference is landing these into WPT as flaky, letting them sync to mozilla-central, and then annotating them there. I'm actively working on a change that I expect to fix these on the Firefox side.

Thanks! I've landed the WPT on Chromium, lmk if I need to do anything else. Looking forward to see Firefox pass the tests!

@sj0602 sj0602 closed this Aug 26, 2022
@sj0602 sj0602 reopened this Aug 26, 2022
@WeizhongX
Copy link
Contributor

WPT Command: python3 ./wpt run --channel=nightly --verify --verify-no-chaos-mode --verify-repeat-loop=0 --verify-repeat-restart=10 --github-checks-text-file=/home/test/artifacts/checkrun.md --affected base_head --log-mach-level=info --log-mach=- -y --no-pause --no-restart-on-unexpected --install-fonts --no-headless --verify-log-full --binary=/home/test/build/firefox/firefox firefox

Some affected tests had inconsistent (flaky) results:

Unstable results

Test Subtest Results Messages
/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-src-204-fragment.html src FAIL: 5/10, PASS: 5/10 assert_equals: history.length must not change after normal navigation from initial empty document expected 1 but got 2
/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-src-204-fragment.html location.href FAIL: 6/10, PASS: 4/10 assert_equals: history.length must not change after fragment navigation on initial empty document expected 2 but got 1;assert_equals: history.length must not change after normal navigation from initial empty document expected 1 but got 2
/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-aboutblank.html location.href FAIL: 5/10, PASS: 5/10 assert_equals: history.length should not increase after normal navigation away from initial empty document expected 1 but got 2
/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-aboutblank.html location.assign FAIL: 5/10, PASS: 5/10 assert_equals: history.length should not increase after normal navigation away from initial empty document expected 1 but got 2

These may be pre-existing or new flakes. Please try to reproduce (see the above WPT command, though some flags may not be needed when running locally) and determine if your change introduced the flake. If you are unable to reproduce the problem, please tag @web-platform-tests/wpt-core-team in a comment for help.

@WeizhongX
Copy link
Contributor

@sj0602, this one is blocked because some tests are flaky on firefox. Below is some instructions to handle such case:

A common problem is the TaskCluster stability check failing, which indicates that a test is flaky. This is very often a problem with the test itself and will require help from the author, so deflaking these can take some time. To avoid these PRs from piling up we aim to clear them from the queue and apply a fix in the background.

Follow these steps (see #23617 for a recent example):

copy the "Unstable Results" from the TaskCluster log into the PR for easier viewing.
create a crbug to record the flake, which should point to the PR and be assigned to the CL author.
reference the new bug in the PR.
force merge the PR(ask @KyleJu or @DanielRyanSmith for help).

@sj0602 sj0602 closed this Aug 26, 2022
@sj0602 sj0602 reopened this Aug 26, 2022
@sj0602
Copy link
Contributor

sj0602 commented Aug 26, 2022

Files crbug.com/1357195.

@WeizhongX
Copy link
Contributor

@KyleJu @DanielRyanSmith can you help admin merge? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants