Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the document.domain attribute setter as a standalone algorithm #2365

Merged
merged 12 commits into from
Feb 22, 2017
98 changes: 55 additions & 43 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -79178,7 +79178,7 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<ol>
<li><p>If <var>origin</var> is an <span data-x="concept-origin-opaque">opaque origin</span>, then
return <var>origin</var>.</p></li>
return null.</p></li>

<li><p>If <var>origin</var>'s <span data-x="concept-origin-domain">domain</span> is non-null,
then return <var>origin</var>'s <span data-x="concept-origin-domain">domain</span>.</p></li>
Expand Down Expand Up @@ -79484,6 +79484,49 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<div w-nodev>

<p>To determine if a string <var>hostSuffixString</var> <dfn data-export="" data-lt="is a
registrable domain suffix of or is equal to|is not a registrable domain suffix of and is not equal
to">is a registrable domain suffix of or is equal to</dfn> a <span
data-x="concept-host">host</span> <var>originalHost</var>, run these steps:</p>
<!-- Web platform usage: document.domain, Cookies, Web Authentication -->

<ol>
<li><p>If <var>hostSuffixString</var> is the empty string, then return false.</p></li>

<li><p>Let <var>host</var> be the result of <span data-x="host parser">parsing</span>
<var>hostSuffixString</var>.</p></li>

<li><p>If <var>host</var> is failure, then return false.</p></li>

<li>
<p>If <var>host</var> is <em>not</em> <span data-x="host equals">equal</span> to
<var>originalHost</var>, then run these substeps:</p>

<ol>
<li>
<p>If <var>host</var> or <var>originalHost</var> is not a <span
data-x="concept-domain">domain</span>, then return false.</p>

<p class="note">This is meant to exclude <span data-x="concept-host">hosts</span> that are an
<span>IPv4 address</span> or an <span>IPv6 address</span>.</p>
</li>

<li><p>If <var>host</var>, prefixed by a U+002E FULL STOP (.), does not exactly match the end
of <var>originalHost</var>, then return false.</p></li>

<li>
<p>If <var>host</var> matches a suffix in the Public Suffix List, or, if <var>host</var>,
prefixed by a U+002E FULL STOP (.), matches the end of a suffix in the Public Suffix List,
then return false. <ref spec=PSL></p>

<p>Suffixes must be compared after applying the <span>host parser</span> algorithm.</p>
</li>
</ol>
</li>

<li><p>Return true.</p></li>
</ol>

<p>The <dfn><code data-x="dom-document-domain">domain</code></dfn> attribute's getter must run
these steps:</p>

Expand All @@ -79494,8 +79537,7 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<li><p>Let <var>effectiveDomain</var> be this <code>Document</code>'s <span>origin</span>'s <span
data-x="concept-origin-effective-domain">effective domain</span>.

<li><p>If <var>effectiveDomain</var> is an <span data-x="concept-origin-opaque">opaque
origin</span>, then return the empty string.</p></li>
<li><p>If <var>effectiveDomain</var> is null, then return the empty string.</p></li>

<li><p>Return <var>effectiveDomain</var>, <span data-x="host
serializer">serialized</span>.</p></li>
Expand All @@ -79514,50 +79556,19 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
flag</span> set, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>If the given value is the empty string, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Let <var>host</var> be the result of <span data-x="host parser">parsing</span> the given
value.</p></li>

<li><p>If <var>host</var> is failure, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>Let <var>effectiveDomain</var> be this <code>Document</code> object's
<span>origin</span>'s <span data-x="concept-origin-effective-domain">effective
domain</span>.</p></li>

<li>
<p>If <var>host</var> is <em>not</em> <span data-x="host equals">equal</span> to
<var>effectiveDomain</var>, then run these substeps:</p>

<ol>
<li>
<p>If <var>host</var> or <var>effectiveDomain</var> is not a <span
data-x="concept-domain">domain</span>, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p>

<p class="note">This is meant to exclude <span data-x="concept-host">hosts</span> that are an
<span>IPv4 address</span> or an <span>IPv6 address</span>.</p>
</li>

<li><p>If <var>host</var>, prefixed by a U+002E FULL STOP (.), does not exactly match the end
of <var>effectiveDomain</var>, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p></li>
<li><p>Let <var>effectiveDomain</var> be this <code>Document</code>'s <span>origin</span>'s <span
data-x="concept-origin-effective-domain">effective domain</span>.

<li>
<p>If <var>host</var> matches a suffix in the Public Suffix List, or, if <var>host</var>,
prefixed by a U+002E FULL STOP (.), matches the end of a suffix in the Public Suffix List,
then throw a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>. <ref
spec=PSL></p>
<li><p>If <var>effectiveDomain</var> is null, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<p>Suffixes must be compared after applying the <span>host parser</span> algorithm.</p>
</li>
</ol>
</li>
<li><p>If the given value <span data-x="is a registrable domain suffix of or is equal to">is not
a registrable domain suffix of and is not equal to</span> <var>effectiveDomain</var>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Set this <code>Document</code> object's <span>origin</span>'s <span
data-x="concept-origin-domain">domain</span> to <var>host</var>.</p></li>
data-x="concept-origin-domain">domain</span> to the result of <span data-x="host
parser">parsing</span> the given value.</p></li>
</ol>

</div>
Expand Down Expand Up @@ -119631,6 +119642,7 @@ INSERT INTERFACES HERE
Ivan Enderlin,
Ivo Emanuel Gon&ccedil;alves,
J. King,
J.C. Jones,
Jackson Ray Hamilton,
Jacob Davies,
Jacques Distler,
Expand Down