Skip to content

Commit

Permalink
Merge branch 'burnburn-overconstrainederror'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Burnett committed Jul 9, 2015
2 parents 931bb19 + 60280ff commit 3037221
Show file tree
Hide file tree
Showing 2 changed files with 296 additions and 58 deletions.
343 changes: 286 additions & 57 deletions getusermedia.html
Expand Up @@ -1874,45 +1874,274 @@ <h2>MediaStreams in Media Elements</h2>
<section>
<h2>Error Handling</h2>

<p>All promises in this specification, when they are rejected, are rejected
with an object that implements the <code><a>MediaStreamError</a></code>
interface.</p>
<p>This section and its subsections extend the list of Error
subclasses defined in [[!ES6]] following the pattern for NativeError
in section 19.5.6 of that specification. Assume the following:</p>

<section>
<h3>MediaStreamError</h3>
<ul>
<li>that use of syntax such as [[\something]] and %something% is
as used in [[!ES6]].</li>
<li>that the rules for ECMAScript standard built-in objects
([[!ES6]], section 17) are in effect in this section.</li>
<li>that the new intrinsic objects %OverconstrainedError% and
%OverconstrainedErrorPrototype% are available as if they had
been included in ([[!ES6]], Table 7) and all referencing sections,
e.g. ([[!ES6]], section 8.2.2), thus behave appropriately.</li>
</ul>

<p>All errors defined in this specification implement the following
interface:</p>
<section>
<h2>ECMAScript 6 Terminology</h2>

<dl class="idl" title="[Exposed=Window, NoInterfaceObject] interface MediaStreamError">
<dt>readonly attribute DOMString name</dt>
<p>The following terms used in this section are defined in [[!ES6]].</p>
<table>
<tr>
<th>Term/Notation</th>
<th>Section in [[!ES6]]</th>
<tr>
<tr>
<td>Type(X)</td>
<td>6</td>
<tr>
<td>intrinsic object</td>
<td>6.1.7.4</td>
</tr>
<tr>
<td>[[\ErrorData]]</td>
<td>19.5.1</td>
</tr>
<tr>
<td>internal slot</td>
<td>6.1.7.2</td>
</tr>
<tr>
<td>NewTarget</td>
<td>various uses, but no definition</td>
</tr>
<tr>
<td>active function object</td>
<td>8.3</td>
</tr>
<tr>
<td>OrdinaryCreateFromConstructor()</td>
<td>9.1.14</td>
</tr>
<tr>
<td>ReturnIfAbrupt()</td>
<td>6.2.2.4</td>
</tr>
<tr>
<td>Assert</td>
<td>5.2</td>
</tr>
<tr>
<td>String</td>
<td>4.3.17-19, depending on context</td>
</tr>
<tr>
<td>PropertyDescriptor</td>
<td>6.2.4</td>
</tr>
<tr>
<td>[[\Value]]</td>
<td>6.1.7.1</td>
</tr>
<tr>
<td>[[\Writable]]</td>
<td>6.1.7.1</td>
</tr>
<tr>
<td>[[\Enumerable]]</td>
<td>6.1.7.1</td>
</tr>
<tr>
<td>[[\Configurable]]</td>
<td>6.1.7.1</td>
</tr>
<tr>
<td>DefinePropertyOrThrow()</td>
<td>7.3.7</td>
</tr>
<tr>
<td>abrupt completion</td>
<td>6.2.2</td>
</tr>
<tr>
<td>ToString()</td>
<td>7.1.12</td>
</tr>
<tr>
<td>[[\Prototype]]</td>
<td>9.1</td>
</tr>
<tr>
<td>%Error%</td>
<td>19.5.1</td>
</tr>
<tr>
<td>Error</td>
<td>19.5</td>
</tr>
<tr>
<td>%ErrorPrototype%</td>
<td>19.5.3</td>
</tr>
<tr>
<td>Object.prototype.toString</td>
<td>19.1.3.6</td>
</tr>
</table>
</section>

<dd>
<p>The name of the error</p>
</dd>
<section>
<h2>OverconstrainedError Object</h2>

<dt>readonly attribute DOMString? message</dt>
<section>
<h2>OverconstrainedError Constructor</h2>

