Skip to content

Instantly share code, notes, and snippets.

@shs96c
Created October 31, 2014 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shs96c/84d94aa2b9d978718db3 to your computer and use it in GitHub Desktop.
Save shs96c/84d94aa2b9d978718db3 to your computer and use it in GitHub Desktop.
The PATCH OF DOOM!
diff --git a/10_element_state.html b/10_element_state.html
--- a/10_element_state.html
+++ b/10_element_state.html
@@ -109,77 +109,42 @@
<td></td>
</tr>
</table>
- <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of this, the WebDriver API offers a single command ("getElementAttribute") which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
+ <div class="note">
+ <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of thisend point which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
- <p>The algorithm to implement this MUST be (where <code>name</code> refers to the <code>name</code> parameter of the <code>getElementAttribute</code> command):</p>
+ <p>The end result of this algorithm are values that can be passed to other commands within this specification. Notably, this means that URLs that are returned can be passed to <a href="#widl-WebDriver-get-void-DOMString-url">get</a> and the expected URL will be navigated to.</p>
+ </div>
+
+ <p>To determine the <var>value</var> of the <a>response</a>, the following steps must be taken where <var>name</var> is the <code>name</code> property on the <code>parameters</code> dictionary in <a>Command</a>, and <var>element</var> is the <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> modeled by the <code>ELEMENT</code> parameter.:
<ol>
- <li>If <code>name</code> case insensitively matches "style", the value returned MUST be <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec. Notably, css property names MUST be cased the same as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec.
- <ul>
- <li>It SHOULD be equivalent to obtaining the "cssText" property, with the additional constraint that the same value MUST be returned after a round trip through "executeScript". That is, the following pseudo-code MUST be true (where "driver" is a WebDriver instance, and "element" is a WebElement):
- <pre class="example highlight">
- style = element.get_attribute('style');
- self.driver.execute_script('arguments[0].style = arguments[1]', element, style);
- var recovered = element.get_attribute('style');
- assertEquals(style, recovered);
- </pre>
+ <li>Initially set <var>result</var> to null.
+ <li>Handle special-cases:
+ <ol>
+ <li>If "<var>name</var>" case insensitively matches "<code>style</code>", then store the value of the computed value of the <code>style</code> property of <var>element</var>, <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec, as <var>result</var>. Notably, CSS property names must be cased as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec. In addition, color property values must be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
+
+ <li>If "<var>name</var>" case insensitively matches "selected" or "checked", and the element is <a href="#is_selectable"><dfn>selectable</dfn></a>:
+ <ol>
+ <li>If the element supports neither a <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> or <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> check, then store null as <var>result</var>.</li>
+ <li>For an <code>option</code> element, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> as <var>result</var>.</li>
+ <li>In all other cases, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> as <var>result</var>.</li>
+ </ol>
</li>
- <li>Color property values MUST be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
- </ul>
- </li>
- <li>If the result of a Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-hasattribute">hasAttribute(name)</a></code>" (as defined in [[!DOM4]]) returns true:
- <ol>
- <li>Store the result of the Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-getattribute">getAttribute(name)</a></code>" in <code>result</code></li>
- <li>If the attribute <code>name</code> is defined as a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/#boolean-attribute">boolean attribute</a>, the string 'true' MUST be returned if <code>result</code> is true, or null otherwise</li>
- <li>Otherwise, fall through to the <a href="#attribute-final-step">final step</a> in this algorithm.</li>
+ <li>If any of the above steps have been executed, go to the <a href="#attribute-result-coercion">result coercion</a> step of this algorithm.
</ol>
</li>
- <li>If the element is an OPTION element and <code>name</code> case insensitively matches "value":
+
+ <li>Obtain the property indexed by "<var>name</var>" from the element and store this as <var>result</var>. If <var>name</var> case insensitively matches "class" set <var>result</var> to be <var>element</var>'s <code>className</code> property. Similarly, if <var>name</var> case insensitively matches "readonly", set <var>result</var> to be the <var>element</var>'s <code>readOnly</code> property.</li>
+
+ <li>If <var>result</var> is null or undefined, or if it is an object, set the value of <var>result</var> to be the <code>value</code> of the AttributeNode obtained by calling <code>getAttributeNode</code> on <var>element</var> iff that AttributeNode is <code>specified</code>. That is, <var>result</var> is the equivalent of executing the following Ecmascript: <code>var attr = element.getAttribute(name); var result = (attr &amp;&amp; attr.specified) ? attr.value : null;</code></li>
+
+ <li name="attribute-result-coercion">Coerce the return value to a DOMString:
<ol>
- <li>If a Javascript call to <code>hasAttribute(name)</code> returns true, then the result of a Javascript call to <code>getAttribute(name)</code> MUST be returned.</li>
- <li>Otherwise, the text content of the OPTION, as returned by a call to <code><a href="#widl-WebElement-getElementText-DOMString">getElementText</a></code>, MUST be returned.</li>
+ <li>If <var>result</var> is a boolean value, use the value "true" if <var>result</var> is true, or null otherwise.</li>
+ <li>if <var>result</var> is null or undefined, set <var>result</var> to be null.</li>
+ <li>In all other cases, ceorce <var>result</var> to a DOMString.</li>
</ol>
- </li>
- <li>If the element is <a href="#is_selectable">selectable</a> and <code>name</code> case insensitively matches "selected", and the element in an INPUT element of type "checkbox" or "radio", the string "true" MUST be returned if the element is <a href="http://www.w3.org/TR/html5/forms.html#concept-fe-checked">checked</a> or null otherwise.</li>
- <li>If the value is expected to be a URL, return the property named <code>name</code>, i.e. a fully resolved URL. A non-normative set of these properties is given below:
- <table class="simple">
- <tr>
- <th>Tag name</th>
- <th>"name" value</th>
- </tr>
- <tr>
- <td>A</td>
- <td>href</td>
- </tr>
- <tr>
- <td>IMG</td>
- <td>src</td>
- </tr>
- </table>
- </li>
- <li>If <code>name</code> is in the table below, and the above stages have not yielded a defined, non-null value, the value of the aliased attribute in the table MUST be used as the argument to a recursive call to <code>getElementAttribute</code> and the result returned. This is to allow for common mis-captitalizations:
- <table class="simple">
- <tr>
- <th>Original property name</th>
- <th>Aliased property name</th>
- </tr>
- <tr>
- <td>class</td>
- <td>className</td>
- </tr>
- <tr>
- <td>readonly</td>
- <td>readOnly</td>
- </tr>
- </table>
- </li>
- <li id="attribute-final-step">Finally, attempt the following steps in order, ceasing when one returns a value:
- <ol>
- <li>Attempt to determine the property of the element with the given <code>name</code>. If this is defined and is not an object, then the named property of the object coerced to a string MUST be returned.</li>
- <li> If a Javascript call to "<code>hasAttribute(name)</code>" returns "true", the result of a Javascript call to "<code>getAttribute(name)</code>" MUST be returned.</li>
- <li>The null value MUST be returned.</li>
- </ol>
- </li>
+ </li>
</ol>
<dl class='parameters'>
<dt>DOMString name</dt>
diff --git a/webdriver-spec.html b/webdriver-spec.html
--- a/webdriver-spec.html
+++ b/webdriver-spec.html
@@ -1247,77 +1247,42 @@
<td></td>
</tr>
</table>
- <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of this, the WebDriver API offers a single command ("getElementAttribute") which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
+ <div class="note">
+ <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of thisend point which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
- <p>The algorithm to implement this MUST be (where <code>name</code> refers to the <code>name</code> parameter of the <code>getElementAttribute</code> command):</p>
+ <p>The end result of this algorithm are values that can be passed to other commands within this specification. Notably, this means that URLs that are returned can be passed to <a href="#widl-WebDriver-get-void-DOMString-url">get</a> and the expected URL will be navigated to.</p>
+ </div>
+
+ <p>To determine the <var>value</var> of the <a>response</a>, the following steps must be taken where <var>name</var> is the <code>name</code> property on the <code>parameters</code> dictionary in <a>Command</a>, and <var>element</var> is the <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> modeled by the <code>ELEMENT</code> parameter.:
<ol>
- <li>If <code>name</code> case insensitively matches "style", the value returned MUST be <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec. Notably, css property names MUST be cased the same as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec.
- <ul>
- <li>It SHOULD be equivalent to obtaining the "cssText" property, with the additional constraint that the same value MUST be returned after a round trip through "executeScript". That is, the following pseudo-code MUST be true (where "driver" is a WebDriver instance, and "element" is a WebElement):
- <pre class="example highlight">
- style = element.get_attribute('style');
- self.driver.execute_script('arguments[0].style = arguments[1]', element, style);
- var recovered = element.get_attribute('style');
- assertEquals(style, recovered);
- </pre>
+ <li>Initially set <var>result</var> to null.
+ <li>Handle special-cases:
+ <ol>
+ <li>If "<var>name</var>" case insensitively matches "<code>style</code>", then store the value of the computed value of the <code>style</code> property of <var>element</var>, <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec, as <var>result</var>. Notably, CSS property names must be cased as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec. In addition, color property values must be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
+
+ <li>If "<var>name</var>" case insensitively matches "selected" or "checked", and the element is <a href="#is_selectable"><dfn>selectable</dfn></a>:
+ <ol>
+ <li>If the element supports neither a <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> or <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> check, then store null as <var>result</var>.</li>
+ <li>For an <code>option</code> element, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> as <var>result</var>.</li>
+ <li>In all other cases, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> as <var>result</var>.</li>
+ </ol>
</li>
- <li>Color property values MUST be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
- </ul>
- </li>
- <li>If the result of a Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-hasattribute">hasAttribute(name)</a></code>" (as defined in [[!DOM4]]) returns true:
- <ol>
- <li>Store the result of the Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-getattribute">getAttribute(name)</a></code>" in <code>result</code></li>
- <li>If the attribute <code>name</code> is defined as a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/#boolean-attribute">boolean attribute</a>, the string 'true' MUST be returned if <code>result</code> is true, or null otherwise</li>
- <li>Otherwise, fall through to the <a href="#attribute-final-step">final step</a> in this algorithm.</li>
+ <li>If any of the above steps have been executed, go to the <a href="#attribute-result-coercion">result coercion</a> step of this algorithm.
</ol>
</li>
- <li>If the element is an OPTION element and <code>name</code> case insensitively matches "value":
+
+ <li>Obtain the property indexed by "<var>name</var>" from the element and store this as <var>result</var>. If <var>name</var> case insensitively matches "class" set <var>result</var> to be <var>element</var>'s <code>className</code> property. Similarly, if <var>name</var> case insensitively matches "readonly", set <var>result</var> to be the <var>element</var>'s <code>readOnly</code> property.</li>
+
+ <li>If <var>result</var> is null or undefined, or if it is an object, set the value of <var>result</var> to be the <code>value</code> of the AttributeNode obtained by calling <code>getAttributeNode</code> on <var>element</var> iff that AttributeNode is <code>specified</code>. That is, <var>result</var> is the equivalent of executing the following Ecmascript: <code>var attr = element.getAttribute(name); var result = (attr &amp;&amp; attr.specified) ? attr.value : null;</code></li>
+
+ <li name="attribute-result-coercion">Coerce the return value to a DOMString:
<ol>
- <li>If a Javascript call to <code>hasAttribute(name)</code> returns true, then the result of a Javascript call to <code>getAttribute(name)</code> MUST be returned.</li>
- <li>Otherwise, the text content of the OPTION, as returned by a call to <code><a href="#widl-WebElement-getElementText-DOMString">getElementText</a></code>, MUST be returned.</li>
+ <li>If <var>result</var> is a boolean value, use the value "true" if <var>result</var> is true, or null otherwise.</li>
+ <li>if <var>result</var> is null or undefined, set <var>result</var> to be null.</li>
+ <li>In all other cases, ceorce <var>result</var> to a DOMString.</li>
</ol>
- </li>
- <li>If the element is <a href="#is_selectable">selectable</a> and <code>name</code> case insensitively matches "selected", and the element in an INPUT element of type "checkbox" or "radio", the string "true" MUST be returned if the element is <a href="http://www.w3.org/TR/html5/forms.html#concept-fe-checked">checked</a> or null otherwise.</li>
- <li>If the value is expected to be a URL, return the property named <code>name</code>, i.e. a fully resolved URL. A non-normative set of these properties is given below:
- <table class="simple">
- <tr>
- <th>Tag name</th>
- <th>"name" value</th>
- </tr>
- <tr>
- <td>A</td>
- <td>href</td>
- </tr>
- <tr>
- <td>IMG</td>
- <td>src</td>
- </tr>
- </table>
- </li>
- <li>If <code>name</code> is in the table below, and the above stages have not yielded a defined, non-null value, the value of the aliased attribute in the table MUST be used as the argument to a recursive call to <code>getElementAttribute</code> and the result returned. This is to allow for common mis-captitalizations:
- <table class="simple">
- <tr>
- <th>Original property name</th>
- <th>Aliased property name</th>
- </tr>
- <tr>
- <td>class</td>
- <td>className</td>
- </tr>
- <tr>
- <td>readonly</td>
- <td>readOnly</td>
- </tr>
- </table>
- </li>
- <li id="attribute-final-step">Finally, attempt the following steps in order, ceasing when one returns a value:
- <ol>
- <li>Attempt to determine the property of the element with the given <code>name</code>. If this is defined and is not an object, then the named property of the object coerced to a string MUST be returned.</li>
- <li> If a Javascript call to "<code>hasAttribute(name)</code>" returns "true", the result of a Javascript call to "<code>getAttribute(name)</code>" MUST be returned.</li>
- <li>The null value MUST be returned.</li>
- </ol>
- </li>
+ </li>
</ol>
<dl class='parameters'>
<dt>DOMString name</dt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment