Skip to content

Commit

Permalink
Merge r186265 - REGRESSION (r178097): JavaScript TypeError after clic…
Browse files Browse the repository at this point in the history
…king on compose button in Yahoo Mail

https://bugs.webkit.org/show_bug.cgi?id=146515
<rdar://problem/21348421>

Reviewed by Chris Dumez.

Source/WebCore:

Fixes an issue where extra arguments passed to a Web IDL overloaded function, whose implementation
is generated by the bindings generator script, are not ignored as per the note in section "Interface object [[Call]] method"
of the Web IDL spec, <http://www.w3.org/TR/2012/CR-WebIDL-20120419/> (19 April 2012).

Currently for an overloaded function the JavaScript bindings generator script emits code to
throw a TypeError when it cannot find a candidate function that takes the same number of
arguments as passed by a caller. Prior to the change made in bug #139179 (r178097), the
bindings code for HTMLSelectElement.add() was written by hand and ignored extra arguments
that were passed to it. Following this change, the bindings code for HTMLSelectElement.add()
is generated by the bindings generator script. Therefore, we throw a TypeError when Yahoo Mail
calls HTMLSelectElement.add() with extra arguments because the code emitted by the bindings
generator script does not ignore them.

* bindings/scripts/CodeGeneratorJS.pm:
(LengthOfLongestFunctionParameterList): Added. Computes the length of longest overload parameter list.
(GenerateOverloadedFunction): Emit code that ignores more arguments than LengthOfLongestFunctionParameterList().
(GenerateOverloadedConstructorDefinition): Ditto.
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod12): Added; expected result for an overloaded
function that takes a variadic number of Blob elements.
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod): Update expected result. The added
if-conditional expression for the IDL declaration overloadedMethod(Blob... blobArgs) is empty
because we do not support overloading of functions with variadic arguments.
(WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors5): Added; expected
result for an overloaded constructors that takes a variadic number of long arguments.
(WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors): Update expected
result. The added if-conditional expression for the IDL declaration Constructor(long... longArgs) is empty
because we do not support overloading of constructors with variadic arguments.
* bindings/scripts/test/TestObj.idl: Added declaration overloadedMethod(Blob...). Also fixed
typo in license block text.
* bindings/scripts/test/TestOverloadedConstructors.idl: Added declaration Constructor(long... longArgs).
Also fixed typo in license block text.

LayoutTests:

Add new sub-tests to LayoutTests/fast/dom/HTMLSelectElement/{add, options-collection-add}.html,
simplify existing test code, share common code, and update expected results.

Additionally, update results for tests in LayoutTests/fast/canvas now that we ignore extra
arguments passed to a Web IDL overloaded function whose implementation is generated by the
bindings generator script.

* fast/canvas/canvas-overloads-drawImage-expected.txt:
* fast/canvas/canvas-overloads-setFillColor-expected.txt:
* fast/canvas/canvas-overloads-setShadow-expected.txt:
* fast/canvas/canvas-overloads-setStrokeColor-expected.txt:
* fast/canvas/script-tests/canvas-overloads-drawImage.js:
* fast/canvas/script-tests/canvas-overloads-setFillColor.js:
* fast/canvas/script-tests/canvas-overloads-setShadow.js:
* fast/canvas/script-tests/canvas-overloads-setStrokeColor.js:
* 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:
* fast/dom/HTMLSelectElement/resources/html-select-and-options-collection-utilities.js: Added.
(createSelectElementWithTestData):
(deepCopy):
(createOption):
(createGroup):
  • Loading branch information
dydz authored and carlosgcampos committed Jul 7, 2015
1 parent 4d585f0 commit 6277b35
Show file tree
Hide file tree
Showing 20 changed files with 396 additions and 274 deletions.
33 changes: 33 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,36 @@
2015-07-03 Daniel Bates <dabates@apple.com>

