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

Implement srcdoc support for iframes #24576

Merged
merged 2 commits into from Nov 12, 2019
Merged

Conversation

@amj23897
Copy link

amj23897 commented Oct 29, 2019

This PR contains changes related to adding srcdoc attribute parsing support for iframes in Servo. The following changes have been made:

  • uncomment the srcdoc WebIDL attribute, and implement the attribute getter.
  • add a field to LoadData for storing the srcdoc contents when loading a srcdoc iframe.
  • (partially) implemented a new page_load_about_srcdoc method to script_thread.rs which loads the special about:srcdoc URL per the specification and takes the srcdoc contents as an argument
  • call this new method from handle_new_layout when it's detected that a srcdoc iframe is being loaded
  • (partially) in attribute_mutated, ensure that changing the srcdoc attribute of an iframe element follows the specification.

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes are a part of fix #4767 (GitHub issue number if applicable)
@highfive
Copy link

highfive commented Oct 29, 2019

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @ferjm (or someone else) soon.

@highfive
Copy link

highfive commented Oct 29, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmliframeelement.rs, components/script/script_thread.rs, components/script/dom/webidls/HTMLIFrameElement.webidl
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/script_thread.rs, components/script_traits/lib.rs, components/script/dom/webidls/HTMLIFrameElement.webidl
@highfive
Copy link

highfive commented Oct 29, 2019

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@jdm
Copy link
Member

jdm commented Oct 29, 2019

r? @jdm
I'll answer your questions tomorrow morning! Looks like a good start.

@highfive highfive assigned jdm and unassigned ferjm Oct 29, 2019
components/script/dom/htmliframeelement.rs Outdated Show resolved Hide resolved
components/script/dom/htmliframeelement.rs Outdated Show resolved Hide resolved
components/script/script_thread.rs Outdated Show resolved Hide resolved
components/script/script_thread.rs Outdated Show resolved Hide resolved
@jdm
Copy link
Member

jdm commented Nov 4, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

Trying commit 616bb1f with merge c9158bb...

bors-servo added a commit that referenced this pull request Nov 4, 2019
Implement srcdoc support for iframes

<!-- Please describe your changes on the following line: -->
This PR contains changes related to adding srcdoc attribute parsing support for iframes in Servo. The following changes have been made:

