Do not assert when CharacterData representing an Attr fires events
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Apr 2017 00:05:27 +0000 (00:05 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Apr 2017 00:05:27 +0000 (00:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170454
<rdar://problem/30979320>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Make the NoEventDispatchAssertion in CharacterData::notifyParentAfterChange conditional
since Attr elements should be allowed to fire events.

Tests: fast/dom/no-assert-for-malformed-js-url-attribute.html

* dom/CharacterData.cpp:
(WebCore::CharacterData::notifyParentAfterChange):

LayoutTests:

* fast/dom/no-assert-for-malformed-js-url-attribute-expected.txt: Added.
* fast/dom/no-assert-for-malformed-js-url-attribute.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214915 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/no-assert-for-malformed-js-url-attribute-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/no-assert-for-malformed-js-url-attribute.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/CharacterData.cpp

index b6b4d30..2a12eb2 100644 (file)
@@ -1,3 +1,14 @@
+2017-04-04  Brent Fulgham  <bfulgham@apple.com>
+
+        Do not assert when CharacterData representing an Attr fires events
+        https://bugs.webkit.org/show_bug.cgi?id=170454
+        <rdar://problem/30979320>
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/dom/no-assert-for-malformed-js-url-attribute-expected.txt: Added.
+        * fast/dom/no-assert-for-malformed-js-url-attribute.html: Added.
+
 2017-04-04  Youenn Fablet  <youenn@apple.com>
 
         LayoutTest webrtc/libwebrtc/descriptionGetters.html is a flaky failure
diff --git a/LayoutTests/fast/dom/no-assert-for-malformed-js-url-attribute-expected.txt b/LayoutTests/fast/dom/no-assert-for-malformed-js-url-attribute-expected.txt
new file mode 100644 (file)
index 0000000..2cb8efa
--- /dev/null
@@ -0,0 +1,10 @@
+CONSOLE MESSAGE: line 1: SyntaxError: Unexpected identifier 'orem'
+This tests that we do not assert when a malformed JS URL is passed to the 'src' attribute of an iframe. The test passes if it does not ASSERT.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+  
diff --git a/LayoutTests/fast/dom/no-assert-for-malformed-js-url-attribute.html b/LayoutTests/fast/dom/no-assert-for-malformed-js-url-attribute.html
new file mode 100644 (file)
index 0000000..207ad63
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("This tests that we do not assert when a malformed JS URL is passed to the 'src' attribute of an iframe. The test passes if it does not ASSERT.");
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function runTest()
+{
+    var testFrame1 = document.getElementById('testFrame1');
+    testFrame1.getAttributeNode("src").firstChild.appendData("missingFunction(this) orem ipsum dosolorem");
+
+    var testFrame2 = document.getElementById('testFrame2');
+    testFrame2.getAttributeNode("src").firstChild.appendData("javascript:missingFunction(this) orem ipsum dosolorem");
+}
+</script>
+</head>
+<body onload="runTest()">
+    <iframe id='testFrame1' src='javascript:'></iframe>
+    <iframe id='testFrame2' src='foo'></iframe>
+</body>
+</html>
\ No newline at end of file
index f6ed261..529690c 100644 (file)
@@ -1,3 +1,19 @@
+2017-04-04  Brent Fulgham  <bfulgham@apple.com>
+
+        Do not assert when CharacterData representing an Attr fires events
+        https://bugs.webkit.org/show_bug.cgi?id=170454
+        <rdar://problem/30979320>
+
+        Reviewed by Ryosuke Niwa.
+
+        Make the NoEventDispatchAssertion in CharacterData::notifyParentAfterChange conditional
+        since Attr elements should be allowed to fire events.
+
+        Tests: fast/dom/no-assert-for-malformed-js-url-attribute.html
+
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::notifyParentAfterChange):
+
 2017-04-04  Youenn Fablet  <youenn@apple.com>
 
         LayoutTest webrtc/libwebrtc/descriptionGetters.html is a flaky failure
index e00b20c..4e564bc 100644 (file)
@@ -22,6 +22,7 @@
 #include "config.h"
 #include "CharacterData.h"
 
+#include "Attr.h"
 #include "ElementTraversal.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
@@ -208,7 +209,9 @@ void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep
 
 void CharacterData::notifyParentAfterChange(ContainerNode::ChildChangeSource source)
 {
-    NoEventDispatchAssertion assertNoEventDispatch;
+#if !ASSERT_DISABLED
+    auto assertNoEventDispatch = std::make_unique<NoEventDispatchAssertion>();
+#endif
 
     document().incDOMTreeVersion();
 
@@ -221,6 +224,13 @@ void CharacterData::notifyParentAfterChange(ContainerNode::ChildChangeSource sou
         ElementTraversal::nextSibling(*this),
         source
     };
+
+#if !ASSERT_DISABLED
+    // Attribute CharacterData is expected to fire events.
+    if (is<Attr>(*parentNode()))
+        assertNoEventDispatch = nullptr;
+#endif
+
     parentNode()->childrenChanged(change);
 }