Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement srcdoc support for iframes #24576
Conversation
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
commented
Oct 29, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Oct 29, 2019
|
r? @jdm |
|
@bors-servo try=wpt |
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. -->
|
|
| load_data.srcdoc = self.get_srcdoc(); | ||
| self.navigate_or_reload_child_browsing_context( | ||
| load_data, | ||
| NavigationType::Regular, |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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
|
@bors-servo try=wpt |
|
|
|
@bors-servo try=wpt |
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 r+ |
|
|
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. -->
|
@jdm Is there some way we can help in solving the synchronous navigation issue? |
|
@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. |
|
|
|
@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. |
|
Thanks for taking the plunge with us! |
amj23897 commentedOct 29, 2019
This PR contains changes related to adding srcdoc attribute parsing support for iframes in Servo. The following changes have been made:
page_load_about_srcdocmethod toscript_thread.rswhich loads the specialabout:srcdocURL per the specification and takes the srcdoc contents as an argumentsrcdocattribute of an iframe element follows the specification../mach build -ddoes not report any errors./mach test-tidydoes not report any errors