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

about:blank iframe fires two load events #15727

Open
jdm opened this issue Feb 24, 2017 · 6 comments
Open

about:blank iframe fires two load events #15727

jdm opened this issue Feb 24, 2017 · 6 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Feb 24, 2017

<iframe onload="console.log('iframe load')"></iframe>
@gpoesia
Copy link
Contributor

@gpoesia gpoesia commented Mar 3, 2017

I'd like to investigate this.

@jdm
Copy link
Member Author

@jdm jdm commented Mar 3, 2017

@gpoesia That would be really useful! I suspect it's caused by the special case in HTMLIFramElement::process_the_iframe_attributes and ScriptThread::handle_frame_load_event, so we'll probably want to suppress the one invoked by the ScriptThread.

@cbrewster
Copy link
Member

@cbrewster cbrewster commented Mar 15, 2017

The first load event comes from when the iframe is bound to the tree and create_nested_browsing_context is called. This will cause about:blank to be synchronously loaded which will fire a load event (this one is a bit hairy to track down). And then process_the_iframe_attributes will be called.
Since it is being called 1. For the first time 2. Without a src attribute, it will queue a task to fire the load event.

The second load event follows the spec as defined here: https://html.spec.whatwg.org/multipage/embedded-content.html#process-the-iframe-attributes

As @jdm said, we will want to suppress the load event that is fired when we are creating the nested browsing context with the initial about:blank load.

@cbrewster
Copy link
Member

@cbrewster cbrewster commented Mar 21, 2017

@gpoesia how is this going? Is there anything I can do to help?

gpoesia added a commit to gpoesia/servo that referenced this issue Mar 23, 2017
@gpoesia
Copy link
Contributor

@gpoesia gpoesia commented Mar 23, 2017

@cbrewster Would you take a look at #16091? I didn't find a better way of testing than waiting for some timeout. It bothers me that this makes the test non-deterministic in theory, but I think there can't be an exact way since we want to assert that "onload won't ever be called again", and that seems undecidable.

gpoesia added a commit to gpoesia/servo that referenced this issue Mar 25, 2017
gpoesia added a commit to gpoesia/servo that referenced this issue Mar 29, 2017
bors-servo added a commit that referenced this issue Mar 29, 2017
Fix iframe.onload being fired twice on about:blank.

<!-- Please describe your changes on the following line: -->
Supress the load event in the script thread when the iframe doesn't have a src attribute.
In that case, a load event is already fired when binding the iframe to the tree.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15727 (github issue number if applicable).

- [X] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16091)
<!-- Reviewable:end -->
gpoesia added a commit to gpoesia/servo that referenced this issue Mar 29, 2017
bors-servo added a commit that referenced this issue Mar 30, 2017
Fix iframe.onload being fired twice on about:blank.

<!-- Please describe your changes on the following line: -->
Supress the load event in the script thread when the iframe doesn't have a src attribute.
In that case, a load event is already fired when binding the iframe to the tree.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15727 (github issue number if applicable).

- [X] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16091)
<!-- Reviewable:end -->
gpoesia added a commit to gpoesia/servo that referenced this issue Apr 11, 2017
bors-servo added a commit that referenced this issue Apr 12, 2017
Fix iframe.onload being fired twice on about:blank.

<!-- Please describe your changes on the following line: -->
Supress the load event in the script thread when the iframe doesn't have a src attribute.
In that case, a load event is already fired when binding the iframe to the tree.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15727 (github issue number if applicable).

- [X] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16091)
<!-- Reviewable:end -->
gpoesia added a commit to gpoesia/servo that referenced this issue Apr 12, 2017
gpoesia added a commit to gpoesia/servo that referenced this issue Jul 3, 2017
gpoesia added a commit to gpoesia/servo that referenced this issue Jul 12, 2017
gpoesia added a commit to gpoesia/servo that referenced this issue Jul 19, 2017
bors-servo added a commit that referenced this issue Jul 19, 2017
Fix iframe.onload being fired twice on about:blank.

<!-- Please describe your changes on the following line: -->
Supress the load event in the script thread when the iframe doesn't have a src attribute.
In that case, a load event is already fired when binding the iframe to the tree.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15727 (github issue number if applicable).

- [X] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16091)
<!-- Reviewable:end -->
gpoesia added a commit to gpoesia/servo that referenced this issue Jul 25, 2017
gpoesia added a commit to gpoesia/servo that referenced this issue Jul 25, 2017
@jdm
Copy link
Member Author

@jdm jdm commented Jan 6, 2020

#16091 was a work in progress to fix this; I believe #16091 (comment) was the last set of requests but the author stopped responding.

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

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.