Changeset 203941 in webkit
- Timestamp:
- Jul 30, 2016 1:35:06 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r203935 r203941 1 2016-07-30 Chris Dumez <cdumez@apple.com> 2 3 [WebIDL] Enable strict type checking for operations' nullable parameters of wrapper types 4 https://bugs.webkit.org/show_bug.cgi?id=160374 5 6 Reviewed by Youenn Fablet. 7 8 Update / rebaseline existing tests to reflect behavior change. Also fix 9 several bugs in tests that became obvious now that we throw. 10 11 * editing/execCommand/indent-pre-expected.txt: 12 * editing/execCommand/indent-pre.html: 13 * editing/selection/4895428-2.html: 14 * editing/selection/move-by-word-visually-null-box.html: 15 * fast/dom/DOMImplementation/detached-doctype.html: 16 * fast/dom/MutationObserver/observe-attributes.html: 17 * fast/dom/Node/contains-method-expected.txt: 18 * fast/dom/Node/script-tests/contains-method.js: 19 * fast/dom/Window/webkitConvertPoint.html: 20 * fast/dom/adopt-node-crash-2.html: 21 * fast/dom/incompatible-operations-expected.txt: 22 * fast/dom/incompatible-operations.html: 23 * fast/events/selectstart-by-arrow-keys.html: 24 * fast/images/image-copy-memory-usage.html: 25 * fast/xsl/xslt-processor-expected.txt: 26 * http/tests/misc/webtiming-cross-origin-and-back1.html: 27 * platform/mac/fast/dom/Window/webkitConvertPoint-expected.txt: 28 * svg/custom/unicode-in-tspan-multi-svg-crash.html: 29 1 30 2016-07-29 Chris Dumez <cdumez@apple.com> 2 31 -
trunk/LayoutTests/editing/execCommand/indent-pre-expected.txt
r93051 r203941 103 103 if (textNode.nodeType != Node.TEXT_NODE) 104 104 throw "Wrong node type: " + textNode; 105 execSetSelectionCommand(textNode, 0, 0);105 execSetSelectionCommand(textNode, 0, null); 106 106 } 107 107 -
trunk/LayoutTests/editing/execCommand/indent-pre.html
r63039 r203941 31 31 if (textNode.nodeType != Node.TEXT_NODE) 32 32 throw "Wrong node type: " + textNode; 33 execSetSelectionCommand(textNode, 0, 0);33 execSetSelectionCommand(textNode, 0, null); 34 34 } 35 35 -
trunk/LayoutTests/editing/selection/4895428-2.html
r120173 r203941 19 19 return; 20 20 var cell = document.getElementById("cell"); 21 cell.addEventListener( handleBlur, "DOMBlurEvent");21 cell.addEventListener("DOMBlurEvent", handleBlur); 22 22 var div = document.getElementById("div"); 23 23 div.focus(); -
trunk/LayoutTests/editing/selection/move-by-word-visually-null-box.html
r155276 r203941 10 10 // Test NULL VisiblePosition. 11 11 var selection = getSelection(); 12 selection.setPosition( 0, 0);12 selection.setPosition(null, 0); 13 13 selection.modify("move", "right", "-webkit-visual-word"); 14 14 document.body.innerHTML = "Crash test passed"; -
trunk/LayoutTests/fast/dom/DOMImplementation/detached-doctype.html
r120792 r203941 15 15 16 16 var o = document.implementation.createDocumentType('x', null, null); 17 var doc = document.implementation.createDocument("doc", null, 0);17 var doc = document.implementation.createDocument("doc", null, null); 18 18 for (i in o) { 19 19 try { o[i]; } catch (e) {} -
trunk/LayoutTests/fast/dom/MutationObserver/observe-attributes.html
r155265 r203941 596 596 debug('Testing that attributeFilter respects case with non-HTML elements.'); 597 597 598 svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', 'svg');598 svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null); 599 599 mutations = null; 600 600 observer = new MutationObserver(function(m) { -
trunk/LayoutTests/fast/dom/Node/contains-method-expected.txt
r94898 r203941 13 13 PASS test1.contains(test1) is true 14 14 PASS test1TextChild.contains(test1TextChild) is true 15 PASS test1.contains(123) is false15 PASS test1.contains(123) threw exception TypeError: Argument 1 ('other') to Node.contains must be an instance of Node. 16 16 PASS test1.contains(null) is false 17 17 PASS document.contains(iframe) is false -
trunk/LayoutTests/fast/dom/Node/script-tests/contains-method.js
r98407 r203941 15 15 shouldBeTrue("test1.contains(test1)"); 16 16 shouldBeTrue("test1TextChild.contains(test1TextChild)"); 17 should BeFalse("test1.contains(123)");17 shouldThrow("test1.contains(123)"); 18 18 shouldBeFalse("test1.contains(null)"); 19 19 -
trunk/LayoutTests/fast/dom/Window/webkitConvertPoint.html
r155265 r203941 114 114 115 115 debug("Test parameter passing - should not crash"); 116 var point = webkitConvertPointFromNodeToPage(new WebKitPoint(0, 0)); 117 if (point == null) 118 testPassed("Missing parameter test"); 119 else 120 testFailed("Missing parameter test"); 121 debug("Test did not crash and therefore was successful"); 116 shouldThrow("webkitConvertPointFromNodeToPage(new WebKitPoint(0, 0))"); 122 117 debug(""); 123 118 point = webkitConvertPointFromNodeToPage(null, new WebKitPoint(0, 0)); -
trunk/LayoutTests/fast/dom/adopt-node-crash-2.html
r135914 r203941 26 26 testRunner.notifyDone(); 27 27 } 28 document.addEventListener("DOMContentLoaded", setTimeout("doit()", 1), false); 28 document.addEventListener("DOMContentLoaded", function() { 29 setTimeout("doit()", 1); 30 }, false); 29 31 </script> 30 32 </html> -
trunk/LayoutTests/fast/dom/incompatible-operations-expected.txt
r200696 r203941 7 7 PASS aNode.appendChild('knort') threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node. 8 8 PASS aNode.appendChild(void 0) threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node. 9 PASS aNode.isSameNode(aDOMImplementation) is false10 PASS aNode.isSameNode('foo') is false9 PASS aNode.isSameNode(aDOMImplementation) threw exception TypeError: Argument 1 ('other') to Node.isSameNode must be an instance of Node. 10 PASS aNode.isSameNode('foo') threw exception TypeError: Argument 1 ('other') to Node.isSameNode must be an instance of Node. 11 11 PASS aNode.isSameNode(void 0) is false 12 12 PASS aNode.lookupPrefix(aDOMImplementation) is null -
trunk/LayoutTests/fast/dom/incompatible-operations.html
r200696 r203941 35 35 shouldThrow("aNode.appendChild(void 0)"); 36 36 37 should BeFalse("aNode.isSameNode(aDOMImplementation)");38 should BeFalse("aNode.isSameNode('foo')");37 shouldThrow("aNode.isSameNode(aDOMImplementation)"); 38 shouldThrow("aNode.isSameNode('foo')"); 39 39 shouldBeFalse("aNode.isSameNode(void 0)"); 40 40 shouldBe("aNode.lookupPrefix(aDOMImplementation)", "null"); -
trunk/LayoutTests/fast/events/selectstart-by-arrow-keys.html
r120792 r203941 40 40 // On Mac, home/end doesn't move caret so manually select " World". 41 41 if (navigator.platform.indexOf('Mac') == 0) 42 window.getSelection().setBaseAndExtent(div.firstChild, div.textContent.indexOf('World') , div.textContent.length);42 window.getSelection().setBaseAndExtent(div.firstChild, div.textContent.indexOf('World')); 43 43 44 44 eventSender.keyDown("leftArrow"); -
trunk/LayoutTests/fast/images/image-copy-memory-usage.html
r194326 r203941 42 42 // the copy and also finish the test. setTimeout() is used with a zero delay in order to cause this to 43 43 // run after the copy is finished. 44 document.getElementById("animationFrame").contentWindow.document.addEventListener("copy", 44 document.getElementById("animationFrame").contentWindow.document.addEventListener("copy", function() { 45 45 setTimeout( 46 46 function() … … 51 51 window.finishJSTest(); 52 52 }, 53 0) ,53 0) }, 54 54 false); 55 55 -
trunk/LayoutTests/fast/xsl/xslt-processor-expected.txt
r152685 r203941 61 61 Success 62 62 2.3 use non-DOMDocument output parameter: 63 ****Failure**** (expected exception, instead got result: "null") 63 Success 64 64 2.4 transform to same fragment twice: 65 65 Success -
trunk/LayoutTests/http/tests/misc/webtiming-cross-origin-and-back1.html
r177283 r203941 8 8 window.location = "http://127.0.0.1:8000/misc/resources/webtiming-cross-origin-and-back-redirect1.php"; 9 9 } 10 addEventListener("load", setTimeout(doRedirect, 0)); 10 addEventListener("load", function() { 11 setTimeout(doRedirect, 0); 12 }); 11 13 </script> 12 14 </head> -
trunk/LayoutTests/imported/w3c/ChangeLog
r203935 r203941 1 2016-07-30 Chris Dumez <cdumez@apple.com> 2 3 [WebIDL] Enable strict type checking for operations' nullable parameters of wrapper types 4 https://bugs.webkit.org/show_bug.cgi?id=160374 5 6 Reviewed by Youenn Fablet. 7 8 Rebaseline W3C test now that one more check is passing. 9 10 * web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt: 11 1 12 2016-07-29 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt
r203517 r203941 268 268 PASS createDocument test 154: metadata for "foo:","xmlfoo:bar",null 269 269 PASS createDocument test 154: characterSet aliases for "foo:","xmlfoo:bar",null 270 FAIL createDocument test 155: null,null,false,object "TypeError" assert_throws: function "function () { document.implementation.createDocument(name..." did not throw 270 PASS createDocument test 155: null,null,false,object "TypeError" 271 271 PASS createDocument test 156: null,null,null,null 272 272 PASS createDocument test 156: metadata for null,null,null -
trunk/LayoutTests/platform/mac/fast/dom/Window/webkitConvertPoint-expected.txt
r161884 r203941 28 28 29 29 Test parameter passing - should not crash 30 PASS Missing parameter test 31 Test did not crash and therefore was successful 30 PASS webkitConvertPointFromNodeToPage(new WebKitPoint(0, 0)) threw exception TypeError: Argument 1 ('node') to Window.webkitConvertPointFromNodeToPage must be an instance of Node. 32 31 33 32 PASS null parameter test a -
trunk/LayoutTests/svg/custom/unicode-in-tspan-multi-svg-crash.html
r195411 r203941 15 15 filterInFirstRoot = document.getElementById('filterInFirstRoot'); 16 16 useElement = document.getElementById('useElement'); 17 window.getSelection().setBaseAndExtent(filterInFirstRoot, useElement, 5);17 window.getSelection().setBaseAndExtent(filterInFirstRoot, 0); 18 18 document.execCommand('ForwardDelete'); 19 19 document.designMode='off'; -
trunk/Source/WebCore/ChangeLog
r203935 r203941 1 2016-07-30 Chris Dumez <cdumez@apple.com> 2 3 [WebIDL] Enable strict type checking for operations' nullable parameters of wrapper types 4 https://bugs.webkit.org/show_bug.cgi?id=160374 5 6 Reviewed by Youenn Fablet. 7 8 Enable strict type checking for operations' nullable parameters of 9 wrapper types to comply with the Web IDL specification: 10 - http://heycam.github.io/webidl/#es-nullable-type 11 - http://heycam.github.io/webidl/#es-interface 12 13 For such parameters, if the JS passes a value that is not null / 14 undefined and does not have the expected wrapper type, then we now 15 throw a TypeError instead of silently converting the value to null. 16 17 This behavior is consistent with Chrome and Firefox. It also helps 18 identify bugs in JavaScript code. 19 20 No new tests, rebaselined existing tests. 21 22 * bindings/scripts/CodeGeneratorJS.pm: 23 (GenerateParametersCheck): 24 * bindings/scripts/test/JS/JSTestObj.cpp: 25 (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper): 26 (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull): 27 (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver): 28 (WebCore::jsTestObjPrototypeFunctionOverloadedMethod1): 29 (WebCore::jsTestObjPrototypeFunctionOverloadedMethod2): 30 (WebCore::jsTestObjPrototypeFunctionOverloadedMethod6): 31 (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1): 32 (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2): 33 (WebCore::jsTestObjPrototypeFunctionConvert2): 34 (WebCore::jsTestObjPrototypeFunctionStrictFunctionWithSequence): 35 (WebCore::jsTestObjPrototypeFunctionConditionalMethod3): Deleted. 36 (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5): Deleted. 37 (WebCore::jsTestObjPrototypeFunctionOverloadedMethod): Deleted. 38 (WebCore::jsTestObjPrototypeFunctionOrange): Deleted. 39 1 40 2016-07-29 Chris Dumez <cdumez@apple.com> 2 41 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r203858 r203941 3751 3751 my $shouldPassByReference = $isTearOff || ShouldPassWrapperByReference($parameter, $interface); 3752 3752 3753 if ( $function->signature->extendedAttributes->{"StrictTypeChecking"} &&!$shouldPassByReference && $codeGenerator->IsWrapperType($type)) {3753 if (!$shouldPassByReference && $codeGenerator->IsWrapperType($type)) { 3754 3754 $implIncludes{"<runtime/Error.h>"} = 1; 3755 3755 my $checkedArgument = "state->argument($argumentIndex)"; … … 3760 3760 push(@$outputArray, " $name = $nativeValue;\n"); 3761 3761 if ($mayThrowException) { 3762 push(@$outputArray, " if (UNLIKELY(state->hadException()))\n");3763 push(@$outputArray, " return JSValue::encode(jsUndefined());\n");3762 push(@$outputArray, " if (UNLIKELY(state->hadException()))\n"); 3763 push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); 3764 3764 } 3765 3765 push(@$outputArray, " if (UNLIKELY(!$name))\n"); 3766 3766 push(@$outputArray, " return throwArgumentTypeError(*state, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n"); 3767 3767 push(@$outputArray, " }\n"); 3768 $value = "WTFMove($name)"; 3768 3769 } else { 3769 3770 if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($type, $parameter->default)) { … … 4296 4297 "Date" => "double", 4297 4298 "Dictionary" => "Dictionary", 4299 "EventListener" => "RefPtr<EventListener>", 4298 4300 "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", 4299 4301 "XPathNSResolver" => "RefPtr<XPathNSResolver>", -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r203858 r203941 5029 5029 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 5030 5030 auto& impl = castedThis->wrapped(); 5031 auto obj = JSTestObj::toWrapped(state->argument(0)); 5031 TestObj* obj = nullptr; 5032 if (!state->argument(0).isUndefinedOrNull()) { 5033 obj = JSTestObj::toWrapped(state->uncheckedArgument(0)); 5034 if (UNLIKELY(!obj)) 5035 return throwArgumentTypeError(*state, 0, "obj", "TestObject", "methodWithOptionalNullableWrapper", "TestObj"); 5036 } 5032 5037 impl.methodWithOptionalNullableWrapper(WTFMove(obj)); 5033 5038 return JSValue::encode(jsUndefined()); … … 5042 5047 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 5043 5048 auto& impl = castedThis->wrapped(); 5044 auto obj = JSTestObj::toWrapped(state->argument(0)); 5049 TestObj* obj = nullptr; 5050 if (!state->argument(0).isUndefinedOrNull()) { 5051 obj = JSTestObj::toWrapped(state->uncheckedArgument(0)); 5052 if (UNLIKELY(!obj)) 5053 return throwArgumentTypeError(*state, 0, "obj", "TestObject", "methodWithOptionalNullableWrapperIsNull", "TestObj"); 5054 } 5045 5055 impl.methodWithOptionalNullableWrapperIsNull(WTFMove(obj)); 5046 5056 return JSValue::encode(jsUndefined()); … … 5055 5065 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 5056 5066 auto& impl = castedThis->wrapped(); 5057 auto resolver = JSXPathNSResolver::toWrapped(*state, state->argument(0)); 5058 if (UNLIKELY(state->hadException())) 5059 return JSValue::encode(jsUndefined()); 5067 RefPtr<XPathNSResolver> resolver = nullptr; 5068 if (!state->argument(0).isUndefinedOrNull()) { 5069 resolver = JSXPathNSResolver::toWrapped(*state, state->uncheckedArgument(0)); 5070 if (UNLIKELY(state->hadException())) 5071 return JSValue::encode(jsUndefined()); 5072 if (UNLIKELY(!resolver)) 5073 return throwArgumentTypeError(*state, 0, "resolver", "TestObject", "methodWithOptionalXPathNSResolver", "XPathNSResolver"); 5074 } 5060 5075 impl.methodWithOptionalXPathNSResolver(WTFMove(resolver)); 5061 5076 return JSValue::encode(jsUndefined()); … … 5250 5265 if (UNLIKELY(state->argumentCount() < 2)) 5251 5266 return throwVMError(state, createNotEnoughArgumentsError(state)); 5252 auto objArg = JSTestObj::toWrapped(state->argument(0)); 5267 TestObj* objArg = nullptr; 5268 if (!state->argument(0).isUndefinedOrNull()) { 5269 objArg = JSTestObj::toWrapped(state->uncheckedArgument(0)); 5270 if (UNLIKELY(!objArg)) 5271 return throwArgumentTypeError(*state, 0, "objArg", "TestObject", "overloadedMethod", "TestObj"); 5272 } 5253 5273 auto strArg = state->argument(1).toWTFString(state); 5254 5274 if (UNLIKELY(state->hadException())) … … 5268 5288 if (UNLIKELY(state->argumentCount() < 1)) 5269 5289 return throwVMError(state, createNotEnoughArgumentsError(state)); 5270 auto objArg = JSTestObj::toWrapped(state->argument(0)); 5290 TestObj* objArg = nullptr; 5291 if (!state->argument(0).isUndefinedOrNull()) { 5292 objArg = JSTestObj::toWrapped(state->uncheckedArgument(0)); 5293 if (UNLIKELY(!objArg)) 5294 return throwArgumentTypeError(*state, 0, "objArg", "TestObject", "overloadedMethod", "TestObj"); 5295 } 5271 5296 auto longArg = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion); 5272 5297 if (UNLIKELY(state->hadException())) … … 5337 5362 if (UNLIKELY(state->argumentCount() < 1)) 5338 5363 return throwVMError(state, createNotEnoughArgumentsError(state)); 5339 auto listArg = JSDOMStringList::toWrapped(*state, state->argument(0)); 5340 if (UNLIKELY(state->hadException())) 5341 return JSValue::encode(jsUndefined()); 5364 RefPtr<DOMStringList> listArg = nullptr; 5365 if (!state->argument(0).isUndefinedOrNull()) { 5366 listArg = JSDOMStringList::toWrapped(*state, state->uncheckedArgument(0)); 5367 if (UNLIKELY(state->hadException())) 5368 return JSValue::encode(jsUndefined()); 5369 if (UNLIKELY(!listArg)) 5370 return throwArgumentTypeError(*state, 0, "listArg", "TestObject", "overloadedMethod", "DOMStringList"); 5371 } 5342 5372 impl.overloadedMethod(WTFMove(listArg)); 5343 5373 return JSValue::encode(jsUndefined()); … … 5494 5524 if (UNLIKELY(state->argumentCount() < 1)) 5495 5525 return throwVMError(state, createNotEnoughArgumentsError(state)); 5496 auto objArg1 = JSTestObj::toWrapped(state->argument(0)); 5497 auto objArg2 = JSTestObj::toWrapped(state->argument(1)); 5526 TestObj* objArg1 = nullptr; 5527 if (!state->argument(0).isUndefinedOrNull()) { 5528 objArg1 = JSTestObj::toWrapped(state->uncheckedArgument(0)); 5529 if (UNLIKELY(!objArg1)) 5530 return throwArgumentTypeError(*state, 0, "objArg1", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj"); 5531 } 5532 TestObj* objArg2 = nullptr; 5533 if (!state->argument(1).isUndefinedOrNull()) { 5534 objArg2 = JSTestObj::toWrapped(state->uncheckedArgument(1)); 5535 if (UNLIKELY(!objArg2)) 5536 return throwArgumentTypeError(*state, 1, "objArg2", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj"); 5537 } 5498 5538 impl.overloadedMethodWithOptionalParameter(WTFMove(objArg1), WTFMove(objArg2)); 5499 5539 return JSValue::encode(jsUndefined()); … … 5510 5550 if (UNLIKELY(state->argumentCount() < 1)) 5511 5551 return throwVMError(state, createNotEnoughArgumentsError(state)); 5512 auto objArg = JSTestObj::toWrapped(state->argument(0)); 5552 TestObj* objArg = nullptr; 5553 if (!state->argument(0).isUndefinedOrNull()) { 5554 objArg = JSTestObj::toWrapped(state->uncheckedArgument(0)); 5555 if (UNLIKELY(!objArg)) 5556 return throwArgumentTypeError(*state, 0, "objArg", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj"); 5557 } 5513 5558 auto longArg = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion); 5514 5559 if (UNLIKELY(state->hadException())) … … 5801 5846 if (UNLIKELY(state->argumentCount() < 1)) 5802 5847 return throwVMError(state, createNotEnoughArgumentsError(state)); 5803 auto value = JSTestNode::toWrapped(state->argument(0)); 5848 TestNode* value = nullptr; 5849 if (!state->argument(0).isUndefinedOrNull()) { 5850 value = JSTestNode::toWrapped(state->uncheckedArgument(0)); 5851 if (UNLIKELY(!value)) 5852 return throwArgumentTypeError(*state, 0, "value", "TestObject", "convert2", "TestNode"); 5853 } 5804 5854 impl.convert2(WTFMove(value)); 5805 5855 return JSValue::encode(jsUndefined()); … … 5922 5972 if (UNLIKELY(state->hadException())) 5923 5973 return JSValue::encode(jsUndefined()); 5924 JSValue result = jsBoolean(impl.strictFunctionWithSequence( objArg, WTFMove(a), ec));5974 JSValue result = jsBoolean(impl.strictFunctionWithSequence(WTFMove(objArg), WTFMove(a), ec)); 5925 5975 5926 5976 setDOMException(state, ec);
Note: See TracChangeset
for help on using the changeset viewer.