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

HTML: document.open() and tasks #10818

Merged
merged 11 commits into from
Aug 20, 2018
Merged

Conversation

annevk
Copy link
Member

@annevk annevk commented May 3, 2018

@wpt-pr-bot wpt-pr-bot added the html label May 3, 2018
@wpt-pr-bot wpt-pr-bot requested review from ayg, jdm, jgraham and zqzhang May 3, 2018 11:24
annevk added a commit to whatwg/html that referenced this pull request May 3, 2018
This is not consistently implemented and given that Firefox does not appear to do it at all I hope we can get away without it.

Tests: web-platform-tests/wpt#10818.
@domenic
Copy link
Member

domenic commented May 3, 2018

Some other potential tests:

  • An image being created and its load event being fired
  • A marquee element's start event being fired
  • A fetch completing

@annevk
Copy link
Member Author

annevk commented May 3, 2018

fetch() is interesting, I test that in #10789 and only Firefox fires an error event there. I guess I should add an onload with unreached_func to see if some trigger that.

@TimothyGu
Copy link
Member

w3c-test:mirror

@wpt-pr-bot wpt-pr-bot requested review from domenic, foolip, sideshowbarker and zcorpan and removed request for ayg July 13, 2018 19:25
@TimothyGu TimothyGu self-assigned this Jul 31, 2018
// second actually calls document.open() to test if the method call removes
// that specific task from the queue.

