<!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
&lt;rdar://problem/21663919&gt;

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 &quot;new WebSocket(url, undefined)&quot; as WebSocket is
using constructor overloads with optional parameters. Previously, calling
new WebSocket(url, undefined) was equivalent to calling
new WebSocket(url, &quot;undefined&quot;) 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  &lt;cdumez@apple.com&gt;
</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
+        &lt;rdar://problem/21663919&gt;
+
+        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 &quot;new WebSocket(url, undefined)&quot; as WebSocket is
+        using constructor overloads with optional parameters. Previously, calling
+        new WebSocket(url, undefined) was equivalent to calling
+        new WebSocket(url, &quot;undefined&quot;) even though it is supposed to be
+        equivalent to calling new WebSocket(url).
+
+2015-07-03  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</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(&quot;Y20&quot;), -Infinity) is &quot;Y20,0,1,2&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;Y21&quot;), &quot;foo&quot;) is &quot;Y21,0,1,2&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;Y22&quot;), NaN) is &quot;Y22,0,1,2&quot;
</span><del>-PASS testAdd(createOption(&quot;Y23&quot;), undefined) is &quot;Y23,0,1,2&quot;
</del><ins>+PASS testAdd(createOption(&quot;Y23&quot;), undefined) is &quot;0,1,2,Y23&quot;
</ins><span class="cx"> PASS testAdd(createOption(&quot;Y24&quot;), -2) is &quot;0,1,2,Y24&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;X&quot;), mySelect.options[0]) is &quot;X,0,1,2&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;X&quot;), mySelect.options[1]) is &quot;0,X,1,2&quot;
</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(&quot;Y20&quot;), -Infinity)', &quot;Y20,0,1,2&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;Y21&quot;), &quot;foo&quot;)', &quot;Y21,0,1,2&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;Y22&quot;), NaN)', &quot;Y22,0,1,2&quot;);
</span><del>-shouldBeEqualToString('testAdd(createOption(&quot;Y23&quot;), undefined)', &quot;Y23,0,1,2&quot;);
</del><ins>+shouldBeEqualToString('testAdd(createOption(&quot;Y23&quot;), undefined)', &quot;0,1,2,Y23&quot;);
</ins><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;Y24&quot;), -2)', &quot;0,1,2,Y24&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;X&quot;), mySelect.options[0])', &quot;X,0,1,2&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;X&quot;), mySelect.options[1])', &quot;0,X,1,2&quot;);
</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(&quot;Y20&quot;), -Infinity) is &quot;Y20,0,1,2&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;Y21&quot;), &quot;foo&quot;) is &quot;Y21,0,1,2&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;Y22&quot;), NaN) is &quot;Y22,0,1,2&quot;
</span><del>-PASS testAdd(createOption(&quot;Y23&quot;), undefined) is &quot;Y23,0,1,2&quot;
</del><ins>+PASS testAdd(createOption(&quot;Y23&quot;), undefined) is &quot;0,1,2,Y23&quot;
</ins><span class="cx"> PASS testAdd(createOption(&quot;Y24&quot;), -2) is &quot;0,1,2,Y24&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;X&quot;), mySelect.options[0]) is &quot;X,0,1,2&quot;
</span><span class="cx"> PASS testAdd(createOption(&quot;X&quot;), mySelect.options[1]) is &quot;0,X,1,2&quot;
</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(&quot;Y20&quot;), -Infinity)', &quot;Y20,0,1,2&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;Y21&quot;), &quot;foo&quot;)', &quot;Y21,0,1,2&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;Y22&quot;), NaN)', &quot;Y22,0,1,2&quot;);
</span><del>-shouldBeEqualToString('testAdd(createOption(&quot;Y23&quot;), undefined)', &quot;Y23,0,1,2&quot;);
</del><ins>+shouldBeEqualToString('testAdd(createOption(&quot;Y23&quot;), undefined)', &quot;0,1,2,Y23&quot;);
</ins><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;Y24&quot;), -2)', &quot;0,1,2,Y24&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;X&quot;), mySelect.options[0])', &quot;X,0,1,2&quot;);
</span><span class="cx"> shouldBeEqualToString('testAdd(createOption(&quot;X&quot;), mySelect.options[1])', &quot;0,X,1,2&quot;);
</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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+PASS ws.protocol is &quot;&quot;
+Connected
+PASS ws.protocol is &quot;&quot;
+Closed
+PASS ws.protocol is &quot;&quot;
+PASS closeEvent.wasClean is true
+Exited onclose handler
+PASS ws.protocol is &quot;&quot;
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../../../js-test-resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;description&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;script type=&quot;text/javascript&quot;&gt;
+description(&quot;Test that passing undefined as protocols is equivalent to not passing any protocols&quot;);
+
+window.jsTestIsAsync = true;
+
+var ws = new WebSocket(&quot;ws://127.0.0.1:8880/websocket/tests/hybi/simple&quot;, undefined);
+var closeEvent;
+
+shouldBeEqualToString(&quot;ws.protocol&quot;, &quot;&quot;);
+
+ws.onopen = function()
+{
+    debug(&quot;Connected&quot;);
+    shouldBeEqualToString(&quot;ws.protocol&quot;, &quot;&quot;);
+};
+
+ws.onclose = function(event)
+{
+    debug(&quot;Closed&quot;);
+    shouldBeEqualToString(&quot;ws.protocol&quot;, &quot;&quot;);
+    closeEvent = event;
+    shouldBeTrue(&quot;closeEvent.wasClean&quot;);
+    setTimeout(&quot;checkAfterOnClose()&quot;, 0);
+};
+
+function checkAfterOnClose()
+{
+    debug(&quot;Exited onclose handler&quot;);
+    shouldBeEqualToString(&quot;ws.protocol&quot;, &quot;&quot;);
+    finishJSTest();
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../../../js-test-resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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  &lt;cdumez@apple.com&gt;
+
+        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
+        &lt;rdar://problem/21663919&gt;
+
+        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  &lt;mitz@apple.com&gt;
</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, &quot;(${value}.isNull() || ${value}.isFunction())&quot;);
</span><span class="cx">             $usedArguments{$parameterIndex} = 1;
</span><del>-        } elsif ($codeGenerator-&gt;GetArrayType($type) || $codeGenerator-&gt;GetSequenceType($type)) {
-            # FIXME: Add proper support for T[], T[]?, sequence&lt;T&gt;
-            if ($parameter-&gt;isNullable) {
-                push(@andExpression, &quot;(${value}.isNull() || (${value}.isObject() &amp;&amp; isJSArray(${value})))&quot;);
-            } else {
-                push(@andExpression, &quot;(${value}.isObject() &amp;&amp; isJSArray(${value}))&quot;);
-            }
-            $usedArguments{$parameterIndex} = 1;
</del><span class="cx">         } elsif (!IsNativeType($type)) {
</span><del>-            if ($parameter-&gt;isNullable) {
-                push(@andExpression, &quot;(${value}.isNull() || (${value}.isObject() &amp;&amp; asObject(${value})-&gt;inherits(JS${type}::info())))&quot;);
</del><ins>+            my $condition = &quot;&quot;;
+            $condition .= &quot;${value}.isUndefined() || &quot; if $parameter-&gt;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 .= &quot;${value}.isNull() || &quot; if $parameter-&gt;isNullable;
+
+            if ($codeGenerator-&gt;GetArrayType($type) || $codeGenerator-&gt;GetSequenceType($type)) {
+                # FIXME: Add proper support for T[], T[]?, sequence&lt;T&gt;.
+                $condition .= &quot;(${value}.isObject() &amp;&amp; isJSArray(${value}))&quot;;
</ins><span class="cx">             } else {
</span><del>-                push(@andExpression, &quot;(${value}.isObject() &amp;&amp; asObject(${value})-&gt;inherits(JS${type}::info()))&quot;);
</del><ins>+                $condition .= &quot;(${value}.isObject() &amp;&amp; asObject(${value})-&gt;inherits(JS${type}::info()))&quot;;
</ins><span class="cx">             }
</span><ins>+            push(@andExpression, &quot;(&quot; . $condition . &quot;)&quot;);
</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">     { &quot;overloadedMethod&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t) (2) },
</span><ins>+    { &quot;overloadedMethodWithOptionalParameter&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter), (intptr_t) (1) },
</ins><span class="cx">     { &quot;classMethodWithClamp&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionClassMethodWithClamp), (intptr_t) (2) },
</span><span class="cx">     { &quot;methodWithUnsignedLongSequence&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence), (intptr_t) (1) },
</span><span class="cx">     { &quot;stringArrayFunction&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(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 &amp;&amp; (arg0.isNull() || (arg0.isObject() &amp;&amp; isJSArray(arg0)))))
</span><span class="cx">         return jsTestObjPrototypeFunctionOverloadedMethod7(exec);
</span><del>-    if ((argsCount == 1 &amp;&amp; (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSTestObj::info()))))
</del><ins>+    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSTestObj::info())))))
</ins><span class="cx">         return jsTestObjPrototypeFunctionOverloadedMethod8(exec);
</span><del>-    if ((argsCount == 1 &amp;&amp; (arg0.isObject() &amp;&amp; isJSArray(arg0))))
</del><ins>+    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; isJSArray(arg0)))))
</ins><span class="cx">         return jsTestObjPrototypeFunctionOverloadedMethod9(exec);
</span><del>-    if ((argsCount == 1 &amp;&amp; (arg0.isObject() &amp;&amp; isJSArray(arg0))))
</del><ins>+    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; 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-&gt;thisValue();
+    JSTestObj* castedThis = jsDynamicCast&lt;JSTestObj*&gt;(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, &quot;TestObj&quot;, &quot;overloadedMethodWithOptionalParameter&quot;);
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto&amp; impl = castedThis-&gt;impl();
+    if (UNLIKELY(exec-&gt;argumentCount() &lt; 1))
+        return throwVMError(exec, createNotEnoughArgumentsError(exec));
+    TestObj* objArg1 = JSTestObj::toWrapped(exec-&gt;argument(0));
+    if (UNLIKELY(exec-&gt;hadException()))
+        return JSValue::encode(jsUndefined());
+
+    size_t argsCount = exec-&gt;argumentCount();
+    if (argsCount &lt;= 1) {
+        impl.overloadedMethodWithOptionalParameter(objArg1);
+        return JSValue::encode(jsUndefined());
+    }
+
+    TestObj* objArg2 = JSTestObj::toWrapped(exec-&gt;argument(1));
+    if (UNLIKELY(exec-&gt;hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.overloadedMethodWithOptionalParameter(objArg1, objArg2);
+    return JSValue::encode(jsUndefined());
+}
+
+static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(ExecState* exec)
+{
+    JSValue thisValue = exec-&gt;thisValue();
+    JSTestObj* castedThis = jsDynamicCast&lt;JSTestObj*&gt;(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, &quot;TestObj&quot;, &quot;overloadedMethodWithOptionalParameter&quot;);
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto&amp; impl = castedThis-&gt;impl();
+    if (UNLIKELY(exec-&gt;argumentCount() &lt; 1))
+        return throwVMError(exec, createNotEnoughArgumentsError(exec));
+    TestObj* objArg = JSTestObj::toWrapped(exec-&gt;argument(0));
+    if (UNLIKELY(exec-&gt;hadException()))
+        return JSValue::encode(jsUndefined());
+
+    size_t argsCount = exec-&gt;argumentCount();
+    if (argsCount &lt;= 1) {
+        impl.overloadedMethodWithOptionalParameter(objArg);
+        return JSValue::encode(jsUndefined());
+    }
+
+    int longArg = toInt32(exec, exec-&gt;argument(1), NormalConversion);
+    if (UNLIKELY(exec-&gt;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&lt;size_t&gt;(2, exec-&gt;argumentCount());
+    JSValue arg0(exec-&gt;argument(0));
+    JSValue arg1(exec-&gt;argument(1));
+    if ((argsCount == 1 &amp;&amp; (arg0.isNull() || (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSTestObj::info())))) || (argsCount == 2 &amp;&amp; (arg0.isNull() || (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSTestObj::info()))) &amp;&amp; (arg1.isUndefined() || arg1.isNull() || (arg1.isObject() &amp;&amp; asObject(arg1)-&gt;inherits(JSTestObj::info())))))
+        return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(exec);
+    if ((argsCount == 1 &amp;&amp; (arg0.isNull() || (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSTestObj::info())))) || (argsCount == 2 &amp;&amp; (arg0.isNull() || (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSTestObj::info())))))
+        return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(exec);
+    if (argsCount &lt; 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&lt;size_t&gt;(1, exec-&gt;argumentCount());
</span><span class="cx">     JSValue arg0(exec-&gt;argument(0));
</span><del>-    if ((argsCount == 1 &amp;&amp; (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSArrayBuffer::info()))))
</del><ins>+    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSArrayBuffer::info())))))
</ins><span class="cx">         return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1(exec);
</span><del>-    if ((argsCount == 1 &amp;&amp; (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSArrayBufferView::info()))))
</del><ins>+    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSArrayBufferView::info())))))
</ins><span class="cx">         return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2(exec);
</span><del>-    if ((argsCount == 1 &amp;&amp; (arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSBlob::info()))))
</del><ins>+    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; asObject(arg0)-&gt;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>