<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29061</bug_id>
          
          <creation_ts>2015-08-18 13:39:06 +0000</creation_ts>
          <short_desc>iframe@sandbox support should be feature-detectable.</short_desc>
          <delta_ts>2016-01-24 06:06:47 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://html.spec.whatwg.org/#dom-iframe-sandbox</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          <blocked>28796</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>d</cc>
    
    <cc>igrigorik</cc>
    
    <cc>mike</cc>
    
    <cc>mkwst</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>yoav</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>122640</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2015-08-18 13:39:06 +0000</bug_when>
    <thetext>Specification: https://html.spec.whatwg.org/multipage/embedded-content.html
Multipage: https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
Complete: https://html.spec.whatwg.org/#dom-iframe-sandbox
Referrer: https://html.spec.whatwg.org/multipage/index.html

Comment:
iframe@sandbox support should be feature-detectable.

Currently, there&apos;s no feature-detection mechanism for sandbox attributes. A
trivial way of adding one might be to limit iframe@sandbox attribute to
reflect only known values
(https://html.spec.whatwg.org/multipage/infrastructure.html#limited-to-only-kn
own-values).

Posted from: 216.239.45.87
User agent: Mozilla/5.0 (X11; CrOS x86_64 7262.33.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.37 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122641</commentid>
    <comment_count>1</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2015-08-18 13:40:23 +0000</bug_when>
    <thetext>WDYT, Anne, Domenic?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122642</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-18 14:13:39 +0000</bug_when>
    <thetext>That only works for enumerated attributes. sandbox=&quot;&quot; is an unordered set of unique space-separated tokens.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122643</commentid>
    <comment_count>3</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2015-08-18 14:26:28 +0000</bug_when>
    <thetext>Ok. I admit, I didn&apos;t actually read the definition, but it sounded right. :)

You&apos;re right that we&apos;d need a new concept, but conceptually it&apos;d be similar. That is, it seems reasonable to just drop unknown values on the floor during parsing, such that the following would hold:

