Title: [191388] trunk
Revision
191388
Author
cdu...@apple.com
Date
2015-10-21 10:00:18 -0700 (Wed, 21 Oct 2015)

Log Message

HTMLIFrameElement.sandbox should be a DOMSettableTokenList
https://bugs.webkit.org/show_bug.cgi?id=150377

Reviewed by Ryosuke Niwa.

Source/WebCore:

HTMLIFrameElement.sandbox should be a DOMSettableTokenList as per the
HTML specification:
- https://html.spec.whatwg.org/multipage/embedded-content.html#htmliframeelement

Chrome and Firefox match the specification but Safari/WebKit was uding
a DOMString.

Test: fast/frames/sandbox-attribute.html

* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::sandbox):
(WebCore::HTMLIFrameElement::parseAttribute):
* html/HTMLIFrameElement.h:
* html/HTMLIFrameElement.idl:

LayoutTests:

* fast/frames/sandbox-attribute-expected.txt: Added.
* fast/frames/sandbox-attribute.html: Added.
Add layout test to check that HTMLIframeElement.sandbox is now a
DOMSettableTokenList.

* fast/frames/sandboxed-iframe-navigation-allowed-expected.txt:
* fast/frames/sandboxed-iframe-navigation-allowed.html:
Update test that was using shouldBe() with HTMLIframeElement.sandbox.
shouldBe() does an === check but which now fails before
HTMLIframeElement.sandbox is now a DOMSettableTokenList that can be
stringified, rather than a String.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191387 => 191388)


--- trunk/LayoutTests/ChangeLog	2015-10-21 13:36:55 UTC (rev 191387)
+++ trunk/LayoutTests/ChangeLog	2015-10-21 17:00:18 UTC (rev 191388)
@@ -1,3 +1,22 @@
+2015-10-21  Chris Dumez  <cdu...@apple.com>
+
+        HTMLIFrameElement.sandbox should be a DOMSettableTokenList
+        https://bugs.webkit.org/show_bug.cgi?id=150377
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/frames/sandbox-attribute-expected.txt: Added.
+        * fast/frames/sandbox-attribute.html: Added.
+        Add layout test to check that HTMLIframeElement.sandbox is now a
+        DOMSettableTokenList.
+
+        * fast/frames/sandboxed-iframe-navigation-allowed-expected.txt:
+        * fast/frames/sandboxed-iframe-navigation-allowed.html:
+        Update test that was using shouldBe() with HTMLIframeElement.sandbox.
+        shouldBe() does an === check but which now fails before
+        HTMLIframeElement.sandbox is now a DOMSettableTokenList that can be
+        stringified, rather than a String.
+
 2015-10-20  Sergio Villar Senin  <svil...@igalia.com>
 
         [css-grid] Fix freeSpace computation with non-zero baseSize flex tracks

Added: trunk/LayoutTests/fast/frames/sandbox-attribute-expected.txt (0 => 191388)


--- trunk/LayoutTests/fast/frames/sandbox-attribute-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/frames/sandbox-attribute-expected.txt	2015-10-21 17:00:18 UTC (rev 191388)
@@ -0,0 +1,25 @@
+Checks that HTMLIframeElement.sandbox is a DOMSettableTokenList.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS iframe.sandbox.__proto__ is DOMSettableTokenList.prototype
+
+iframe.sandbox = 'allow-popups   allow-scripts  allow-scripts  allow-same-origin'
+PASS iframe.sandbox.length is 3
+PASS iframe.sandbox[0] is "allow-popups"
+PASS iframe.sandbox[1] is "allow-scripts"
+PASS iframe.sandbox[2] is "allow-same-origin"
+PASS String(iframe.sandbox) is "allow-popups allow-scripts allow-same-origin"
+PASS iframe.getAttribute('sandbox') is "allow-popups allow-scripts allow-same-origin"
+
+iframe.setAttribute('sandbox', 'allow-popups allow-scripts')
+PASS iframe.sandbox.length is 2
+PASS iframe.sandbox[0] is "allow-popups"
+PASS iframe.sandbox[1] is "allow-scripts"
+PASS String(iframe.sandbox) is "allow-popups allow-scripts"
+PASS iframe.getAttribute('sandbox') is "allow-popups allow-scripts"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/frames/sandbox-attribute.html (0 => 191388)