- uncomment the [srcdoc](https://github.com/servo/servo/blob/f63b404e0cbf30380c4043700861110d06e548bb/components/script/dom/webidls/HTMLIFrameElement.webidl#L10-L11) WebIDL attribute, and implement the attribute getter.
- add a field to [LoadData](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script_traits/lib.rs#L137-L164) for storing the srcdoc contents when loading a srcdoc iframe.
- (partially) implemented a new `page_load_about_srcdoc` method to `script_thread.rs` which loads the special `about:srcdoc` URL [per the specification](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes) and takes the srcdoc contents as an argument
- call this new method from [handle_new_layout](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script/script_thread.rs#L2409-L2412) when it's detected that a srcdoc iframe is being loaded
- (partially) in [attribute_mutated](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script/dom/htmliframeelement.rs#L560), ensure that changing the `srcdoc` attribute of an iframe element [follows the specification](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-9).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes are a part of fix #4767  (GitHub issue number if applicable)

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

💔 Test failed - linux-rel-css

load_data.srcdoc = self.get_srcdoc();
self.navigate_or_reload_child_browsing_context(
load_data,
NavigationType::Regular,

This comment has been minimized.

Copy link
@jdm

jdm Nov 4, 2019

Member

Ah, here's the missing piece - in navigate_or_reload_child_browsing_context there's a special branch for NavigationType::InitialAboutBlank which ends up calling ScriptThread::handle_new_layout. If you pass that instead of NavigationType::Regular you should end up with more meaningful test results.

This comment has been minimized.

Copy link
@jdm

jdm Nov 4, 2019

Member

The reason this matters is that Regular causes us to go to the network thread and try to make a request for about:srcdoc, which is then not a recognized URL so we get an error page. To quickly verify if this is working correctly or not, use this test page:

<iframe srcdoc="<div>hi!</div><script>foo=5;</script>" onload="console.log(this.contentWindow.foo)"></iframe>

In the current branch, I see an iframe containing an error message. With the change I suggested, there should be an iframe with "hi!" and the terminal should show 5.

This comment has been minimized.

Copy link
@amj23897

amj23897 Nov 4, 2019

Author

I have done the change. But not tested yet.

This comment has been minimized.

Copy link
@amj23897

amj23897 Nov 4, 2019

Author

Done. I can see the iframe and terminal shows 5. But main tests are failing. The command used:
./mach test-wpt tests/wpt/web-platform-tests/html/semantics/embedded-content/the-iframe-element/srcdoc_process_attributes.html

@jdm
Copy link
Member

jdm commented Nov 4, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

Trying commit e157126 with merge 2e52d7f...

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2019

💔 Test failed - linux-rel-css

@jdm jdm force-pushed the jaymodi98:iframe-srcdoc branch from 721280e to ddd9cd9 Nov 12, 2019
@jdm
Copy link
Member

jdm commented Nov 12, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2019

Trying commit ddd9cd9 with merge dff4717...

bors-servo added a commit that referenced this pull request Nov 12, 2019
Implement srcdoc support for iframes

<!-- Please describe your changes on the following line: -->
This PR contains changes related to adding srcdoc attribute parsing support for iframes in Servo. The following changes have been made:

- uncomment the [srcdoc](https://github.com/servo/servo/blob/f63b404e0cbf30380c4043700861110d06e548bb/components/script/dom/webidls/HTMLIFrameElement.webidl#L10-L11) WebIDL attribute, and implement the attribute getter.
- add a field to [LoadData](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script_traits/lib.rs#L137-L164) for storing the srcdoc contents when loading a srcdoc iframe.
- (partially) implemented a new `page_load_about_srcdoc` method to `script_thread.rs` which loads the special `about:srcdoc` URL [per the specification](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes) and takes the srcdoc contents as an argument
- call this new method from [handle_new_layout](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script/script_thread.rs#L2409-L2412) when it's detected that a srcdoc iframe is being loaded
- (partially) in [attribute_mutated](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script/dom/htmliframeelement.rs#L560), ensure that changing the `srcdoc` attribute of an iframe element [follows the specification](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-9).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes are a part of fix #4767  (GitHub issue number if applicable)

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2019

💔 Test failed - linux-rel-wpt

@jdm jdm force-pushed the jaymodi98:iframe-srcdoc branch from ddd9cd9 to af158de Nov 12, 2019
@jdm
Copy link
Member

jdm commented Nov 12, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2019

📌 Commit af158de has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2019

Testing commit af158de with merge bd0ae59...

bors-servo added a commit that referenced this pull request Nov 12, 2019
Implement srcdoc support for iframes

<!-- Please describe your changes on the following line: -->
This PR contains changes related to adding srcdoc attribute parsing support for iframes in Servo. The following changes have been made:

- uncomment the [srcdoc](https://github.com/servo/servo/blob/f63b404e0cbf30380c4043700861110d06e548bb/components/script/dom/webidls/HTMLIFrameElement.webidl#L10-L11) WebIDL attribute, and implement the attribute getter.
- add a field to [LoadData](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script_traits/lib.rs#L137-L164) for storing the srcdoc contents when loading a srcdoc iframe.
- (partially) implemented a new `page_load_about_srcdoc` method to `script_thread.rs` which loads the special `about:srcdoc` URL [per the specification](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes) and takes the srcdoc contents as an argument
- call this new method from [handle_new_layout](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script/script_thread.rs#L2409-L2412) when it's detected that a srcdoc iframe is being loaded
- (partially) in [attribute_mutated](https://github.com/servo/servo/blob/e6b271d32981ad95442c029bf72bd35efc88f9c5/components/script/dom/htmliframeelement.rs#L560), ensure that changing the `srcdoc` attribute of an iframe element [follows the specification](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-9).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes are a part of fix #4767  (GitHub issue number if applicable)

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@cagandhi
Copy link
Contributor

cagandhi commented Nov 12, 2019

@jdm Is there some way we can help in solving the synchronous navigation issue?

@jdm
Copy link
Member

jdm commented Nov 12, 2019

@cagandhi The actual implementation work would be doable, but I would need to do some talking with more knowledgeable people first about what the expected model should be.

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing bd0ae59 to master...

@bors-servo bors-servo merged commit af158de into servo:master Nov 12, 2019
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
@cagandhi
Copy link
Contributor

cagandhi commented Nov 13, 2019

@jdm On behalf of all my team members @jaymodi98 @amj23897, I would like to thank you for helping us immensely with this. This was our first open-source contribution and it feels really great now that the code is merged.

@jdm
Copy link
Member

jdm commented Nov 13, 2019

Thanks for taking the plunge with us!

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

Successfully merging this pull request may close these issues.

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