```
var i = document.createElement(&apos;iframe&apos;);
i.sandbox = &quot;allow-scripts lldshf&quot;;
i.sandbox.value; // &quot;allow-scripts&quot;
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122644</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-18 14:30:40 +0000</bug_when>
    <thetext>Well, the sandbox property also returns a DOMSettableTokenList so it&apos;s not really a string. And DOMSettableTokenList cannot enforce validity of strings at the moment. So it would require quite a bit more changes I think.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122645</commentid>
    <comment_count>5</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2015-08-18 14:38:19 +0000</bug_when>
    <thetext>If modifying the attribute&apos;s behavior is more work than it&apos;s worth, I&apos;m open to any other options. Put an inspectable enum of allowed values somewhere, done. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122646</commentid>
    <comment_count>6</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2015-08-18 22:29:41 +0000</bug_when>
    <thetext>I think this would be a reasonable change to DOMSettableTokenList/DOMTokenList, to only reflect to the tokens that the browser recognizes. It would require some spec and implementation work to happen though, including a willingness to break back-compat.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122647</commentid>
    <comment_count>7</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2015-08-19 00:44:22 +0000</bug_when>
    <thetext>(In reply to Domenic Denicola from comment #6)
&gt; I think this would be a reasonable change to
&gt; DOMSettableTokenList/DOMTokenList, to only reflect to the tokens that the
&gt; browser recognizes. It would require some spec and implementation work to
&gt; happen though, including a willingness to break back-compat.

Looking at IDL files, backwards compatability doesn&apos;t seem to be a big risk: there are only three DOMSettableTokenList attributes implemented in Chrome, for example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122648</commentid>
    <comment_count>8</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2015-08-19 04:47:50 +0000</bug_when>
    <thetext>Here is a potential plan for the required spec changes:

Modifications to DOM:

- Add an associated optional token validation algorithm to DOMTokenList.
- Modify DOMTokenList.prototype.{add,remove,toggle,contains} to either throw or ignore their input if it the token validation algorithm is present and running it fails on a given token. Be sure to define e.g. `i.sandbox.add(&quot;valid&quot;, &quot;invalid&quot;, &quot;valid2&quot;)` in a well-defined way. I can see pro- and con- arguments for either behavior.
- Modify DOMSettableTokenList.prototype.value&apos;s setter to run the token validation algorithm if present, before setting tokens to the result.

Modifications to HTML:

- Add such a token validation algorithm to HTMLIFrameElement.prototype.seamless, validating that the value is in the given set.
- If possible, find other specs that could benefit from this and add algorithms to them at the same time.

Anne, WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122649</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-19 06:16:05 +0000</bug_when>
    <thetext>Sounds reasonable. And useful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122856</commentid>
    <comment_count>10</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2015-08-28 15:08:27 +0000</bug_when>
    <thetext>Throwing as a way to feature-detect seems more annoying than e.g. a return value. It seems to me that we don&apos;t necessarily want the API to reject invalid values, we just want to enable feature-detection. You might still want to add values that the implementation doesn&apos;t support if that makes the logic simpler. It also seems somewhat risky Web-compat-wise to start throwing.

To that end, I think the minimal change is to make DOMTokenList#add have a boolean return value where, if there is token validation defined and all values added are supported, it returns true; otherwise returns false.

var i = document.createElement(&apos;iframe&apos;);
var supported = i.sandbox.add(&quot;lldshf&quot;);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122857</commentid>
    <comment_count>11</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2015-08-28 15:10:53 +0000</bug_when>
    <thetext>Alternatively introduce DOMTokenList#supports()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122861</commentid>
    <comment_count>12</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2015-08-28 15:37:14 +0000</bug_when>
    <thetext>It still seems valuable to me to have the built-in ways of manipulating a DOMTokenList try to preserve no-invalid-tokens. That is, having add and toggle ignore invalid tokens seems like a good change regardless.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122895</commentid>
    <comment_count>13</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2015-08-29 16:18:08 +0000</bug_when>
    <thetext>Why?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122896</commentid>
    <comment_count>14</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-29 16:46:44 +0000</bug_when>
    <thetext>It would be more consistent with &quot;limited to known values&quot;, an existing pattern, whereas you are proposing a new pattern.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122917</commentid>
    <comment_count>15</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2015-08-31 11:07:25 +0000</bug_when>
    <thetext>OK. Consistency with that suggests not throwing. Let&apos;s try it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124051</commentid>
    <comment_count>16</comment_count>
    <who name="Yoav Weiss">yoav</who>
    <bug_when>2015-11-03 10:18:47 +0000</bug_when>
    <thetext>I like the solution outlined and it seems like it would be useful for https://github.com/w3c/preload/issues/7 as well, when used on `relList`.

Having a boolean return value also has the added benefit of having legacy UAs fall into the &quot;false&quot; bucket for most cases, since their return value for `add()` would be `undefined`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124052</commentid>
    <comment_count>17</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2015-11-03 11:47:48 +0000</bug_when>
    <thetext>The solution that&apos;s most consistent with &quot;limited to known values&quot; would be to make `add` return true or false depending on whether the token(s) are supported, but add all passed tokens to the content attribute regardless of whether they&apos;re supported. I suspect this is also likely the most web-compatible change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124152</commentid>
    <comment_count>18</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2015-11-10 12:33:36 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/pull/103 fixes this issue for the DOM spec, but the HTML spec needs to use the new hook for &lt;iframe sandbox&gt; (this bug) and &lt;link rel&gt; (bug 28796).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124698</commentid>
    <comment_count>19</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2016-01-24 06:06:47 +0000</bug_when>
    <thetext>This is now fixed: &quot;The supported tokens for sandbox are the allowed values defined for the sandbox attribute that are supported by the user agent.&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>