Error thrown during "acceptNode" lookup is overridden
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 06:11:35 +0000 (06:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 06:11:35 +0000 (06:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200735

Patch by Alexey Shvayka <shvaikalesh@gmail.com> on 2019-08-14
Reviewed by Ross Kirsling.

LayoutTests/imported/w3c:

* web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-expected.txt:

Source/WebCore:

Test: imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-expected.html

* bindings/js/JSCallbackData.cpp:
(WebCore::JSCallbackData::invokeCallback): Catch and return exception of callback->get call.

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

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCallbackData.cpp

index 413caff..47ba1c4 100644 (file)
@@ -1,5 +1,14 @@
 2019-08-14  Alexey Shvayka  <shvaikalesh@gmail.com>
 
+        Error thrown during "acceptNode" lookup is overridden
+        https://bugs.webkit.org/show_bug.cgi?id=200735
+
+        Reviewed by Ross Kirsling.
+
+        * web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-expected.txt:
+
+2019-08-14  Alexey Shvayka  <shvaikalesh@gmail.com>
+
         Re-sync web-platform-tests/dom/traversal from upstream
         https://bugs.webkit.org/show_bug.cgi?id=200737
 
index 72a87af..d5eb6a7 100644 (file)
@@ -7,7 +7,7 @@ PASS Testing with object lacking acceptNode property
 PASS Testing with object with non-function acceptNode property 
 PASS Testing with function having acceptNode function 
 PASS Testing with filter function that throws 
-FAIL rethrows errors when getting `acceptNode` assert_throws: function "function () { walker.firstChild(); }" threw object "TypeError: Type error" ("TypeError") expected object "[object Object]" ("test")
+PASS rethrows errors when getting `acceptNode` 
 PASS performs `Get` on every traverse 
 PASS Testing with filter object that throws 
 Test JS objects as NodeFilters
index f5bc8f0..f6c9382 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Alexey Shvayka  <shvaikalesh@gmail.com>
+
+        Error thrown during "acceptNode" lookup is overridden
+        https://bugs.webkit.org/show_bug.cgi?id=200735
+
+        Reviewed by Ross Kirsling.
+
+        Test: imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-expected.html
+
+        * bindings/js/JSCallbackData.cpp:
+        (WebCore::JSCallbackData::invokeCallback): Catch and return exception of callback->get call.
+
 2019-08-14  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [WHLSL] Variables shouldn't be able to have void type
index 186762a..8d11fe9 100644 (file)
@@ -44,6 +44,8 @@ JSValue JSCallbackData::invokeCallback(JSDOMGlobalObject& globalObject, JSObject
 
     ExecState* exec = globalObject.globalExec();
     VM& vm = exec->vm();
+    auto scope = DECLARE_CATCH_SCOPE(vm);
+
     JSValue function;
     CallData callData;
     CallType callType = CallType::None;
@@ -60,6 +62,12 @@ JSValue JSCallbackData::invokeCallback(JSDOMGlobalObject& globalObject, JSObject
 
         ASSERT(!functionName.isNull());
         function = callback->get(exec, functionName);
+        if (UNLIKELY(scope.exception())) {
+            returnedException = scope.exception();
+            scope.clearException();
+            return JSValue();
+        }
+
         callType = getCallData(vm, function, callData);
         if (callType == CallType::None) {
             returnedException = JSC::Exception::create(vm, createTypeError(exec));