Implement worker origin member of WorkerLocation

This commit is contained in:
csmoe 2019-05-07 16:11:45 +08:00
parent 9d9fff3b0a
commit 05bef140bf
57 changed files with 157 additions and 445 deletions

View file

@ -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;

View file

@ -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)