diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-06-02 07:20:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-02 07:20:41 -0400 |
commit | 31ee17e9e1c6012fd512f594c27abb44fe927ec4 (patch) | |
tree | 7f5bf0528c6dbd2312fb1ad8d62f67d2d4ea5bf7 /components/script | |
parent | 9d9fff3b0ad843286875051e6544b3d4750d6238 (diff) | |
parent | 05bef140bfe39ee49147230169800ce3b23704eb (diff) | |
download | servo-31ee17e9e1c6012fd512f594c27abb44fe927ec4.tar.gz servo-31ee17e9e1c6012fd512f594c27abb44fe927ec4.zip |
Auto merge of #23335 - csmoe:w_origin, r=jdm
Implement worker origin member of WorkerLocation
Closes #23331
r?@jdm
(cannot build servo on my mac pro, hope CI helps)
<!-- 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
<!-- 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/23335)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/webidls/WorkerLocation.webidl | 2 | ||||
-rw-r--r-- | components/script/dom/workerlocation.rs | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/components/script/dom/webidls/WorkerLocation.webidl b/components/script/dom/webidls/WorkerLocation.webidl index 4a22c5e82e3..faaf10932bc 100644 --- a/components/script/dom/webidls/WorkerLocation.webidl +++ b/components/script/dom/webidls/WorkerLocation.webidl @@ -6,7 +6,7 @@ [Exposed=Worker] interface WorkerLocation { /*stringifier*/ readonly attribute USVString href; - // readonly attribute USVString origin; + readonly attribute USVString origin; readonly attribute USVString protocol; readonly attribute USVString host; readonly attribute USVString hostname; diff --git a/components/script/dom/workerlocation.rs b/components/script/dom/workerlocation.rs index 8d988fafea8..483cb69c084 100644 --- a/components/script/dom/workerlocation.rs +++ b/components/script/dom/workerlocation.rs @@ -10,7 +10,7 @@ use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::urlhelper::UrlHelper; use crate::dom::workerglobalscope::WorkerGlobalScope; use dom_struct::dom_struct; -use servo_url::ServoUrl; +use servo_url::{ImmutableOrigin, ServoUrl}; // https://html.spec.whatwg.org/multipage/#worker-locations #[dom_struct] @@ -34,6 +34,12 @@ impl WorkerLocation { WorkerLocationBinding::Wrap, ) } + + // https://html.spec.whatwg.org/multipage/#dom-workerlocation-origin + #[allow(dead_code)] + pub fn origin(&self) -> ImmutableOrigin { + self.url.origin() + } } impl WorkerLocationMethods for WorkerLocation { @@ -57,6 +63,11 @@ impl WorkerLocationMethods for WorkerLocation { UrlHelper::Href(&self.url) } + // https://html.spec.whatwg.org/multipage/#dom-workerlocation-origin + fn Origin(&self) -> USVString { + UrlHelper::Origin(&self.url) + } + // https://html.spec.whatwg.org/multipage/#dom-workerlocation-pathname fn Pathname(&self) -> USVString { UrlHelper::Pathname(&self.url) |