<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[186275] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/186275">186275</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-07-03 20:56:16 -0700 (Fri, 03 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/178097">r178097</a>): HTMLSelectElement.add(option, undefined) prepends option to the list of options; should append to the end of the list of options
https://bugs.webkit.org/show_bug.cgi?id=146566
<rdar://problem/21663919>
Reviewed by Ryosuke Niwa.
Source/WebCore:
HTMLSelectElement.add(X, undefined) is supposed to be equivalent to
HTMLSelectElement.add(X) which should *append* X. The same is true
for HTMLOptionsCollection.add(X, undefined).
However, due to a bug in our bindings generator for overloaded
operations, the actual behavior was not the expected one. The
second overload would be chosen: add(X, index) and undefined would
be converted as 0-index, which would *prepend* X.
This patch fixes the bindings generator so that undefined is allowed
for optional parameters of an overload operation, when doing the
overload resolution.
Tests:
- fast/dom/HTMLSelectElement/add.html
- fast/dom/HTMLSelectElement/options-collection-add.html
- http/tests/websocket/tests/hybi/undefined-protocol.html
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheckExpression):
Allow undefined value for optional parameters when doing the overload
resolution.
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors):
* bindings/scripts/test/TestObj.idl:
Add bindings tests coverage and rebaseline.
LayoutTests:
* fast/dom/HTMLSelectElement/add-expected.txt:
* fast/dom/HTMLSelectElement/add.html:
* fast/dom/HTMLSelectElement/options-collection-add-expected.txt:
* fast/dom/HTMLSelectElement/options-collection-add.html:
Update tests so that calling add(X, undefined) is expected to append X,
not prepend it.
* http/tests/websocket/tests/hybi/undefined-protocol-expected.txt: Added.
* http/tests/websocket/tests/hybi/undefined-protocol.html: Added.
Add test coverage for "new WebSocket(url, undefined)" as WebSocket is
using constructor overloads with optional parameters. Previously, calling
new WebSocket(url, undefined) was equivalent to calling
new WebSocket(url, "undefined") even though it is supposed to be
equivalent to calling new WebSocket(url).</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLSelectElementaddexpectedtxt">trunk/LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLSelectElementaddhtml">trunk/LayoutTests/fast/dom/HTMLSelectElement/add.html</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLSelectElementoptionscollectionaddexpectedtxt">trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLSelectElementoptionscollectionaddhtml">trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestObjidl">trunk/Source/WebCore/bindings/scripts/test/TestObj.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybiundefinedprotocolexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybiundefinedprotocolhtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/LayoutTests/ChangeLog        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><span class="cx"> 2015-07-03 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><ins>+ REGRESSION (r178097): HTMLSelectElement.add(option, undefined) prepends option to the list of options; should append to the end of the list of options
+ https://bugs.webkit.org/show_bug.cgi?id=146566
+ <rdar://problem/21663919>
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/dom/HTMLSelectElement/add-expected.txt:
+ * fast/dom/HTMLSelectElement/add.html:
+ * fast/dom/HTMLSelectElement/options-collection-add-expected.txt:
+ * fast/dom/HTMLSelectElement/options-collection-add.html:
+ Update tests so that calling add(X, undefined) is expected to append X,
+ not prepend it.
+
+ * http/tests/websocket/tests/hybi/undefined-protocol-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/undefined-protocol.html: Added.
+ Add test coverage for "new WebSocket(url, undefined)" as WebSocket is
+ using constructor overloads with optional parameters. Previously, calling
+ new WebSocket(url, undefined) was equivalent to calling
+ new WebSocket(url, "undefined") even though it is supposed to be
+ equivalent to calling new WebSocket(url).
+
+2015-07-03 Chris Dumez <cdumez@apple.com>
+
</ins><span class="cx"> Unreviewed, skip http/tests/xmlhttprequest/cross-origin-cookie-storage.html on Windows.
</span><span class="cx">
</span><span class="cx"> Windows' DumpRenderTree does not implement testRunner.setAlwaysAcceptCookies().
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLSelectElementaddexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> PASS testAdd(createOption("Y20"), -Infinity) is "Y20,0,1,2"
</span><span class="cx"> PASS testAdd(createOption("Y21"), "foo") is "Y21,0,1,2"
</span><span class="cx"> PASS testAdd(createOption("Y22"), NaN) is "Y22,0,1,2"
</span><del>-PASS testAdd(createOption("Y23"), undefined) is "Y23,0,1,2"
</del><ins>+PASS testAdd(createOption("Y23"), undefined) is "0,1,2,Y23"
</ins><span class="cx"> PASS testAdd(createOption("Y24"), -2) is "0,1,2,Y24"
</span><span class="cx"> PASS testAdd(createOption("X"), mySelect.options[0]) is "X,0,1,2"
</span><span class="cx"> PASS testAdd(createOption("X"), mySelect.options[1]) is "0,X,1,2"
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLSelectElementaddhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLSelectElement/add.html (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLSelectElement/add.html        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/add.html        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y20"), -Infinity)', "Y20,0,1,2");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y21"), "foo")', "Y21,0,1,2");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y22"), NaN)', "Y22,0,1,2");
</span><del>-shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', "Y23,0,1,2");
</del><ins>+shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', "0,1,2,Y23");
</ins><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y24"), -2)', "0,1,2,Y24");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[0])', "X,0,1,2");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[1])', "0,X,1,2");
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLSelectElementoptionscollectionaddexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add-expected.txt (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add-expected.txt        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add-expected.txt        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> PASS testAdd(createOption("Y20"), -Infinity) is "Y20,0,1,2"
</span><span class="cx"> PASS testAdd(createOption("Y21"), "foo") is "Y21,0,1,2"
</span><span class="cx"> PASS testAdd(createOption("Y22"), NaN) is "Y22,0,1,2"
</span><del>-PASS testAdd(createOption("Y23"), undefined) is "Y23,0,1,2"
</del><ins>+PASS testAdd(createOption("Y23"), undefined) is "0,1,2,Y23"
</ins><span class="cx"> PASS testAdd(createOption("Y24"), -2) is "0,1,2,Y24"
</span><span class="cx"> PASS testAdd(createOption("X"), mySelect.options[0]) is "X,0,1,2"
</span><span class="cx"> PASS testAdd(createOption("X"), mySelect.options[1]) is "0,X,1,2"
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLSelectElementoptionscollectionaddhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add.html (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add.html        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add.html        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y20"), -Infinity)', "Y20,0,1,2");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y21"), "foo")', "Y21,0,1,2");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y22"), NaN)', "Y22,0,1,2");
</span><del>-shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', "Y23,0,1,2");
</del><ins>+shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', "0,1,2,Y23");
</ins><span class="cx"> shouldBeEqualToString('testAdd(createOption("Y24"), -2)', "0,1,2,Y24");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[0])', "X,0,1,2");
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[1])', "0,X,1,2");
</span></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybiundefinedprotocolexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol-expected.txt (0 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol-expected.txt        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test that passing undefined as protocols is equivalent to not passing any protocols
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS ws.protocol is ""
+Connected
+PASS ws.protocol is ""
+Closed
+PASS ws.protocol is ""
+PASS closeEvent.wasClean is true
+Exited onclose handler
+PASS ws.protocol is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybiundefinedprotocolhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol.html (0 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol.html         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/undefined-protocol.html        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../../js-test-resources/js-test-pre.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script type="text/javascript">
+description("Test that passing undefined as protocols is equivalent to not passing any protocols");
+
+window.jsTestIsAsync = true;
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple", undefined);
+var closeEvent;
+
+shouldBeEqualToString("ws.protocol", "");
+
+ws.onopen = function()
+{
+ debug("Connected");
+ shouldBeEqualToString("ws.protocol", "");
+};
+
+ws.onclose = function(event)
+{
+ debug("Closed");
+ shouldBeEqualToString("ws.protocol", "");
+ closeEvent = event;
+ shouldBeTrue("closeEvent.wasClean");
+ setTimeout("checkAfterOnClose()", 0);
+};
+
+function checkAfterOnClose()
+{
+ debug("Exited onclose handler");
+ shouldBeEqualToString("ws.protocol", "");
+ finishJSTest();
+}
+
+</script>
+<script src="../../../../js-test-resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/Source/WebCore/ChangeLog        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2015-07-03 Chris Dumez <cdumez@apple.com>
+
+ REGRESSION (r178097): HTMLSelectElement.add(option, undefined) prepends option to the list of options; should append to the end of the list of options
+ https://bugs.webkit.org/show_bug.cgi?id=146566
+ <rdar://problem/21663919>
+
+ Reviewed by Ryosuke Niwa.
+
+ HTMLSelectElement.add(X, undefined) is supposed to be equivalent to
+ HTMLSelectElement.add(X) which should *append* X. The same is true
+ for HTMLOptionsCollection.add(X, undefined).
+
+ However, due to a bug in our bindings generator for overloaded
+ operations, the actual behavior was not the expected one. The
+ second overload would be chosen: add(X, index) and undefined would
+ be converted as 0-index, which would *prepend* X.
+
+ This patch fixes the bindings generator so that undefined is allowed
+ for optional parameters of an overload operation, when doing the
+ overload resolution.
+
+ Tests:
+ - fast/dom/HTMLSelectElement/add.html
+ - fast/dom/HTMLSelectElement/options-collection-add.html
+ - http/tests/websocket/tests/hybi/undefined-protocol.html
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateParametersCheckExpression):
+ Allow undefined value for optional parameters when doing the overload
+ resolution.
+
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):
+ * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+ (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors):
+ * bindings/scripts/test/TestObj.idl:
+ Add bindings tests coverage and rebaseline.
+
</ins><span class="cx"> 2015-07-03 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> Fixed the Mavericks build after r186236.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -1383,20 +1383,22 @@
</span><span class="cx"> # For Callbacks only checks if the value is null or object.
</span><span class="cx"> push(@andExpression, "(${value}.isNull() || ${value}.isFunction())");
</span><span class="cx"> $usedArguments{$parameterIndex} = 1;
</span><del>- } elsif ($codeGenerator->GetArrayType($type) || $codeGenerator->GetSequenceType($type)) {
- # FIXME: Add proper support for T[], T[]?, sequence<T>
- if ($parameter->isNullable) {
- push(@andExpression, "(${value}.isNull() || (${value}.isObject() && isJSArray(${value})))");
- } else {
- push(@andExpression, "(${value}.isObject() && isJSArray(${value}))");
- }
- $usedArguments{$parameterIndex} = 1;
</del><span class="cx"> } elsif (!IsNativeType($type)) {
</span><del>- if ($parameter->isNullable) {
- push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(JS${type}::info())))");
</del><ins>+ my $condition = "";
+ $condition .= "${value}.isUndefined() || " if $parameter->isOptional;
+
+ # FIXME: WebIDL says that undefined is also acceptable for nullable parameters and
+ # should be converted to null:
+ # http://heycam.github.io/webidl/#es-nullable-type
+ $condition .= "${value}.isNull() || " if $parameter->isNullable;
+
+ if ($codeGenerator->GetArrayType($type) || $codeGenerator->GetSequenceType($type)) {
+ # FIXME: Add proper support for T[], T[]?, sequence<T>.
+ $condition .= "(${value}.isObject() && isJSArray(${value}))";
</ins><span class="cx"> } else {
</span><del>- push(@andExpression, "(${value}.isObject() && asObject(${value})->inherits(JS${type}::info()))");
</del><ins>+ $condition .= "(${value}.isObject() && asObject(${value})->inherits(JS${type}::info()))";
</ins><span class="cx"> }
</span><ins>+ push(@andExpression, "(" . $condition . ")");
</ins><span class="cx"> $usedArguments{$parameterIndex} = 1;
</span><span class="cx"> }
</span><span class="cx"> $parameterIndex++;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -129,6 +129,7 @@
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod3(JSC::ExecState*);
</span><span class="cx"> #endif
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*);
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter(JSC::ExecState*);
</ins><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod2(JSC::ExecState*);
</span><span class="lines">@@ -633,6 +634,7 @@
</span><span class="cx"> { 0, 0, NoIntrinsic, 0, 0 },
</span><span class="cx"> #endif
</span><span class="cx"> { "overloadedMethod", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t) (2) },
</span><ins>+ { "overloadedMethodWithOptionalParameter", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter), (intptr_t) (1) },
</ins><span class="cx"> { "classMethodWithClamp", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithClamp), (intptr_t) (2) },
</span><span class="cx"> { "methodWithUnsignedLongSequence", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence), (intptr_t) (1) },
</span><span class="cx"> { "stringArrayFunction", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStringArrayFunction), (intptr_t) (1) },
</span><span class="lines">@@ -3955,11 +3957,11 @@
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod6(exec);
</span><span class="cx"> if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && isJSArray(arg0)))))
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod7(exec);
</span><del>- if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))))
</del><ins>+ if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))))
</ins><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod8(exec);
</span><del>- if ((argsCount == 1 && (arg0.isObject() && isJSArray(arg0))))
</del><ins>+ if ((argsCount == 1 && ((arg0.isObject() && isJSArray(arg0)))))
</ins><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod9(exec);
</span><del>- if ((argsCount == 1 && (arg0.isObject() && isJSArray(arg0))))
</del><ins>+ if ((argsCount == 1 && ((arg0.isObject() && isJSArray(arg0)))))
</ins><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod10(exec);
</span><span class="cx"> if (argsCount == 1)
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod11(exec);
</span><span class="lines">@@ -3970,6 +3972,74 @@
</span><span class="cx"> return throwVMTypeError(exec);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(ExecState* exec)
+{
+ JSValue thisValue = exec->thisValue();
+ JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return throwThisTypeError(*exec, "TestObj", "overloadedMethodWithOptionalParameter");
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+ auto& impl = castedThis->impl();
+ if (UNLIKELY(exec->argumentCount() < 1))
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ TestObj* objArg1 = JSTestObj::toWrapped(exec->argument(0));
+ if (UNLIKELY(exec->hadException()))
+ return JSValue::encode(jsUndefined());
+
+ size_t argsCount = exec->argumentCount();
+ if (argsCount <= 1) {
+ impl.overloadedMethodWithOptionalParameter(objArg1);
+ return JSValue::encode(jsUndefined());
+ }
+
+ TestObj* objArg2 = JSTestObj::toWrapped(exec->argument(1));
+ if (UNLIKELY(exec->hadException()))
+ return JSValue::encode(jsUndefined());
+ impl.overloadedMethodWithOptionalParameter(objArg1, objArg2);
+ return JSValue::encode(jsUndefined());
+}
+
+static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(ExecState* exec)
+{
+ JSValue thisValue = exec->thisValue();
+ JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return throwThisTypeError(*exec, "TestObj", "overloadedMethodWithOptionalParameter");
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+ auto& impl = castedThis->impl();
+ if (UNLIKELY(exec->argumentCount() < 1))
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ TestObj* objArg = JSTestObj::toWrapped(exec->argument(0));
+ if (UNLIKELY(exec->hadException()))
+ return JSValue::encode(jsUndefined());
+
+ size_t argsCount = exec->argumentCount();
+ if (argsCount <= 1) {
+ impl.overloadedMethodWithOptionalParameter(objArg);
+ return JSValue::encode(jsUndefined());
+ }
+
+ int longArg = toInt32(exec, exec->argument(1), NormalConversion);
+ if (UNLIKELY(exec->hadException()))
+ return JSValue::encode(jsUndefined());
+ impl.overloadedMethodWithOptionalParameter(objArg, longArg);
+ return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter(ExecState* exec)
+{
+ size_t argsCount = std::min<size_t>(2, exec->argumentCount());
+ JSValue arg0(exec->argument(0));
+ JSValue arg1(exec->argument(1));
+ if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))) && (arg1.isUndefined() || arg1.isNull() || (arg1.isObject() && asObject(arg1)->inherits(JSTestObj::info())))))
+ return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(exec);
+ if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))))
+ return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(exec);
+ if (argsCount < 1)
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ return throwVMTypeError(exec);
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx"> TestObj::classMethod();
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -152,11 +152,11 @@
</span><span class="cx"> {
</span><span class="cx"> size_t argsCount = std::min<size_t>(1, exec->argumentCount());
</span><span class="cx"> JSValue arg0(exec->argument(0));
</span><del>- if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(JSArrayBuffer::info()))))
</del><ins>+ if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSArrayBuffer::info())))))
</ins><span class="cx"> return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1(exec);
</span><del>- if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(JSArrayBufferView::info()))))
</del><ins>+ if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSArrayBufferView::info())))))
</ins><span class="cx"> return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2(exec);
</span><del>- if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(JSBlob::info()))))
</del><ins>+ if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSBlob::info())))))
</ins><span class="cx"> return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors3(exec);
</span><span class="cx"> if (argsCount == 1)
</span><span class="cx"> return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors4(exec);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (186274 => 186275)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2015-07-04 03:12:45 UTC (rev 186274)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2015-07-04 03:56:16 UTC (rev 186275)
</span><span class="lines">@@ -190,6 +190,9 @@
</span><span class="cx">
</span><span class="cx"> // FIXME: Implement support for overloaded functions with variadic arguments.
</span><span class="cx"> void overloadedMethod(Blob... blobArgs);
</span><ins>+
+ void overloadedMethodWithOptionalParameter(TestObj? objArg1, optional TestObj? objArg2);
+ void overloadedMethodWithOptionalParameter(TestObj? objArg, optional long longArg);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // Class methods within JavaScript (like what's used for IDBKeyRange).
</span></span></pre>
</div>
</div>
</body>
</html>