REGRESSION (r178097): JavaScript TypeError after clicking on compose button in Yahoo Mail
https://bugs.webkit.org/show_bug.cgi?id=146515
<rdar://problem/21348421>

Reviewed by Chris Dumez.

Add new sub-tests to LayoutTests/fast/dom/HTMLSelectElement/{add, options-collection-add}.html,
simplify existing test code, share common code, and update expected results.

Additionally, update results for tests in LayoutTests/fast/canvas now that we ignore extra
arguments passed to a Web IDL overloaded function whose implementation is generated by the
bindings generator script.

* fast/canvas/canvas-overloads-drawImage-expected.txt:
* fast/canvas/canvas-overloads-setFillColor-expected.txt:
* fast/canvas/canvas-overloads-setShadow-expected.txt:
* fast/canvas/canvas-overloads-setStrokeColor-expected.txt:
* fast/canvas/script-tests/canvas-overloads-drawImage.js:
* fast/canvas/script-tests/canvas-overloads-setFillColor.js:
* fast/canvas/script-tests/canvas-overloads-setShadow.js:
* fast/canvas/script-tests/canvas-overloads-setStrokeColor.js:
* 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:
* fast/dom/HTMLSelectElement/resources/html-select-and-options-collection-utilities.js: Added.
(createSelectElementWithTestData):
(deepCopy):
(createOption):
(createGroup):

2015-06-30 Ryosuke Niwa <rniwa@webkit.org>

