From 77f3b25e65d1c98271332d9606fd10d21a1bba63 Mon Sep 17 00:00:00 2001 From: yodalee Date: Fri, 27 Mar 2015 22:42:56 +0800 Subject: [PATCH 1/2] add readonly pathname function in location pathname function implemented in UrlHelper 'url is null' check is skip for now --- components/script/dom/location.rs | 4 ++++ components/script/dom/urlhelper.rs | 11 ++++++++++- components/script/dom/webidls/URLUtils.webidl | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index 4f02a7952b7..6c4ba3d8c7a 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -46,6 +46,10 @@ impl<'a> LocationMethods for JSRef<'a, Location> { UrlHelper::Href(&self.get_url()) } + fn Pathname(self) -> USVString { + UrlHelper::Pathname(&self.get_url()) + } + fn Stringify(self) -> DOMString { self.Href().0 } diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index c83e65c98b2..3b53746bd85 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -4,7 +4,7 @@ use dom::bindings::str::USVString; -use url::Url; +use url::{Url, SchemeData}; use std::borrow::ToOwned; @@ -31,6 +31,15 @@ impl UrlHelper { }) } + pub fn Pathname(url: &Url) -> USVString { + // https://url.spec.whatwg.org/#dom-urlutils-pathname + // FIXME: Url null check is skipped for now + USVString(match url.scheme_data { + SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(), + SchemeData::Relative(..) => url.serialize_path().unwrap() + }) + } + /// https://html.spec.whatwg.org/multipage/browsers.html#same-origin pub fn SameOrigin(urlA: &Url, urlB: &Url) -> bool { if urlA.host() != urlB.host() { diff --git a/components/script/dom/webidls/URLUtils.webidl b/components/script/dom/webidls/URLUtils.webidl index bdeca5aeabf..29d060c344c 100644 --- a/components/script/dom/webidls/URLUtils.webidl +++ b/components/script/dom/webidls/URLUtils.webidl @@ -16,6 +16,7 @@ interface URLUtils { // attribute USVString hostname; // attribute USVString port; // attribute USVString pathname; + readonly attribute USVString pathname; // attribute USVString search; readonly attribute USVString search; // attribute URLSearchParams searchParams; From 4ffaaf2785544860623ad108ce48367a732f820d Mon Sep 17 00:00:00 2001 From: yodalee Date: Thu, 2 Apr 2015 22:45:40 +0800 Subject: [PATCH 2/2] modify tests metadata pass in XMLHttpRequest fail in members.html --- .../getresponseheader-error-state.htm.ini | 5 ----- .../send-redirect-to-non-cors.htm.ini | 14 -------------- .../XMLHttpRequest/timeout-cors-async.htm.ini | 4 ++-- .../frameElement.sub.html.ini | 2 +- .../WorkerGlobalScope/location/members.html.ini | 4 ++++ 5 files changed, 7 insertions(+), 22 deletions(-) delete mode 100644 tests/wpt/metadata/XMLHttpRequest/getresponseheader-error-state.htm.ini delete mode 100644 tests/wpt/metadata/XMLHttpRequest/send-redirect-to-non-cors.htm.ini create mode 100644 tests/wpt/metadata/workers/interfaces/WorkerGlobalScope/location/members.html.ini diff --git a/tests/wpt/metadata/XMLHttpRequest/getresponseheader-error-state.htm.ini b/tests/wpt/metadata/XMLHttpRequest/getresponseheader-error-state.htm.ini deleted file mode 100644 index c3685696a0c..00000000000 --- a/tests/wpt/metadata/XMLHttpRequest/getresponseheader-error-state.htm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[getresponseheader-error-state.htm] - type: testharness - [XMLHttpRequest: getResponseHeader() in error state (failing cross-origin test)] - expected: FAIL - diff --git a/tests/wpt/metadata/XMLHttpRequest/send-redirect-to-non-cors.htm.ini b/tests/wpt/metadata/XMLHttpRequest/send-redirect-to-non-cors.htm.ini deleted file mode 100644 index eabe809eb86..00000000000 --- a/tests/wpt/metadata/XMLHttpRequest/send-redirect-to-non-cors.htm.ini +++ /dev/null @@ -1,14 +0,0 @@ -[send-redirect-to-non-cors.htm] - type: testharness - [XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (301)] - expected: FAIL - - [XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (302)] - expected: FAIL - - [XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (303)] - expected: FAIL - - [XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (307)] - expected: FAIL - diff --git a/tests/wpt/metadata/XMLHttpRequest/timeout-cors-async.htm.ini b/tests/wpt/metadata/XMLHttpRequest/timeout-cors-async.htm.ini index 7c0d5b29490..4d37d487bfb 100644 --- a/tests/wpt/metadata/XMLHttpRequest/timeout-cors-async.htm.ini +++ b/tests/wpt/metadata/XMLHttpRequest/timeout-cors-async.htm.ini @@ -1,6 +1,6 @@ [timeout-cors-async.htm] type: testharness - expected: TIMEOUT + expected: OK [XMLHttpRequest: timeout event and cross-origin request] - expected: NOTRUN + expected: FAIL diff --git a/tests/wpt/metadata/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html.ini b/tests/wpt/metadata/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html.ini index 522166b1d7b..974579d1009 100644 --- a/tests/wpt/metadata/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html.ini +++ b/tests/wpt/metadata/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html.ini @@ -1,6 +1,6 @@ [frameElement.sub.html] type: testharness - expected: ERROR + expected: OK [The window\'s frameElement attribute must return its container element if it is a nested browsing context] expected: FAIL diff --git a/tests/wpt/metadata/workers/interfaces/WorkerGlobalScope/location/members.html.ini b/tests/wpt/metadata/workers/interfaces/WorkerGlobalScope/location/members.html.ini new file mode 100644 index 00000000000..71d4aa447ea --- /dev/null +++ b/tests/wpt/metadata/workers/interfaces/WorkerGlobalScope/location/members.html.ini @@ -0,0 +1,4 @@ +[members.html] + type: testharness + [members of WorkerLocation] + expected: FAIL