-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Should location-object-navigate (and friends) queue a task to navigate instead of navigating directly? #3730
Comments
How would it throw an exception if it queued a task? |
Doesn't the issue of throwing exceptions also apply to hyperlink navigations? So following that line of reasoning, then maybe nothing should be queued? |
No, that doesn't set the exceptions enabled flag. |
Is the below test correct, if we assume that no task should be queued(cc servo/servo#23368)? This test uses
Wouldn't this only happen if a task was queued? (Or is the expected delay related to execution of the newly created script?) |
Also, just to point it out, in the case of the anchor element, following-hyperlinks says to "queue a task to navigate". Then, inside navigate, we are told to queue a task to execute a JS url request. So this means that in the examples discussed above, while no task should be queued to navigate(which includes unloading and so on), a task should be queued to perform step 13, in the case that it involves a JS url. So the test I mentioned above, On the other hand, related the anchor element, there is also So the test suite seems to expect that when navigate is done in a task(in the case of an anchor following a hyperlink), no task is enqueued for the JS url part, and when navigate is not done in a task, a task is enqueued for the JS url part. I haven't looked into Since executing the JS url involves manipulating the realm of JS objects(I think), it makes sense to do thart part in a task on the event-loop. Note that otherwise step 13 is done "in-parallel". |
Update: In the context of That's because the tests only sets |
So all in all, I'd go for the following:
So at this point the spec could perhaps say "unless this navigation is the result of running the "following-hyperlinks" algorithm, in which case the following steps should be done in the same task that invoked the navigation steps? Would need a bit of reshuffle at step 12 too, so that it doesn't read "continue running these steps in parallel" in that particular case... |
This test is, as you note, not following the spec. Note that it's marked as failing in Firefox... It also fails in Safari, per https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/execution-timing/029.html?label=master&product=chrome%5Bexperimental%5D&product=edge&product=firefox%5Bexperimental%5D&product=safari%5Bexperimental%5D&aligned&q=html%2Fsemantics%2Fscripting-1%2Fthe-script-element%2Fexecution-timing%2F029.html It seems to be passing in Chrome for reasons that are entirely unclear to me, but Chrome is making a bunch of changes in this area right now to align with the spec, so I suspect the right thing is to just fix this test to follow the spec. That said, last I checked there were suggestions that the spec (and implementations) be changed to not queue an extra task when following hyperlinks. I do NOT thing we should add special-casing in navigation for the hyperlink case. |
Ok, thanks for the info, I will happily mark Actually I'll look at changing the test instead... |
What @bzbarsky said. I think navigation (and form submission too as a special case) should be invoked synchronously and not involve additional tasks that can result in changing state and such. |
See whatwg/html#3730. Follows the spec in whatwg/html#6315.
See whatwg/html#3730. Follows the spec in whatwg/html#6315.
Update: in #6315 we're speccing navigation to generally start synchronously. That is, neither location.href nor following hyperlinks will inherently queue a task. However, javascript: URL navigation is always done in a task. So there will always be a single task for javascript: URL navigation. Tests are added for that in web-platform-tests/wpt#36358, and at least Firefox and Chrome pass them. I will also look into fixing the 029.html test. |
See some discussion in whatwg/html#3730 about this test. However, it is very broken, and when we remove the brokenness, it becomes redundant with the just-added javascript-url-task-queuing.html. In particular, it's assuming beforeunload will fire. But beforeunload will never fire for a javascript: URL that returns a non-string value, since we're never in danger of unloading the document.
See whatwg/html#3730. Follows the spec in whatwg/html#6315.
See some discussion in whatwg/html#3730 about this test. However, it is very broken, and when we remove the brokenness, it becomes redundant with the just-added javascript-url-task-queuing.html. In particular, it's assuming beforeunload will fire. But beforeunload will never fire for a javascript: URL that returns a non-string value, since we're never in danger of unloading the document.
…ng, a=testonly Automatic update from web-platform-tests Add tests for javascript: URL task queuing See whatwg/html#3730. Follows the spec in whatwg/html#6315. -- Delete failing-in-all-browsers 029.html See some discussion in whatwg/html#3730 about this test. However, it is very broken, and when we remove the brokenness, it becomes redundant with the just-added javascript-url-task-queuing.html. In particular, it's assuming beforeunload will fire. But beforeunload will never fire for a javascript: URL that returns a non-string value, since we're never in danger of unloading the document. -- wpt-commits: b9d6751e534aed6a8d9eb1e7e51640f968b943bb, 1a2f69d137c5ccbaaf678bf372a1a410ced97eed wpt-pr: 36358
…ng, a=testonly Automatic update from web-platform-tests Add tests for javascript: URL task queuing See whatwg/html#3730. Follows the spec in whatwg/html#6315. -- Delete failing-in-all-browsers 029.html See some discussion in whatwg/html#3730 about this test. However, it is very broken, and when we remove the brokenness, it becomes redundant with the just-added javascript-url-task-queuing.html. In particular, it's assuming beforeunload will fire. But beforeunload will never fire for a javascript: URL that returns a non-string value, since we're never in danger of unloading the document. -- wpt-commits: b9d6751e534aed6a8d9eb1e7e51640f968b943bb, 1a2f69d137c5ccbaaf678bf372a1a410ced97eed wpt-pr: 36358
location-object-navigate doesn't currently specify that a task is queued to perform the navigation. However, it looks like some browsers do queue this:
In IE, this prints 2 and then 1.
In Chrome, Firefox, and Safari, this prints 1 and then 2.
Similarly, should
window.open()
queue a task to navigate as well?In Chrome and Safari, this prints 2 and then 1.
In Firefox and IE, this prints 1 and then 2.
And there's also
HTMLIFrameElement.src
:In Chrome, IE, and Safari, this prints 2 and then 1.
In Firefox, this prints 1 and then 2.
Queueing a task would be consistent with https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks-2, but it's not clear to me it's the right thing to do.
I'm not sure of a way to test this hypothesis without using javascript: URLs: it's entirely possible that the reason Firefox always prints 1 before 2 is because it is the only implementation that queues a task to process javascript: URLs.
The text was updated successfully, but these errors were encountered: