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
Added implementation for itemprop and itemtype along with test files #19038
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon. |
@KiChjang , @fitzgen , @jdm
Whereas we had merged a pull request to add these into html5ever https://github.com/servo/html5ever/pull/320/files |
Have you ran Also, merge commits are not accepted. Please rebase against the master branch. |
Closing pull request to make minor tidy modifications |
tests/wpt/mozilla/meta/MANIFEST.json
Outdated
[ | ||
{} | ||
] | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This... doesn't seem it should be here.
tests/wpt/mozilla/meta/MANIFEST.json
Outdated
"mozilla/.DS_Store": [ | ||
"df2fbeb1400acda0909a32c1cf6bf492f1121e07", | ||
"support" | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@KiChjang we are having some difficulties in rebasing our branch, is there a possibility/option to squash the commits while merging? |
I can help you rebase against master, if you have the "Allow edits from maintainers" checkbox checked at the right hand side of GitHub's interface. Please let me know whether this is preferable to you, and if you agree to it, please do not push any code to your branch until my rebasing is complete. |
@@ -17,10 +17,16 @@ interface HTMLElement : Element { | |||
readonly attribute DOMStringMap dataset; | |||
|
|||
// microdata | |||
// attribute boolean itemScope; | |||
// attribute boolean itemScope; | |||
// attribute DOMString itemProp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these lines were already there. We don't need these comments, I can delete them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
.gitignore
Outdated
@@ -35,3 +35,5 @@ Servo.app | |||
.vscode | |||
|
|||
/unminified-js | |||
|
|||
tests/wpt/mozilla/tests/mozilla/microdata/local_tests.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is a script you wrote for your own testing purposes? Let's not add it to .gitignore; you can just leave it as an untracked file.
// attribute DOMString itemId; | ||
//readonly attribute HTMLPropertiesCollection properties; | ||
// attribute any itemValue; // acts as DOMString on setting | ||
[Pref="dom.microdata.enabled"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are only for use in test code, let's use the dom.microdata.testing.enabled name instead.
resources/prefs.json
Outdated
@@ -6,6 +6,7 @@ | |||
"dom.customelements.enabled": true, | |||
"dom.forcetouch.enabled": false, | |||
"dom.gamepad.enabled": false, | |||
"dom.microdata.enabled": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dom.microdata.testing.enabled
@@ -0,0 +1 @@ | |||
prefs: ["dom.microdata.enabled:true"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dom.microdata.testing.enabled
// Test body element | ||
var body = document.getElementById("body"); | ||
assert_array_equals(body.propertyNames().sort(), ["hello", "world"].sort(), "The method should return 'hello world' "); | ||
assert_array_equals(body.itemtypes().sort(), ["hello", "world"].sort(), "The method should return 'hello world' "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's reduce some of the duplication in this test (and others) like this:
var ids = ["body", "h1", "h2", "p", "input", "form", "li", "ul", "meta", "table", "div", "anchor"];
for (let id of ids) {
var elem = document.getElementById(id);
assert_array_equals(elem.propertyNames().sort(), ["hello", "world"], "duplicate itemprop tokens should be filtered");
assert_array_equals(elem.itemtypes().sort(), ["hello", "world"], "duplicate itemtype tokens should be filtered");
}
components/script/dom/htmlelement.rs
Outdated
@@ -44,27 +45,30 @@ pub struct HTMLElement { | |||
} | |||
|
|||
impl HTMLElement { | |||
pub fn new_inherited(tag_name: LocalName, prefix: Option<Prefix>, | |||
document: &Document) -> HTMLElement { | |||
pub fn new_inherited(tag_name: LocalName, prefix: Option<Prefix>, document: &Document) -> HTMLElement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains a lot of modifications caused by your editor automatically running rustfmt on the file, which makes it harder to review. Could you disable this feature, revert the changes to the file, and make your modifications to it again?
components/script/dom/htmlelement.rs
Outdated
self.upcast::<Element>() | ||
.GetAttribute(DOMString::from(String::from("itemtype"))) | ||
.unwrap_or(DOMString::from(String::from(""))), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than calling parse_plain_attribute here, we should use Element::get_tokenlist_attribute instead, which will return the previously-parsed value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About this change, do we then remove the parse_plain_attribute method that we implemented ? because its purpose was to be used in this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, parse_plain_attribute is a method that gets called from other parts of Servo already. Your implementation is required, like adding a virtual method override in C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, we have now used Element::get_tokenlist_attribute and will push the code in few minutes, running test-tidy now. When can we expect the appveyor to work again? ;(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor passing is not required for landing. Also, when we finally approve your changes and are ready to land your changes, we have another build & test system that will build and test your changes against all web platform tests before merging your PR to the master branch.
components/script/dom/htmlelement.rs
Outdated
} | ||
let opt: Option<Vec<DOMString>> = Some(item_attr_vector); | ||
return opt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of manually draining and pushing, we can replace this with:
Some(item_attrs.into_iter().collect())
components/script/dom/htmlelement.rs
Outdated
self.upcast::<Element>() | ||
.GetAttribute(DOMString::from(String::from("itemprop"))) | ||
.unwrap_or(DOMString::from(String::from(""))), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments for this method as the previous one.
☔ The latest upstream changes (presumably #18967) made this pull request unmergeable. Please resolve the merge conflicts. |
Thank you for the review comments. We will begin incorporating changes and provide an update. |
Closing the pull request, to make changes. Will reopen once the changes are pushed |
It is perfectly acceptable to leave the PR open while you make changes. |
@CJ8664 Not necessary; on the GitHub UI, if you have the "Allow maintainer to edit branch" checkbox checked, then people with write access to the servo repository would be able to push to your PR branch. I've just done that, so you should see all your team's work squashed into 1 commit on this branch. Thank you for your work! @bors-servo r=jdm |
📌 Commit 7b3794b has been approved by |
Added implementation for itemprop and itemtype along with test files <!-- Please describe your changes on the following line: --> --- <!-- 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 <!-- Either: --> - [x] There are tests for these changes OR <!-- 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. --> <!-- 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/19038) <!-- Reviewable:end -->
💔 Test failed - android |
Sigh. There's an extra newline at the end of Cargo.lock that needs to be removed. :( |
Hey @KiChjang should we remove the extraline from Cargo.lock or pushing our changes onto this PR would mess it up? |
That should take care of it. |
Created test file Added the stub methods for itemprop and itemscope Resolved html5ever dependency, added ItemScope and ItemProp attr Resolving dependency Added pref override on metadata attributes Resetting to original state due to change in requirement Reverted adding attributes 1. add a customized implementation of parse_plain_attribute 2. add the following methods to HTMLElement.webidl added itemprop and itemtype, enabled pref in test Added initial implementation for getting itemprop property values Adding the wireframe for testing Implemented function to handle itemType Corrected typo Fixed typo bug in code Handling duplicates for itemtype attribute values Added the test suite structure Added test for extra space Added test for regular test values Added test cases for Single property values Test cases to check absence of itemtype and itemprop attributes Added code to handle absence of itemtype or itemprop attributes Added shell script to run all test cases cleared up Cargo file Tidying up Removed the local test file Removed new line for test-tidy Ordered key in prefs.json Fixes for test-tidy Enabled test preferences Created test using wpt Creating WPT Tests for Regular and Single Prop Types Fixed the Regular type test Fixed tests Removed old test case metadata Incorporate review changes from PR Updated MANIFEST to sync test cases Making changed suggested in review Removed editor folding Removed unnecessary code Resolving cargo conflicts Updated PropertyNames and itemtypes implementation Trying different data in test case Updated manifest Updated code based on reviews
Lets see if it builds this time |
@bors-servo: r+ |
📌 Commit 4a43dba has been approved by |
Added implementation for itemprop and itemtype along with test files <!-- Please describe your changes on the following line: --> --- <!-- 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 <!-- Either: --> - [x] There are tests for these changes OR <!-- 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. --> <!-- 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/19038) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is