Skip to content

Commit

Permalink
Location object sans browsing context
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=191060

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

* web-platform-tests/html/browsers/history/the-location-interface/no-browsing-context.window-expected.txt:
Rebase WPT test now that all checks are passing.

* web-platform-tests/html/browsers/history/the-location-interface/no-browsing-context.window.js:
Fix bug in WPT test (web-platform-tests/wpt#13854)

* web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url.window-expected.txt:

Source/WebCore:

As per whatwg/html#4076, a Location object's URL should be "about:blank" when
it does not have a browsing context (Frame), not "".

No new tests, rebaselined existing tests.

* page/Location.cpp:
(WebCore::Location::url const):
(WebCore::Location::href const):
(WebCore::Location::protocol const):
(WebCore::Location::host const):
(WebCore::Location::hostname const):
(WebCore::Location::port const):
(WebCore::Location::pathname const):
(WebCore::Location::search const):
(WebCore::Location::origin const):
(WebCore::Location::hash const):

LayoutTests:

Update existing tests to reflect behavior change.

* http/tests/dom/same-origin-detached-window-properties-expected.txt:
* http/tests/dom/same-origin-detached-window-properties.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window2-pson.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window2.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window3.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@237702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez@apple.com committed Nov 1, 2018
1 parent e0fcbf5 commit 4d9bf00
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 76 deletions.
16 changes: 16 additions & 0 deletions LayoutTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2018-11-01 Chris Dumez <cdumez@apple.com>

Location object sans browsing context
https://bugs.webkit.org/show_bug.cgi?id=191060

Reviewed by Geoffrey Garen.

Update existing tests to reflect behavior change.

* http/tests/dom/same-origin-detached-window-properties-expected.txt:
* http/tests/dom/same-origin-detached-window-properties.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window2-pson.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window2.html:
* http/tests/security/xss-DENIED-script-inject-into-inactive-window3.html:

2018-11-01 Ross Kirsling <ross.kirsling@sony.com>

[WinCairo] Unreviewed layout test gardening.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE

* Before GC
PASS !!w.location is true
PASS w.location.href is ""
PASS w.location.protocol is ""
PASS w.location.href is "about:blank"
PASS w.location.protocol is "about:"
PASS w.location.host is ""
PASS w.location.hostname is ""
PASS w.location.port is ""
PASS w.location.pathname is ""
PASS w.location.pathname is "blank"
PASS w.location.search is ""
PASS w.location.hash is ""
PASS w.location.origin is ""
PASS w.location.origin is "null"
PASS w.location.assign('') did not throw exception.
PASS w.location.replace('') did not throw exception.
PASS w.location.reload('') did not throw exception.
Expand Down Expand Up @@ -80,15 +80,15 @@ PASS w.location.foo is undefined.

* After GC
PASS !!w.location is true
PASS w.location.href is ""
PASS w.location.protocol is ""
PASS w.location.href is "about:blank"
PASS w.location.protocol is "about:"
PASS w.location.host is ""
PASS w.location.hostname is ""
PASS w.location.port is ""
PASS w.location.pathname is ""
PASS w.location.pathname is "blank"
PASS w.location.search is ""
PASS w.location.hash is ""
PASS w.location.origin is ""
PASS w.location.origin is "null"
PASS w.location.assign('') did not throw exception.
PASS w.location.replace('') did not throw exception.
PASS w.location.reload('') did not throw exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
try {
shouldBeTrue("!!w.location");
if (w.location) {
shouldBeEqualToString("w.location.href", "");
shouldBeEqualToString("w.location.protocol", "");
shouldBeEqualToString("w.location.href", "about:blank");
shouldBeEqualToString("w.location.protocol", "about:");
shouldBeEqualToString("w.location.host", "");
shouldBeEqualToString("w.location.hostname", "");
shouldBeEqualToString("w.location.port", "");
shouldBeEqualToString("w.location.pathname", "");
shouldBeEqualToString("w.location.pathname", "blank");
shouldBeEqualToString("w.location.search", "");
shouldBeEqualToString("w.location.hash", "");
shouldBeEqualToString("w.location.origin", "");
shouldBeEqualToString("w.location.origin", "null");
shouldNotThrow("w.location.assign('')");
shouldNotThrow("w.location.replace('')");
shouldNotThrow("w.location.reload('')");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

function checkDidLoadVictim()
{
if (_openedWindowDocument.location.href == "") {
if (_openedWindowDocument.location.href == "about:blank") {
// Victim loaded; |_openedWindowDocument| is an inactive document.
window.clearInterval(intervalId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

function checkDidLoadVictim()
{
if (openerDocument.location.href == "") {
if (openerDocument.location.href == "about:blank") {
// Victim loaded.
window.clearInterval(intervalId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

function checkDidLoadVictim()
{
if (openerDocument.location.href == "") {
if (openerDocument.location.href == "about:blank") {
// Victim loaded.
window.clearInterval(intervalId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

function checkDidLoadVictim()
{
if (secondOpenerDocument.location.href == "") {
if (secondOpenerDocument.location.href == "about:blank") {
// Victim loaded.
window.clearInterval(intervalId);

Expand Down
15 changes: 15 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2018-11-01 Chris Dumez <cdumez@apple.com>

Location object sans browsing context
https://bugs.webkit.org/show_bug.cgi?id=191060

Reviewed by Geoffrey Garen.

* web-platform-tests/html/browsers/history/the-location-interface/no-browsing-context.window-expected.txt:
Rebase WPT test now that all checks are passing.

* web-platform-tests/html/browsers/history/the-location-interface/no-browsing-context.window.js:
Fix bug in WPT test (https://github.com/web-platform-tests/wpt/pull/13854)

* web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url.window-expected.txt:

2018-11-01 Justin Michaud <justin_michaud@apple.com>

CSS Custom Properties API Should Support syntax="*" and "<length>", and handle cycles properly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

PASS Window and Location are 1:1 after browsing context removal
FAIL Setting `href` to `https://example.com/` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Setting `href` to `/` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Setting `href` to `http://test:test/` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Setting `href` to `test test` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Setting `href` to `test:test` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Setting `href` to `chrome:fail` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Setting `protocol` to `http` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:" but got ""
FAIL Setting `protocol` to `about` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:" but got ""
FAIL Setting `protocol` to `test` of a `Location` object sans browsing context is a no-op assert_equals: expected "about:" but got ""
PASS Setting `href` to `https://example.com/` of a `Location` object sans browsing context is a no-op
PASS Setting `href` to `/` of a `Location` object sans browsing context is a no-op
PASS Setting `href` to `http://test:test/` of a `Location` object sans browsing context is a no-op
PASS Setting `href` to `test test` of a `Location` object sans browsing context is a no-op
PASS Setting `href` to `test:test` of a `Location` object sans browsing context is a no-op
PASS Setting `href` to `chrome:fail` of a `Location` object sans browsing context is a no-op
PASS Setting `protocol` to `http` of a `Location` object sans browsing context is a no-op
PASS Setting `protocol` to `about` of a `Location` object sans browsing context is a no-op
PASS Setting `protocol` to `test` of a `Location` object sans browsing context is a no-op
PASS Setting `host` to `example.com` of a `Location` object sans browsing context is a no-op
PASS Setting `host` to `test test` of a `Location` object sans browsing context is a no-op
PASS Setting `host` to `()` of a `Location` object sans browsing context is a no-op
Expand All @@ -22,27 +22,27 @@ PASS Setting `pathname` to `x` of a `Location` object sans browsing context is a
PASS Setting `search` to `test` of a `Location` object sans browsing context is a no-op
PASS Setting `hash` to `test` of a `Location` object sans browsing context is a no-op
PASS Setting `hash` to `#` of a `Location` object sans browsing context is a no-op
FAIL Getting `origin` of a `Location` object sans browsing context should be "null" assert_equals: expected "null" but got ""
FAIL Invoking `assign` with `about:blank` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `assign` with `https://example.com/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `assign` with `/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `assign` with `http://test:test/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `assign` with `test test` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `assign` with `test:test` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `assign` with `chrome:fail` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `replace` with `about:blank` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `replace` with `https://example.com/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `replace` with `/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `replace` with `http://test:test/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `replace` with `test test` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `replace` with `test:test` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `replace` with `chrome:fail` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `reload` with `about:blank` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `reload` with `https://example.com/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `reload` with `/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `reload` with `http://test:test/` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `reload` with `test test` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `reload` with `test:test` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
FAIL Invoking `reload` with `chrome:fail` on a `Location` object sans browsing context is a no-op assert_equals: expected "about:blank" but got ""
PASS Getting `origin` of a `Location` object sans browsing context should be "null"
PASS Invoking `assign` with `about:blank` on a `Location` object sans browsing context is a no-op
PASS Invoking `assign` with `https://example.com/` on a `Location` object sans browsing context is a no-op
PASS Invoking `assign` with `/` on a `Location` object sans browsing context is a no-op
PASS Invoking `assign` with `http://test:test/` on a `Location` object sans browsing context is a no-op
PASS Invoking `assign` with `test test` on a `Location` object sans browsing context is a no-op
PASS Invoking `assign` with `test:test` on a `Location` object sans browsing context is a no-op
PASS Invoking `assign` with `chrome:fail` on a `Location` object sans browsing context is a no-op
PASS Invoking `replace` with `about:blank` on a `Location` object sans browsing context is a no-op
PASS Invoking `replace` with `https://example.com/` on a `Location` object sans browsing context is a no-op
PASS Invoking `replace` with `/` on a `Location` object sans browsing context is a no-op
PASS Invoking `replace` with `http://test:test/` on a `Location` object sans browsing context is a no-op
PASS Invoking `replace` with `test test` on a `Location` object sans browsing context is a no-op
PASS Invoking `replace` with `test:test` on a `Location` object sans browsing context is a no-op
PASS Invoking `replace` with `chrome:fail` on a `Location` object sans browsing context is a no-op
PASS Invoking `reload` with `about:blank` on a `Location` object sans browsing context is a no-op
PASS Invoking `reload` with `https://example.com/` on a `Location` object sans browsing context is a no-op
PASS Invoking `reload` with `/` on a `Location` object sans browsing context is a no-op
PASS Invoking `reload` with `http://test:test/` on a `Location` object sans browsing context is a no-op
PASS Invoking `reload` with `test test` on a `Location` object sans browsing context is a no-op
PASS Invoking `reload` with `test:test` on a `Location` object sans browsing context is a no-op
PASS Invoking `reload` with `chrome:fail` on a `Location` object sans browsing context is a no-op
PASS Getting `ancestorOrigins` of a `Location` object sans browsing context should be []

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function bcLessLocation() {
},
{
"property": "pathname",
"expected": "",
"expected": "blank",
"values": ["/", "x"]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

PASS document.open() changes document's URL (fully active document)
FAIL document.open() does not change document's URL (active but not fully active document) assert_equals: expected "http://localhost:8800/common/blank.html" but got ""
FAIL document.open() does not change document's URL (active but not fully active document) assert_equals: expected "http://localhost:8800/common/blank.html" but got "about:blank"
PASS document.open() does not change document's URL (non-active document with an associated Window object; frame is removed)
PASS document.open() does not change document's URL (non-active document with an associated Window object; navigated away)
PASS document.open() does not change document's URL (non-active document without an associated Window object)
Expand Down
24 changes: 24 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
2018-11-01 Chris Dumez <cdumez@apple.com>

Location object sans browsing context
https://bugs.webkit.org/show_bug.cgi?id=191060

Reviewed by Geoffrey Garen.

As per https://github.com/whatwg/html/pull/4076, a Location object's URL should be "about:blank" when
it does not have a browsing context (Frame), not "".

No new tests, rebaselined existing tests.

* page/Location.cpp:
(WebCore::Location::url const):
(WebCore::Location::href const):
(WebCore::Location::protocol const):
(WebCore::Location::host const):
(WebCore::Location::hostname const):
(WebCore::Location::port const):
(WebCore::Location::pathname const):
(WebCore::Location::search const):
(WebCore::Location::origin const):
(WebCore::Location::hash const):

2018-11-01 Sihui Liu <sihui_liu@apple.com>

Add a storage limit for IndexedDB
Expand Down
29 changes: 2 additions & 27 deletions Source/WebCore/page/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Location::Location(DOMWindow& window)

inline const URL& Location::url() const
{
ASSERT(frame());
if (!frame())
return blankURL();

const URL& url = frame()->document()->url();
if (!url.isValid())
Expand All @@ -57,9 +58,6 @@ inline const URL& Location::url() const

String Location::href() const
{
if (!frame())
return String();

auto& url = this->url();

if (!url.hasUsername() && !url.hasPassword())
Expand All @@ -73,61 +71,41 @@ String Location::href() const

String Location::protocol() const
{
if (!frame())
return String();

return makeString(url().protocol(), ":");
}

String Location::host() const
{
if (!frame())
return String();

// Note: this is the IE spec. The NS spec swaps the two, it says
// "The hostname property is the concatenation of the host and port properties, separated by a colon."
return url().hostAndPort();
}

String Location::hostname() const
{
if (!frame())
return String();

return url().host().toString();
}

String Location::port() const
{
if (!frame())
return String();

const URL& url = this->url();
return url.port() ? String::number(url.port().value()) : emptyString();
}

String Location::pathname() const
{
if (!frame())
return String();

const URL& url = this->url();
return url.path().isEmpty() ? "/" : url.path();
}

String Location::search() const
{
if (!frame())
return String();

const URL& url = this->url();
return url.query().isEmpty() ? emptyString() : "?" + url.query();
}

String Location::origin() const
{
if (!frame())
return String();
return SecurityOrigin::create(url())->toString();
}

Expand All @@ -144,9 +122,6 @@ Ref<DOMStringList> Location::ancestorOrigins() const

String Location::hash() const
{
if (!frame())
return String();

const String& fragmentIdentifier = url().fragmentIdentifier();
return fragmentIdentifier.isEmpty() ? emptyString() : "#" + fragmentIdentifier;
}
Expand Down

0 comments on commit 4d9bf00

Please sign in to comment.