<p>The OverconstrainedError Constructor is the
%OverconstrainedError% intrinsic object. When
<code>OverconstrainedError</code> is called as a function
rather than as a constructor, it creates and initializes a new
OverconstrainedError object. A call of the object as a
function is equivalent to calling it as a constructor with the
same arguments. Thus the function call
<code><b>OverconstrainedError(</b>...<b>)</b></code> is
equivalent to the object creation expression <code><b>new
OverconstrainedError(</b>...<b>)</b></code> with the same
arguments.</p>

<p>The <code>OverconstrainedError</code> constructor is
designed to be subclassable. It may be used as the value of
an <code>extends</code> clause of a class definition. Subclass
constructors that intend to inherit the specified
<code>OverconstrainedError</code> behaviour must include
a <code>super</code> call to
the <code>OverconstrainedError</code> constructor to create
and initialize the subclass instance with an [[\ErrorData]]
internal slot.</p>

<section>
<h2>OverconstrainedError ( constraint, message )</h2>

<p>When the <code>OverconstrainedError</code> function is
called with arguments <i>constraint</i> and <i>message</i>
the following steps are taken:</p>
<ol>
<li>If NewTarget is <b>undefined</b>, let <i>newTarget</i>
be the active function object, else let <i>newTarget</i>
be NewTarget.</li>
<li>Let <i>O</i> be
OrdinaryCreateFromConstructor(<i>newTarget</i>,
<code>"%OverconstrainedErrorPrototype%"</code>, «[[\ErrorData]]»
).</li>
<li>ReturnIfAbrupt(<i>O</i>).</li>
<li>If <i>constraint</i> is not <b>undefined</b>, then</li>
<ol>
<li>Let <i>constraintDesc</i> be the
PropertyDescriptor{[[\Value]]:
<i>constraint</i>, [[\Writable]]: <b>false</b>,
[[\Enumerable]]: <b>false</b>,
[[\Configurable]]: <b>false</b>}.</li>
<li>Let <i>cStatus</i> be DefinePropertyOrThrow(O,
"<code>constraint</code>", <i>constraintDesc</i>).</li>
<li>Assert: <i>cStatus</i> is not an abrupt completion.</li>
</ol>
<li>If <i>message</i> is not <b>undefined</b>, then</li>
<ol>
<li>Let <i>msg</i> be ToString(<i>message</i>).</li>
<li>Let <i>msgDesc</i> be the PropertyDescriptor{[[\Value]]:
<i>msg</i>, [[\Writable]]: <b>true</b>,
[[\Enumerable]]: <b>false</b>, [[\Configurable]]:
<b>true</b>}.</li>
<li>Let <i>mStatus</i> be DefinePropertyOrThrow(O,
"<code>message</code>", <i>msgDesc</i>).</li>
<li>Assert: <i>mStatus</i> is not an abrupt completion.</li>
</ol>
<li>Return <i>O</i>.</li>
</ol>
</section>
</section>

<dd>
<p>A User Agent-dependent string offering extra human-readable
information about the error.</p>
</dd>
<section>
<h2>Properties of the OverconstrainedError Constructor</h2>

<p>The value of the [[\Prototype]] internal slot of the
OverconstrainedError constructor is the intrinsic object
%Error%.</p>
<p>Besides the <code>length</code> property (whose value
is <b>1</b>), the OverconstrainedError constructor has the
following properties:</p>

<section>
<h2>OverconstrainedError.prototype</h2>

<p>The initial value
of <code>OverconstrainedError.prototype</code> is the
<a href="#properties-of-the-overconstrainederror-prototype-object">OverconstrainedError
prototype object</a>. This property has the attributes {
[[\Writable]]: <b>false</b>, [[\Enumerable]]: <b>false</b>,
[[\Configurable]]: <b>false</b> }.</p>
</section>
</section>

<dt>readonly attribute DOMString? constraintName</dt>
<section>
<h2>Properties of the OverconstrainedError Prototype Object</h2>

<p>The OverconstrainedError prototype object is an ordinary
object. It is not an Error instance and does not have an
[[\ErrorData]] internal slot.</p>
<p>The value of the [[\Prototype]] internal slot of the
OverconstrainedError prototype object is the intrinsic object
%ErrorPrototype%.</p>

<section>
<h2>OverconstrainedError.prototype.constructor</h2>

<p>The initial value of the constructor property of the
prototype for the OverconstrainedError constructor is the
intrinsic
object <a href="#error-handling">%OverconstrainedError%</a>.</p>
</section>

<section>
<h2>OverconstrainedError.prototype.constraint</h2>

<p>The initial value of the constraint property of the
prototype for the OverconstrainedError constructor is the
empty String.</p>
</section>