setup({
Copy link
Member

Choose a reason for hiding this comment

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

Can you point to the reason this is needed? (the promise rejection test below)

Reason being that this can also mask other problems with the test, so usage should be well motivated. (and is)

t.add_cleanup(() => frame.remove());
frame.onload = t.step_func(() => {
// Make sure there is no parser. Firefox seems to have an additional
// non-spec-compliant readiness state "uninitialized", so test for the
Copy link
Member

Choose a reason for hiding this comment

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

Can you file/link to a bug for this?


async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
// The empty HTML seems to be necessary to cajole Chrome into firing a load
Copy link
Member

Choose a reason for hiding this comment

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

Is there a bug that this could be linked to?


taskTest("timeout", (t, frame, open) => {
let happened = false;
// Work around the lint script, since we can't use step_timeout here.
Copy link
Member

Choose a reason for hiding this comment

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

I would probably add this to lint.whitelist, even if that means it's possible to accidentally add setTimeout elsewhere in this file. It's a small file, and that this fools the linter is arguably just a bug. (For more granular opt-outs some special comment syntax would be an option.)

taskTest("timeout", (t, frame, open) => {
let happened = false;
// Work around the lint script, since we can't use step_timeout here.
frame.contentWindow['setTimeout'](() => happened = true, 100);
Copy link
Member

Choose a reason for hiding this comment

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

Rather than setting happened here, how about just t.step_func_done() as the callback to pass the test ASAP?

The following test just times out if there isn't a 2nd message event, so I'd let this test also time out. If that's no good, is there any timeout one could pick that doesn't make the test more likely to be flaky on slow runners?

counter++;
assert_less_than_equal(counter, 2);
if (counter == 2) {
t.done();
Copy link
Member

Choose a reason for hiding this comment

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

(This is the test that will time out after 30s or so.)

Copy link
Member

Choose a reason for hiding this comment

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

This didn't seem to timeout in the latest Travis run…

Copy link
Member

Choose a reason for hiding this comment

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

Travis unfortunately doesn't fail unless the tests are flaky, it doesn't help catch any other problem, even totally broken tests. Did you read the logs to see that it didn't time out, or how could you tell?

Copy link
Member

Choose a reason for hiding this comment

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

Oh right, I guess I meant rather that it wasn't flaky.

});
});

taskTest("canvas.toBlob()", (t, frame, open) => {
Copy link
Member

Choose a reason for hiding this comment

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

The "queue a task" of toBlob happens inside "in parallel" so might not have happened when document.open() is called, is that a problem for this test? Does any browser currently fail this?

Copy link
Member

Choose a reason for hiding this comment

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

Good point. No browser actually seems to fail this, but I should note that setTimeout is defined the same way (wait in parallel, and then queue a task), and browsers have very different behavior with regards to that. That's why I think this is a good test.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, I didn't know setTimeout did that internally in the spec. I tend to think of "in parallel" as possibly happening on another thread or process (thus requiring "queue a task" to rejoin main thread) and that's certainly not how setTimeout is implemented. Test LGTM in any case, at worst it'll pass everywhere always :)

const doc = frame.contentDocument;
const marquee = doc.body.appendChild(doc.createElement("marquee"));
open(frame.contentDocument);
marquee.addEventListener("start", t.step_func_done());
Copy link
Member

Choose a reason for hiding this comment

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

I like this one. If you want one which is a bit special in practice try a new audio element and changing the volume attribute to 0.5. That should queue a task to fire volumechange. But implementations do something special to emulate that per-instance task source that media elements are supposed to have, and I wouldn't be surprised if it's different from other things tested here.

TimothyGu added a commit to TimothyGu/html that referenced this pull request Aug 14, 2018
Based on the work by Anne van Kesteren in whatwg#3651, but without the parts
concerning the session history. Changes to that area will come later
(see whatwg#3818).

Tests: web-platform-tests/wpt#10773
Tests: web-platform-tests/wpt#10778
Tests: web-platform-tests/wpt#10789
Tests: web-platform-tests/wpt#10815
Tests: web-platform-tests/wpt#10818

Fixes whatwg#1698.
Fixes whatwg#3286.
Fixes whatwg#3306.
Closes whatwg#3665.

Co-authored-by: Anne van Kesteren <[email protected]>
TimothyGu added a commit to TimothyGu/html that referenced this pull request Aug 14, 2018
Based on the work by Anne van Kesteren in whatwg#3651, but without the parts
concerning the session history. Changes to that area will come later
(see whatwg#3818).

Tests: web-platform-tests/wpt#10773
Tests: web-platform-tests/wpt#10778
Tests: web-platform-tests/wpt#10815
Tests: web-platform-tests/wpt#10818

Fixes whatwg#1698.
Fixes whatwg#3286.
Fixes whatwg#3306.
Closes whatwg#3665.

Co-authored-by: Anne van Kesteren <[email protected]>
domenic pushed a commit to whatwg/html that referenced this pull request Aug 16, 2018
In particular, removes the realm creation, document unloading, and tasks
removal steps.

Based on the work by Anne van Kesteren in #3651, but without the parts
concerning the session history. Changes to that area will come later
(see #3818).

These changes allow us to remove several auxiliary concepts that only
existed to support document.open():

- The recycle parameter to the "unload a Document" algorithm
- The window parameter to the "set the active document" algorithm

Tests: web-platform-tests/wpt#10773
Tests: web-platform-tests/wpt#10778
Tests: web-platform-tests/wpt#10815
Tests: web-platform-tests/wpt#10818

Fixes #1698.
Fixes #3286.
Fixes #3306.
Closes #3665.
@TimothyGu TimothyGu force-pushed the annevk/document-open-steps-and-tasks branch from 1c519a7 to f07c4e2 Compare August 17, 2018 18:22
Copy link
Member

@foolip foolip left a comment

Choose a reason for hiding this comment

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

Only remaining comments requiring change are the "link to bug" ones, if you like.

@TimothyGu TimothyGu force-pushed the annevk/document-open-steps-and-tasks branch from c90163d to 176e9c0 Compare August 20, 2018 15:28
@TimothyGu TimothyGu force-pushed the annevk/document-open-steps-and-tasks branch from 176e9c0 to fcf210e Compare August 20, 2018 18:33
@TimothyGu TimothyGu merged commit 87329a1 into master Aug 20, 2018
@TimothyGu TimothyGu deleted the annevk/document-open-steps-and-tasks branch August 20, 2018 18:53
zcorpan pushed a commit that referenced this pull request Aug 27, 2018
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
In particular, removes the realm creation, document unloading, and tasks
removal steps.

Based on the work by Anne van Kesteren in whatwg#3651, but without the parts
concerning the session history. Changes to that area will come later
(see whatwg#3818).

These changes allow us to remove several auxiliary concepts that only
existed to support document.open():

- The recycle parameter to the "unload a Document" algorithm
- The window parameter to the "set the active document" algorithm

Tests: web-platform-tests/wpt#10773
Tests: web-platform-tests/wpt#10778
Tests: web-platform-tests/wpt#10815
Tests: web-platform-tests/wpt#10818

Fixes whatwg#1698.
Fixes whatwg#3286.
Fixes whatwg#3306.
Closes whatwg#3665.
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
In particular, removes the realm creation, document unloading, and tasks
removal steps.

Based on the work by Anne van Kesteren in whatwg#3651, but without the parts
concerning the session history. Changes to that area will come later
(see whatwg#3818).

These changes allow us to remove several auxiliary concepts that only
existed to support document.open():

- The recycle parameter to the "unload a Document" algorithm
- The window parameter to the "set the active document" algorithm

Tests: web-platform-tests/wpt#10773
Tests: web-platform-tests/wpt#10778
Tests: web-platform-tests/wpt#10815
Tests: web-platform-tests/wpt#10818

Fixes whatwg#1698.
Fixes whatwg#3286.
Fixes whatwg#3306.
Closes whatwg#3665.
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.

5 participants