REGRESSION (r179168): Characters overlap after resizing the font on the copy-pasted Japanese text
Expand Down
Expand Up @@ -13,8 +13,8 @@ PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0) threw exception TypeError: Type
PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0) is undefined
PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0) is undefined
PASS ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) is undefined
PASS ctx.drawImage(canvasElement) threw exception TypeError: Not enough arguments.
PASS ctx.drawImage(canvasElement, 0) threw exception TypeError: Not enough arguments.
PASS ctx.drawImage(canvasElement, 0, 0) is undefined
Expand All @@ -24,8 +24,8 @@ PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0) threw exception TypeError: Type
PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0) threw exception Error: IndexSizeError: DOM Exception 1.
PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception Error: IndexSizeError: DOM Exception 1.
PASS ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception Error: IndexSizeError: DOM Exception 1.
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Expand Up @@ -10,7 +10,7 @@ PASS ctx.setFillColor(0, 0) is undefined
PASS ctx.setFillColor(0, 0, 0) threw exception TypeError: Type error.
PASS ctx.setFillColor(0, 0, 0, 0) is undefined
PASS ctx.setFillColor(0, 0, 0, 0, 0) is undefined
PASS ctx.setFillColor(0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.setFillColor(0, 0, 0, 0, 0, 0) is undefined
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Expand Up @@ -16,7 +16,7 @@ PASS ctx.setShadow(0, 0, 0, 0, 'red', 0, 0) is undefined
PASS ctx.setShadow(0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.setShadow(0, 0, 0, 0, 0, 0, 0) is undefined
PASS ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0) is undefined
PASS ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0, 0) is undefined
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Expand Up @@ -10,7 +10,7 @@ PASS ctx.setStrokeColor(0, 0) is undefined
PASS ctx.setStrokeColor(0, 0, 0) threw exception TypeError: Type error.
PASS ctx.setStrokeColor(0, 0, 0, 0) is undefined
PASS ctx.setStrokeColor(0, 0, 0, 0, 0) is undefined
PASS ctx.setStrokeColor(0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
PASS ctx.setStrokeColor(0, 0, 0, 0, 0, 0) is undefined
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Expand Up @@ -16,8 +16,8 @@ shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");

var canvasElement = document.createElement("canvas");
shouldThrow("ctx.drawImage(canvasElement)", "TypeErrorNotEnoughArguments");
Expand All @@ -29,5 +29,5 @@ shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0)", "'Error: IndexSizeError: DOM Exception 1'");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "'Error: IndexSizeError: DOM Exception 1'");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "'Error: IndexSizeError: DOM Exception 1'");
Expand Up @@ -12,4 +12,4 @@ shouldBe("ctx.setFillColor(0, 0)", "undefined");
shouldThrow("ctx.setFillColor(0, 0, 0)", "TypeError");
shouldBe("ctx.setFillColor(0, 0, 0, 0)", "undefined");
shouldBe("ctx.setFillColor(0, 0, 0, 0, 0)", "undefined");
shouldThrow("ctx.setFillColor(0, 0, 0, 0, 0, 0)", "TypeError");
shouldBe("ctx.setFillColor(0, 0, 0, 0, 0, 0)", "undefined");
Expand Up @@ -18,4 +18,4 @@ shouldBe("ctx.setShadow(0, 0, 0, 0, 'red', 0, 0)", "undefined");
shouldThrow("ctx.setShadow(0, 0, 0, 0, 0, 0)", "TypeError");
shouldBe("ctx.setShadow(0, 0, 0, 0, 0, 0, 0)", "undefined");
shouldBe("ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
shouldThrow("ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldBe("ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
Expand Up @@ -12,4 +12,4 @@ shouldBe("ctx.setStrokeColor(0, 0)", "undefined");
shouldThrow("ctx.setStrokeColor(0, 0, 0)", "TypeError");
shouldBe("ctx.setStrokeColor(0, 0, 0, 0)", "undefined");
shouldBe("ctx.setStrokeColor(0, 0, 0, 0, 0)", "undefined");
shouldThrow("ctx.setStrokeColor(0, 0, 0, 0, 0, 0)", "TypeError");
shouldBe("ctx.setStrokeColor(0, 0, 0, 0, 0, 0)", "undefined");
81 changes: 45 additions & 36 deletions LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt
@@ -1,43 +1,52 @@
Test select.add() with index parameter
Test that HTMLSelectElement.add() works when passing an index or an HTML option element as its second argument.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


list elements are = 0,1,2
PASS testAdd1(createOption("Y1")) is "0,1,2,Y1"
PASS testAdd3(createOption("Y2"), null) is "0,1,2,Y2"
PASS testAdd3(createOption("Y3"), 0) is "Y3,0,1,2"
PASS testAdd3(createOption("Y4"), 1) is "0,Y4,1,2"
PASS testAdd3(createOption("Y5"), 2) is "0,1,Y5,2"
PASS testAdd3(createOption("Y6"), 3) is "0,1,2,Y6"
PASS testAdd3(createOption("Y7"), 100) is "0,1,2,Y7"
PASS testAdd3(createOption("Y8"), -100) is "0,1,2,Y8"
PASS testAdd3(createOption("Y9"), "0") is "Y9,0,1,2"
PASS testAdd3(createOption("Y10"), "1") is "0,Y10,1,2"
PASS testAdd3(createOption("Y11"), "2") is "0,1,Y11,2"
PASS testAdd3(createOption("Y12"), true) is "0,Y12,1,2"
PASS testAdd3(createOption("Y13"), false) is "Y13,0,1,2"
PASS testAdd3(createOption("Y14"), 2147483647) is "0,1,2,Y14"
PASS testAdd3(createOption("Y15"), 2147483648) is "0,1,2,Y15"
PASS testAdd3(createOption("Y16"), -2147483647) is "0,1,2,Y16"
PASS testAdd3(createOption("Y17"), -2147483648) is "0,1,2,Y17"
PASS testAdd3(createOption("Y18"), -2147483649) is "0,1,2,Y18"
PASS testAdd3(createOption("Y19"), Infinity) is "Y19,0,1,2"
PASS testAdd3(createOption("Y20"), -Infinity) is "Y20,0,1,2"
PASS testAdd3(createOption("Y21"), "foo") is "Y21,0,1,2"
PASS testAdd3(createOption("Y22"), NaN) is "Y22,0,1,2"
PASS testAdd3(createOption("Y23"), undefined) is "Y23,0,1,2"
PASS testAdd3(createOption("Y24"), -2) is "0,1,2,Y24"
PASS testAdd4(createOption("Y25"), 0, 1) threw exception TypeError: Type error.
PASS testAdd4(createOption("Y25"), mySelect.options[0], 1) threw exception TypeError: Type error.
list elements are = 0,1,2
PASS mySelect.add("foo") threw exception TypeError: Type error.
PASS mySelect.add("foo", 0) threw exception TypeError: Type error.
PASS mySelect.add(undefined) threw exception TypeError: Type error.
PASS mySelect.add(undefined, 0) threw exception TypeError: Type error.
PASS mySelect.add(null, 0) threw exception TypeError: Type error.
PASS mySelect.add(null) threw exception TypeError: Type error.
PASS mySelect.add() threw exception TypeError: Not enough arguments.

Call HTMLSelectElement.add() with zero arguments:
PASS testAdd() threw exception TypeError: Not enough arguments.

Call HTMLSelectElement.add() with one argument:
PASS testAdd(createOption("Y1")) is "0,1,2,Y1"
PASS testAdd("foo") threw exception TypeError: Type error.
PASS testAdd(undefined) threw exception TypeError: Type error.
PASS testAdd(null) threw exception TypeError: Type error.

Call HTMLSelectElement.add() with two arguments:
PASS testAdd(createOption("Y2"), null) is "0,1,2,Y2"
PASS testAdd(createOption("Y3"), 0) is "Y3,0,1,2"
PASS testAdd(createOption("Y4"), 1) is "0,Y4,1,2"
PASS testAdd(createOption("Y5"), 2) is "0,1,Y5,2"
PASS testAdd(createOption("Y6"), 3) is "0,1,2,Y6"
PASS testAdd(createOption("Y7"), 100) is "0,1,2,Y7"
PASS testAdd(createOption("Y8"), -100) is "0,1,2,Y8"
PASS testAdd(createOption("Y9"), "0") is "Y9,0,1,2"
PASS testAdd(createOption("Y10"), "1") is "0,Y10,1,2"
PASS testAdd(createOption("Y11"), "2") is "0,1,Y11,2"
PASS testAdd(createOption("Y12"), true) is "0,Y12,1,2"
PASS testAdd(createOption("Y13"), false) is "Y13,0,1,2"
PASS testAdd(createOption("Y14"), 2147483647) is "0,1,2,Y14"
PASS testAdd(createOption("Y15"), 2147483648) is "0,1,2,Y15"
PASS testAdd(createOption("Y16"), -2147483647) is "0,1,2,Y16"
PASS testAdd(createOption("Y17"), -2147483648) is "0,1,2,Y17"
PASS testAdd(createOption("Y18"), -2147483649) is "0,1,2,Y18"
PASS testAdd(createOption("Y19"), Infinity) is "Y19,0,1,2"
PASS testAdd(createOption("Y20"), -Infinity) is "Y20,0,1,2"
PASS testAdd(createOption("Y21"), "foo") is "Y21,0,1,2"
PASS testAdd(createOption("Y22"), NaN) is "Y22,0,1,2"
PASS testAdd(createOption("Y23"), undefined) is "Y23,0,1,2"
PASS testAdd(createOption("Y24"), -2) is "0,1,2,Y24"
PASS testAdd(createOption("X"), mySelect.options[0]) is "X,0,1,2"
PASS testAdd(createOption("X"), mySelect.options[1]) is "0,X,1,2"
PASS testAdd(createOption("X"), mySelect.options[2]) is "0,1,X,2"
PASS testAdd("foo", 0) threw exception TypeError: Type error.
PASS testAdd(undefined, 0) threw exception TypeError: Type error.
PASS testAdd(null, 0) threw exception TypeError: Type error.

Call HTMLSelectElement.add() with three arguments (when it only takes two arguments):
PASS testAdd(createOption("X"), 0, "unnecessary extra argument - should be ignored") is "X,0,1,2"
PASS testAdd(createOption("X"), mySelect.options[1], "unnecessary extra argument - should be ignored") is "0,X,1,2"
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
120 changes: 49 additions & 71 deletions LayoutTests/fast/dom/HTMLSelectElement/add.html
Expand Up @@ -2,87 +2,65 @@
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/html-select-and-options-collection-utilities.js"></script>
</head>
<body>
<script>
description('Test select.add() with index parameter');

var mySelect;
description("Test that HTMLSelectElement.add() works when passing an index or an HTML option element as its second argument.");

function resetSelection() {
mySelect = document.createElement('select');
mySelect.appendChild(new Option("0", "0", false, false));
mySelect.appendChild(new Option("1", "1", false, false));
mySelect.appendChild(new Option("2", "2", false, false));
}
var mySelect = createSelectElementWithTestData();

function deepCopy() {
var copy = [];
for(var i = 0; i < mySelect.options.length; ++i)
copy.push(mySelect.options[i].value);
return copy.join(",");
}

function createOption(value) {
return new Option(value + "X", value, false, false);
function testAdd()
{
HTMLSelectElement.prototype.add.apply(mySelect, arguments);
var result = deepCopy(mySelect);
mySelect = createSelectElementWithTestData(); // Reset
return result;
}

function testAdd1(element) {
resetSelection();
mySelect.add(element);
return deepCopy();
}
debug("<br>Call HTMLSelectElement.add() with zero arguments:");
shouldThrow("testAdd()");

function testAdd3(newelement, index) {
resetSelection();
mySelect.add(newelement, index);
return deepCopy();
}
debug("<br>Call HTMLSelectElement.add() with one argument:");
shouldBeEqualToString('testAdd(createOption("Y1"))', "0,1,2,Y1");
shouldThrow('testAdd("foo")');
shouldThrow("testAdd(undefined)");
shouldThrow("testAdd(null)");

function testAdd4(newelement, element, index) {
resetSelection();
mySelect.add(newelement, element, index);
return deepCopy();
}
debug("<br>Call HTMLSelectElement.add() with two arguments:");
shouldBeEqualToString('testAdd(createOption("Y2"), null)', "0,1,2,Y2");
shouldBeEqualToString('testAdd(createOption("Y3"), 0)', "Y3,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y4"), 1)', "0,Y4,1,2");
shouldBeEqualToString('testAdd(createOption("Y5"), 2)', "0,1,Y5,2");
shouldBeEqualToString('testAdd(createOption("Y6"), 3)', "0,1,2,Y6");
shouldBeEqualToString('testAdd(createOption("Y7"), 100)', "0,1,2,Y7");
shouldBeEqualToString('testAdd(createOption("Y8"), -100)', "0,1,2,Y8");
shouldBeEqualToString('testAdd(createOption("Y9"), "0")', "Y9,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y10"), "1")', "0,Y10,1,2");
shouldBeEqualToString('testAdd(createOption("Y11"), "2")', "0,1,Y11,2");
shouldBeEqualToString('testAdd(createOption("Y12"), true)', "0,Y12,1,2");
shouldBeEqualToString('testAdd(createOption("Y13"), false)', "Y13,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y14"), 2147483647)', "0,1,2,Y14");
shouldBeEqualToString('testAdd(createOption("Y15"), 2147483648)', "0,1,2,Y15");
shouldBeEqualToString('testAdd(createOption("Y16"), -2147483647)', "0,1,2,Y16");
shouldBeEqualToString('testAdd(createOption("Y17"), -2147483648)', "0,1,2,Y17");
shouldBeEqualToString('testAdd(createOption("Y18"), -2147483649)', "0,1,2,Y18");
shouldBeEqualToString('testAdd(createOption("Y19"), Infinity)', "Y19,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y20"), -Infinity)', "Y20,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y21"), "foo")', "Y21,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y22"), NaN)', "Y22,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', "Y23,0,1,2");
shouldBeEqualToString('testAdd(createOption("Y24"), -2)', "0,1,2,Y24");
shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[0])', "X,0,1,2");
shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[1])', "0,X,1,2");
shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[2])', "0,1,X,2");
shouldThrow('testAdd("foo", 0)', "'TypeError: Type error'");
shouldThrow('testAdd(undefined, 0)', "'TypeError: Type error'");
shouldThrow('testAdd(null, 0)', "'TypeError: Type error'");