<section>
<h2>OverconstrainedError.prototype.message</h2>

<p>The initial value of the message property of the
prototype for the OverconstrainedError constructor is the
empty String.</p>
</section>

<section>
<h2>OverconstrainedError.prototype.name</h2>

<p>The initial value of the name property of the prototype
for the OverconstrainedError constructor is
<code>"<b>OverconstrainedError</b>"</code>.</p>
</section>
</section>

<dd>
<p>This attribute is only used for some types of errors. For
<code><a>MediaStreamError</a></code> with a name of
<code>ConstraintNotSatisfiedError</code> or of
<code>OverconstrainedError</code>, this attribute MUST be set to the
name of the constraint that caused the error.</p>
</dd>
</dl>
<section>
<h2>Properties of OverconstrainedError Instances</h2>

<p>OverconstrainedError instances are ordinary objects that
inherit properties from the OverconstrainedError prototype
object and have an [[\ErrorData]] internal slot whose value is
<b>undefined</b>. The only specified use of [[\ErrorData]] is
by Object.prototype.toString ([[!ES6]], section 19.1.3.6) to
identify instances of Error or its various subclasses.</p>
</section>

<div class="note">
We use MediaStreamError rather than deriving from Error until the
situation with adding additional information into an error has been
clarified.
The following will need to be updated when we finish out the
error definitions.
</div>

<p>The following interface is defined for cases when a MediaStreamError
Expand Down Expand Up @@ -1984,22 +2213,12 @@ <h3>Error names</h3>
</tr>

<tr>
<th><code><dfn>ConstraintNotSatisfiedError</dfn></code></th>
<th><code><dfn>OverconstrainedError</dfn></code></th>

<td>One of the mandatory <a>Constraints</a> could not be
satisfied.</td>

<td>The <code>constraintName</code> attribute gets set to the name
of the constraint that caused the error</td>
</tr>

<tr>
<th><code><dfn>OverconstrainedError</dfn></code></th>

<td>Due to changes in the environment, one or more mandatory
constraints can no longer be satisfied.</td>

<td>The <code>constraintName</code> attribute gets set to the name
<td>The <code>constraint</code> attribute gets set to the name
of the constraint that caused the error</td>
</tr>

Expand Down Expand Up @@ -2706,16 +2925,18 @@ <h3>MediaDevices Interface Extensions</h3>
</li>
</ol>

<p>If <var>finalSet</var> is the empty set, reject
<var>p</var> with a new
<code><a>MediaStreamError</a></code> object whose
<code><a>name</a></code> attribute has the value
<code>ConstraintNotSatisfiedError</code> and whose
<code><a>constraintName</a></code> attribute is set
to any required constraint whose fitness distance
was infinity for all settings dictionaries examined
while executing
the <code><a>SelectSettings</a></code> algorithm, then
<p>If <var>finalSet</var> is the empty set,
let <var>constraint</var> be any required constraint
whose fitness distance was infinity for all settings
dictionaries examined while executing
the <code><a>SelectSettings</a></code> algorithm,
let <var>message</var> be
either <code>undefined</code> or an informative
human-readable message, and reject <var>p</var> with
a new <code><a>OverconstrainedError</a></code>
created by calling
<code>OverconstrainedError(<var>constraint</var>,
<var>message</var>)</code>, then
abort these steps.</p>
</li>

Expand Down Expand Up @@ -3399,12 +3620,20 @@ <h2>Interface Definition</h2>

<li>
<p>If <var>successfulSettings</var> is
<code>undefined</code>, reject <var>p</var> with a new
<code>MediaStreamError</code> with name
<code>ConstraintNotSatisfied</code> and
<code>constraintName</code> set to any of the required
constraints that could not be satisfied, and abort these
steps. <var>existingConstraints</var> remain in effect in
<code>undefined</code>,
let <var>failedConstraint</var> be any required constraint
whose fitness distance was infinity for all settings
dictionaries examined while executing
the <code><a>SelectSettings</a></code> algorithm,
let <var>message</var> be
either <code>undefined</code> or an informative
human-readable message, and reject <var>p</var> with
a new
<code>OverconstrainedError</code> created by
calling
<code>OverconstrainedError(<var>failedConstraint</var>,
<var>message</var>)</code>.
<var>existingConstraints</var> remain in effect in
this case.</p>
</li>

Expand Down

0 comments on commit 3037221

Please sign in to comment.