You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix#365: Do not allow operations after close() is called but before the session is actually closed (#421)
Introduce a new "closing or closed" value and use it when determining whether to
abort MediaKeySession algorithms.
Make media-key-session-closed depend on an explicit state.
Previously, this definition depended on whether an algorithm had been
run, which is slightly ambiguous.
<li><p>Let the <var>session type</var> value be <var>sessionType</var>.</p></li>
1470
1470
<li><p>Let the <var>uninitialized</var> value be true.</p></li>
1471
1471
<li><p>Let the <var>callable</var> value be false.</p></li>
1472
+
<li><p>Let the <var>closing or closed</var> value be false.</p></li>
1472
1473
<li><p>Let the <var>use distinctive identifier</var> value be this object's <var>use distinctive identifier</var> value.</p></li>
1473
1474
<li><p>Let the <var>cdm implementation</var> value be this object's <var>cdm implementation</var>.</p></li>
1474
1475
<li><p>Let the <var>cdm instance</var> value be this object's <var>cdm instance</var>.</p></li>
@@ -1578,8 +1579,7 @@ <h3>Storage and Persistence</h3>
1578
1579
<h2><a>MediaKeySession</a> Interface</h2>
1579
1580
<p>The MediaKeySession object represents a <ahref="#key-session">key session</a>.</p>
1580
1581
<p>
1581
-
A <a>MediaKeySession</a> object is <dfnid="media-key-session-closed">closed</dfn> if and only if the <adef-id="session-closed-algorithm"></a> algorithm has
1582
-
been run.
1582
+
A <a>MediaKeySession</a> object is <dfnid="media-key-session-closed">closed</dfn> if and only if the object's <adef-id="closed"></a> attribute has been resolved.
1583
1583
</p>
1584
1584
<p>
1585
1585
The User Agent SHALL execute the <adef-id="monitor-cdm-algorithm"></a> algorithm continuously for each <a>MediaKeySession</a> object
<li><p>If this object is <adef-id="media-key-session-closed"></a>, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1661
+
<li><p><li><p>If this object's <var>closing or closed</var> value is true, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1662
1662
<li><p>If this object's <var>uninitialized</var> value is false, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1663
1663
<li><p>Let this object's <var>uninitialized</var> value be false.</p></li><!-- For simplicity and consistency, this object cannot be reused after any failure. -->
1664
1664
<li><p>If <var>initDataType</var> is the empty string, return a promise rejected with a newly created <adef-id="TypeError"></a>.</p></li>
<li><p>If any of the preceding steps failed, reject <var>promise</var> with <adef-id="new-domexception-named"></a><adef-id="appropriate-error-name"></a>.</p></li>
1757
1757
<li><p>Set the <adef-id="sessionId"></a> attribute to <var>session id</var>.</p></li>
1758
-
<li><p>Let this object's <var>callable</var> value be true.</p></li>
1758
+
<li><p>Set this object's <var>callable</var> value to true.</p></li>
1759
1759
<li><p>Run the <adef-id="queue-message-algorithm"></a> algorithm on the <var>session</var>, providing <var>message type</var> and <var>message</var>.</p>
<li><p>If this object is <adef-id="media-key-session-closed"></a>, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1780
+
<li><p><li><p>If this object's <var>closing or closed</var> value is true, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1781
1781
<li><p>If this object's <var>uninitialized</var> value is false, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1782
1782
<li><p>Let this object's <var>uninitialized</var> value be false.</p></li><!-- For simplicity and consistency, this object cannot be reused after any failure. -->
1783
1783
<li><p>If <var>sessionId</var> is the empty string, return a promise rejected with a newly created <adef-id="TypeError"></a>.</p></li>
<li><p>If any of the preceding steps failed, reject <var>promise</var> with a <adef-id="appropriate-error-name"></a>.</p></li>
1826
1826
<li><p>Set the <adef-id="sessionId"></a> attribute to <var>sanitized session ID</var>.</p></li>
1827
-
<li><p>Let this object's <var>callable</var> value be true.</p></li>
1827
+
<li><p>Set this object's <var>callable</var> value to true.</p></li>
1828
1828
<li>
1829
1829
<p>
1830
1830
If the loaded session contains information about any keys (there are <ahref="#known-key">known keys</a>), run the <adef-id="update-key-statuses-algorithm"></a> algorithm on the <var>session</var>, providing each key's <adef-id="key-id"></a> along with the appropriate <a>MediaKeyStatus</a>.
<li><p>If this object is <adef-id="media-key-session-closed"></a>, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1857
+
<li><p><li><p>If this object's <var>closing or closed</var> value is true, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1858
1858
<li><p>If this object's <var>callable</var> value is false, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1859
1859
<li><p>If <var>response</var> is an empty array, return a promise rejected with a newly created <adef-id="TypeError"></a>.</p></li>
1860
1860
<li><p>Let <var>response copy</var> be a copy of the contents of the <var>response</var> parameter.</p></li>
<pclass="note">The returned promise is resolved when the request has been processed, and the <adef-id="closed"></a> attribute promise is resolved when the session is closed.</p>
1985
1985
1986
1986
<olclass="method-algorithm">
1987
-
<li><p>If this object is <adef-id="media-key-session-closed"></a>, return a resolved promise.</p></li>
1987
+
<li><p><li><p>If this object's <var>closing or closed</var> value is true, return a resolved promise.</p></li>
1988
1988
<li><p>If this object's <var>callable</var> value is false, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
1989
1989
<li><p>Let <var>promise</var> be a new promise.</p></li>
1990
+
<li><p>Set this object's <var>closing or closed</var> value to true.</p></li>
1990
1991
<li><p>Run the following steps in parallel:</p>
1991
1992
<ol>
1992
1993
<li><p>Let <var>cdm</var> be the CDM instance represented by this object's <var>cdm instance</var> value.</p></li>
<li><p>If this object is <adef-id="media-key-session-closed"></a>, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
2019
+
<li><p><li><p>If this object's <var>closing or closed</var> value is true, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
2019
2020
<li><p>If this object's <var>callable</var> value is false, return a promise rejected with an <adef-id="InvalidStateError"></a>.</p></li>
2020
2021
<li><p>Let <var>promise</var> be a new promise.</p></li>
2021
2022
<li><p>Run the following steps in parallel:</p>
@@ -2354,9 +2355,13 @@ <h4>Session Closed</h4>
2354
2355
<p>The following steps are run:</p>
2355
2356
<ol>
2356
2357
<li><p>Let <var>session</var> be the associated <a>MediaKeySession</a> object.</p></li>
2358
+
<li><p>Let <var>promise</var> be the <var>session</var>'s <adef-id="closed"></a> attribute.</p></li>
2359
+
<!-- Avoid a race condition that could cause the algorithms below to be run multiple times. -->
2360
+
<li><p>If <var>promise</var> is resolved, abort these steps.</p></li>
2361
+
<!-- Handle the case that this algorithm is reached by a path other than close(). In all cases, the value is set before the algorithms below are run. -->
2362
+
<li><p>Set the <var>session</var>'s <var>closing or closed</var> value to true.</p></li>
2357
2363
<li><p>Run the <adef-id="update-key-statuses-algorithm"></a> algorithm on the <var>session</var>, providing an empty sequence.</p></li>
2358
2364
<li><p>Run the <adef-id="update-expiration-algorithm"></a> algorithm on the <var>session</var>, providing <code>NaN</code>.</p></li>
2359
-
<li><p>Let <var>promise</var> be the <adef-id="closed"></a> attribute of the <var>session</var>.</p></li>
0 commit comments