--- trunk/LayoutTests/fast/frames/sandbox-attribute.html	                        (rev 0)
+++ trunk/LayoutTests/fast/frames/sandbox-attribute.html	2015-10-21 17:00:18 UTC (rev 191388)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Checks that HTMLIframeElement.sandbox is a DOMSettableTokenList.");
+
+var iframe = document.createElement("iframe");
+shouldBe("iframe.sandbox.__proto__", "DOMSettableTokenList.prototype");
+
+debug("");
+evalAndLog("iframe.sandbox = 'allow-popups   allow-scripts  allow-scripts  allow-same-origin'");
+shouldBe("iframe.sandbox.length", "3");
+shouldBeEqualToString("iframe.sandbox[0]", "allow-popups");
+shouldBeEqualToString("iframe.sandbox[1]", "allow-scripts");
+shouldBeEqualToString("iframe.sandbox[2]", "allow-same-origin");
+shouldBeEqualToString("String(iframe.sandbox)", "allow-popups allow-scripts allow-same-origin");
+shouldBeEqualToString("iframe.getAttribute('sandbox')", "allow-popups allow-scripts allow-same-origin");
+
+debug("");
+evalAndLog("iframe.setAttribute('sandbox', 'allow-popups allow-scripts')");
+shouldBe("iframe.sandbox.length", "2");
+shouldBeEqualToString("iframe.sandbox[0]", "allow-popups");
+shouldBeEqualToString("iframe.sandbox[1]", "allow-scripts");
+shouldBeEqualToString("String(iframe.sandbox)", "allow-popups allow-scripts");
+shouldBeEqualToString("iframe.getAttribute('sandbox')", "allow-popups allow-scripts");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-allowed-expected.txt (191387 => 191388)


--- trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-allowed-expected.txt	2015-10-21 13:36:55 UTC (rev 191387)
+++ trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-allowed-expected.txt	2015-10-21 17:00:18 UTC (rev 191388)
@@ -5,7 +5,7 @@
 
 PASS (self.sandboxedFrame.frameWithPlugin.document.getElementById('plugin').destroyStream) == undefined is true
 PASS (self.frameWithPlugin.document.getElementById('plugin').destroyStream) != undefined is true
-PASS document.getElementById('sandboxedFrameId').sandbox is 'allow-scripts allow-same-origin'
+PASS String(document.getElementById('sandboxedFrameId').sandbox) is "allow-scripts allow-same-origin"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-allowed.html (191387 => 191388)


--- trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-allowed.html	2015-10-21 13:36:55 UTC (rev 191387)
+++ trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-allowed.html	2015-10-21 17:00:18 UTC (rev 191388)
@@ -24,7 +24,7 @@
 
 function sandboxWasNavigated()
 {
-    shouldBe("document.getElementById('sandboxedFrameId').sandbox", "'allow-scripts allow-same-origin'");
+    shouldBeEqualToString("String(document.getElementById('sandboxedFrameId').sandbox)", "allow-scripts allow-same-origin");
     isSuccessfullyParsed();
 
     if (window.testRunner)

Modified: trunk/Source/WebCore/ChangeLog (191387 => 191388)


--- trunk/Source/WebCore/ChangeLog	2015-10-21 13:36:55 UTC (rev 191387)
+++ trunk/Source/WebCore/ChangeLog	2015-10-21 17:00:18 UTC (rev 191388)
@@ -1,3 +1,25 @@
+2015-10-21  Chris Dumez  <cdu...@apple.com>
+
+        HTMLIFrameElement.sandbox should be a DOMSettableTokenList
+        https://bugs.webkit.org/show_bug.cgi?id=150377
+
+        Reviewed by Ryosuke Niwa.
+
+        HTMLIFrameElement.sandbox should be a DOMSettableTokenList as per the
+        HTML specification:
+        - https://html.spec.whatwg.org/multipage/embedded-content.html#htmliframeelement
+
+        Chrome and Firefox match the specification but Safari/WebKit was uding
+        a DOMString.
+
+        Test: fast/frames/sandbox-attribute.html
+
+        * html/HTMLIFrameElement.cpp:
+        (WebCore::HTMLIFrameElement::sandbox):
+        (WebCore::HTMLIFrameElement::parseAttribute):
+        * html/HTMLIFrameElement.h:
+        * html/HTMLIFrameElement.idl:
+
 2015-10-21  Carlos Garcia Campos  <cgar...@igalia.com>
 
         ASSERTION FAILED: markFontData in FontCascade::emphasisMarkHeight

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.cpp (191387 => 191388)


--- trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2015-10-21 13:36:55 UTC (rev 191387)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2015-10-21 17:00:18 UTC (rev 191388)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "HTMLIFrameElement.h"
 
+#include "AttributeDOMTokenList.h"
 #include "CSSPropertyNames.h"
 #include "Frame.h"
 #include "HTMLDocument.h"
@@ -47,6 +48,13 @@
     return adoptRef(*new HTMLIFrameElement(tagName, document));
 }
 
+DOMSettableTokenList& HTMLIFrameElement::sandbox()
+{
+    if (!m_sandbox)
+        m_sandbox = std::make_unique<AttributeDOMTokenList>(*this, sandboxAttr);
+    return *m_sandbox;
+}
+
 bool HTMLIFrameElement::isPresentationAttribute(const QualifiedName& name) const
 {
     if (name == widthAttr || name == heightAttr || name == alignAttr || name == frameborderAttr)
@@ -76,6 +84,9 @@
 void HTMLIFrameElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == sandboxAttr) {
+        if (m_sandbox)
+            m_sandbox->attributeValueChanged(value);
+
         String invalidTokens;
         setSandboxFlags(value.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(value, invalidTokens));
         if (!invalidTokens.isNull())

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.h (191387 => 191388)


--- trunk/Source/WebCore/html/HTMLIFrameElement.h	2015-10-21 13:36:55 UTC (rev 191387)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.h	2015-10-21 17:00:18 UTC (rev 191388)
@@ -28,10 +28,14 @@
 
 namespace WebCore {
 
+class AttributeDOMTokenList;
+
 class HTMLIFrameElement final : public HTMLFrameElementBase {
 public:
     static Ref<HTMLIFrameElement> create(const QualifiedName&, Document&);
 
+    DOMSettableTokenList& sandbox();
+
 private:
     HTMLIFrameElement(const QualifiedName&, Document&);
 
@@ -45,6 +49,8 @@
 
     virtual bool rendererIsNeeded(const RenderStyle&) override;
     virtual RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&, const RenderTreePosition&) override;
+
+    std::unique_ptr<AttributeDOMTokenList> m_sandbox;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.idl (191387 => 191388)


--- trunk/Source/WebCore/html/HTMLIFrameElement.idl	2015-10-21 13:36:55 UTC (rev 191387)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.idl	2015-10-21 17:00:18 UTC (rev 191388)
@@ -27,9 +27,11 @@
     [Reflect] attribute DOMString marginWidth;
     [Reflect] attribute DOMString name;
 
-    // FIXME: This is supposed to be:
-    // [PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
     [Reflect] attribute DOMString sandbox;
+#else
+    [PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
+#endif
 
     [Reflect] attribute DOMString scrolling;
     [Reflect, URL] attribute DOMString src;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to