resetSelection();
debug('list elements are = ' + deepCopy());
shouldBeEqualToString('testAdd1(createOption("Y1"))', '0,1,2,Y1');
shouldBeEqualToString('testAdd3(createOption("Y2"), null)', '0,1,2,Y2');
shouldBeEqualToString('testAdd3(createOption("Y3"), 0)', 'Y3,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y4"), 1)', '0,Y4,1,2');
shouldBeEqualToString('testAdd3(createOption("Y5"), 2)', '0,1,Y5,2');
shouldBeEqualToString('testAdd3(createOption("Y6"), 3)', '0,1,2,Y6');
shouldBeEqualToString('testAdd3(createOption("Y7"), 100)', '0,1,2,Y7');
shouldBeEqualToString('testAdd3(createOption("Y8"), -100)', '0,1,2,Y8');
shouldBeEqualToString('testAdd3(createOption("Y9"), "0")', 'Y9,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y10"), "1")', '0,Y10,1,2');
shouldBeEqualToString('testAdd3(createOption("Y11"), "2")', '0,1,Y11,2');
shouldBeEqualToString('testAdd3(createOption("Y12"), true)', '0,Y12,1,2');
shouldBeEqualToString('testAdd3(createOption("Y13"), false)', 'Y13,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y14"), 2147483647)', '0,1,2,Y14');
shouldBeEqualToString('testAdd3(createOption("Y15"), 2147483648)', '0,1,2,Y15');
shouldBeEqualToString('testAdd3(createOption("Y16"), -2147483647)', '0,1,2,Y16');
shouldBeEqualToString('testAdd3(createOption("Y17"), -2147483648)', '0,1,2,Y17');
shouldBeEqualToString('testAdd3(createOption("Y18"), -2147483649)', '0,1,2,Y18');
shouldBeEqualToString('testAdd3(createOption("Y19"), Infinity)', 'Y19,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y20"), -Infinity)', 'Y20,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y21"), "foo")', 'Y21,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y22"), NaN)', 'Y22,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y23"), undefined)', 'Y23,0,1,2');
shouldBeEqualToString('testAdd3(createOption("Y24"), -2)','0,1,2,Y24');
shouldThrow('testAdd4(createOption("Y25"), 0, 1)');
shouldThrow('testAdd4(createOption("Y25"), mySelect.options[0], 1)');
resetSelection();
debug('list elements are = ' + deepCopy());
shouldThrow('mySelect.add("foo")');
shouldThrow('mySelect.add("foo", 0)');
shouldThrow('mySelect.add(undefined)');
shouldThrow('mySelect.add(undefined, 0)');
shouldThrow('mySelect.add(null, 0)');
shouldThrow('mySelect.add(null)');
shouldThrow('mySelect.add()');

debug("<br>Call HTMLSelectElement.add() with three arguments (when it only takes two arguments):");
shouldBeEqualToString('testAdd(createOption("X"), 0, "unnecessary extra argument - should be ignored")', "X,0,1,2");
shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[1], "unnecessary extra argument - should be ignored")', "0,X,1,2");
</script>
</body>
</html>

0 comments on commit 6277b35

Please sign in to comment.