Skip to content

Commit

Permalink
Make the Location object deal when it does not have a browsing context
Browse files Browse the repository at this point in the history
Previously, the various pieces of spec text here assumed that a browsing
context always existed.

Tests: web-platform-tests/wpt#13435.

Fixes whatwg#3959.
  • Loading branch information
annevk authored and mustaqahmed committed Feb 15, 2019
1 parent c95d503 commit c82448e
Showing 1 changed file with 78 additions and 41 deletions.
119 changes: 78 additions & 41 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -81078,12 +81078,14 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
<div w-nodev>

<p>A <code>Location</code> object has an associated <dfn>relevant <code>Document</code></dfn>,
which is this <code>Location</code> object's associated <code>Document</code> object's <span
data-x="concept-document-bc">browsing context</span>'s <span>active document</span>.</p>
which is this <code>Location</code> object's <span>relevant global object</span>'s <span>browsing
context</span>'s <span>active document</span>, if this <code>Location</code> object's
<span>relevant global object</span> has a <span>browsing context</span>, and null otherwise.</p>

<p>A <code>Location</code> object has an associated <dfn data-x="concept-location-url">url</dfn>,
which is this <code>Location</code> object's <span>relevant <code>Document</code></span>'s <span
data-x="concept-document-url">URL</span>.</p>
data-x="concept-document-url">URL</span>, if this <code>Location</code> object's <span>relevant
<code>Document</code></span> is non-null, and <code>about:blank</code> otherwise.</p>

<p>A <code>Location</code> object has an associated <dfn
data-x="concept-location-ancestor-origins-list">ancestor origins list</dfn>. When a
Expand Down Expand Up @@ -81166,10 +81168,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Return this <code>Location</code> object's <span data-x="concept-location-url">url</span>,
<span data-x="concept-url-serializer">serialized</span>.</p></li>
Expand All @@ -81178,6 +81180,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
<p>The <code data-x="dom-location-href">href</code> attribute's setter must run these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p><span data-x="parse a url">Parse</span> the given value relative to the <span>entry
settings object</span>. If that failed, throw a <code>TypeError</code> exception.</p></li>

Expand All @@ -81192,10 +81197,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Return the <span data-x="serialization of an origin">serialization</span> of this
<code>Location</code> object's <span data-x="concept-location-url">url</span>'s <span
Expand All @@ -81206,10 +81211,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Return this <code>Location</code> object's <span
data-x="concept-location-url">url</span>'s <span data-x="concept-url-scheme">scheme</span>,
Expand All @@ -81220,6 +81225,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand Down Expand Up @@ -81251,10 +81259,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Let <var>url</var> be this <code>Location</code> object's <span
data-x="concept-location-url">url</span>.</p></li>
Expand All @@ -81275,6 +81283,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
<p>The <code data-x="dom-location-host">host</code> attribute's setter must run these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand All @@ -81297,10 +81308,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
run these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If this <code>Location</code> object's <span data-x="concept-location-url">url</span>'s
<span data-x="concept-url-host">host</span> is null, return the empty string.</p></li>
Expand All @@ -81314,6 +81325,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand All @@ -81336,10 +81350,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If this <code>Location</code> object's <span data-x="concept-location-url">url</span>'s
<span data-x="concept-url-port">port</span> is null, return the empty string.</p></li>
Expand All @@ -81352,6 +81366,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
<p>The <code data-x="dom-location-port">port</code> attribute's setter must run these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand All @@ -81377,10 +81394,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
run these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Let <var>url</var> be this <code>Location</code> object's <span
data-x="concept-location-url">url</span>.</p></li>
Expand All @@ -81400,6 +81417,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand All @@ -81425,10 +81445,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If this <code>Location</code> object's <span data-x="concept-location-url">url</span>'s
<span data-x="concept-url-query">query</span> is either null or the empty string, return the
Expand All @@ -81443,6 +81463,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand Down Expand Up @@ -81478,10 +81501,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
non-null and its <span>origin</span> is not <span>same origin-domain</span> with the <span>entry
settings object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If this <code>Location</code> object's <span data-x="concept-location-url">url</span>'s
<span data-x="concept-url-fragment">fragment</span> is either null or the empty string, return
Expand All @@ -81495,6 +81518,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
<p>The <code data-x="dom-location-hash">hash</code> attribute's setter must run these steps:</p>

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand Down Expand Up @@ -81526,6 +81552,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
method is invoked, the user agent must run the following steps:

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand All @@ -81537,21 +81566,21 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface

<li><p><span><code>Location</code>-object navigate</span> to the <span>resulting URL
record</span>.</p></li>

</ol>

<p>When the <dfn><code data-x="dom-location-replace">replace(<var>url</var>)</code></dfn>
method is invoked, the user agent must run the following steps:

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return.</p></li>

<li><p><span data-x="parse a url">Parse</span> <var>url</var> relative to the <span>entry
settings object</span>. If that failed, throw a <span>"<code>SyntaxError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p><span><code>Location</code>-object navigate</span> to the <span>resulting URL
record</span> with the <var>replacement flag</var> set.</p></li>

</ol>

<p class="note">The <code data-x="dom-location-replace">replace()</code> method intentionally has
Expand All @@ -81561,6 +81590,11 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
user agent must run the appropriate steps from the following list:</p>

<dl class="switch">
<dt>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null</dt>

<dd><p>Return.</p></dd>

<dt>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span></dt>
Expand Down Expand Up @@ -81616,6 +81650,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
getter must run these steps:

<ol>
<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span> is
null, then return an empty <span>list</span>.</p></li>

<li><p>If this <code>Location</code> object's <span>relevant <code>Document</code></span>'s
<span>origin</span> is not <span>same origin-domain</span> with the <span>entry settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>, then throw a
Expand Down

0 comments on commit c82448e

Please sign in to comment.