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

Handle crossorigin in Link #14940

Merged
merged 1 commit into from Jan 13, 2017
Merged

Handle crossorigin in Link #14940

merged 1 commit into from Jan 13, 2017

Conversation

@nmvk
Copy link
Contributor

nmvk commented Jan 10, 2017

Implemented Step three and handled step four of obtain the resource part
of 4.2.4 The link element.
Link to spec : https://html.spec.whatwg.org/multipage/semantics.html#concept-link-obtain


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes OR

This change is Reviewable

@highfive
Copy link

highfive commented Jan 10, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmllinkelement.rs, components/script/dom/webidls/HTMLLinkElement.webidl, components/script/stylesheet_loader.rs
  • @KiChjang: components/script/dom/htmllinkelement.rs, components/script/dom/webidls/HTMLLinkElement.webidl, components/script/stylesheet_loader.rs
@jdm jdm assigned jdm and unassigned emilio Jan 10, 2017
Copy link
Member

jdm left a comment

I'm glad to see more tests passing. I've made a few suggestions for ways to avoid duplicating code.

@@ -377,6 +387,32 @@ impl HTMLLinkElementMethods for HTMLLinkElement {
// https://html.spec.whatwg.org/multipage/#dom-link-target
make_setter!(SetTarget, "target");

// https://html.spec.whatwg.org/multipage/#dom-link-crossorigin

This comment has been minimized.

@nmvk

nmvk Jan 11, 2017

Author Contributor

Using enumerated_getter always returns default crossorigin value as anonymous. This value is returned even if request is not a valid crossorigin request. This breaks many test case.

This comment has been minimized.

@jdm

jdm Jan 11, 2017

Member

You're right. Could we share this code with htmlscriptelement.rs instead of duplicating it, in that case?

This comment has been minimized.

@nmvk

nmvk Jan 13, 2017

Author Contributor

I have fixed this.

}

// https://html.spec.whatwg.org/multipage/#dom-link-crossorigin
fn SetCrossOrigin(&self, value: Option<DOMString>) {

This comment has been minimized.

@jdm

jdm Jan 11, 2017

Member

My mistake; it can't. Let's add another set_cross_origin_attribute helper we can call from both HTMLLinkElement and HTMLScriptElement.

@@ -235,6 +237,14 @@ impl HTMLLinkElement {
}
};

// Step 3
let cors_setting = match self.GetCrossOrigin() {

This comment has been minimized.

@jdm

jdm Jan 10, 2017

Member

Let's make a helper function for this and share it with htmlscriptelement.rs.

This comment has been minimized.

@nmvk

nmvk Jan 11, 2017

Author Contributor

I have added a method in request.rs which given a &str returns CorsSettings. I am not sure if this is good refactoring. Other option could be return CorsSettings given DomString but I dont know what is the right location for such utility.

This comment has been minimized.

@jdm

jdm Jan 11, 2017

Member

I propose the following in element.rs:

fn reflect_cross_origin_attribute(element: &Element) -> Option<DOMString> {
    // body of HTMLScriptElement::GetCrossOrigin
}

fn cors_setting_for_element(element: &Element) -> Option<CorsSetting> {
    reflect_cross_origin_attribute(element).map(|attr| {
        // body of CorsSetting::from_str_ref
    })
}

Then these can be called by both HTMLLinkElement and HTMLScriptElement as necessary.

@@ -244,6 +255,6 @@ impl<'a> StylesheetLoader<'a> {

impl<'a> StyleStylesheetLoader for StylesheetLoader<'a> {
fn request_stylesheet(&self, import: &Arc<RwLock<ImportRule>>) {
self.load(StylesheetContextSource::Import(import.clone()), "".to_owned())
self.load(StylesheetContextSource::Import(import.clone()), None, "".to_owned())

This comment has been minimized.

@jdm

jdm Jan 10, 2017

Member

Let's add a TODO comment about whether we should use the original loader's CORS setting. I don't find any direction from the specification about it.

@bors-servo
Copy link
Contributor

bors-servo commented Jan 11, 2017

The latest upstream changes (presumably #14911) made this pull request unmergeable. Please resolve the merge conflicts.

Implemented Step three and handled step four of obtain the resource part
of 4.2.4 The link element.
Link to spec : https://html.spec.whatwg.org/multipage/semantics.html#concept-link-obtain

Refactored crossOrigin handling in HTMLScriptElement, HTMLImageElement
@nmvk nmvk force-pushed the nmvk:link-cross branch from 9853df0 to 3d9e44a Jan 13, 2017
@nmvk
Copy link
Contributor Author

nmvk commented Jan 13, 2017

@jdm Thanks, I have addressed review comments. Additionally I refactored HTMLImageElement to use this updated change.

@jdm
Copy link
Member

jdm commented Jan 13, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jan 13, 2017

📌 Commit 3d9e44a has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jan 13, 2017

Testing commit 3d9e44a with merge 9afd960...

bors-servo added a commit that referenced this pull request Jan 13, 2017
Handle crossorigin in Link

Implemented Step three and handled step four of obtain the resource part
of 4.2.4 The link element.
Link to spec : https://html.spec.whatwg.org/multipage/semantics.html#concept-link-obtain

<!-- 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

<!-- 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/14940)
<!-- Reviewable:end -->
@bors-servo bors-servo merged commit 3d9e44a into servo:master Jan 13, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@nmvk nmvk deleted the nmvk:link-cross branch Jan 13, 2017
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.

None yet

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