Commit 04fc7b0e authored by arv@chromium.org's avatar arv@chromium.org

Replace DOMException TYPE_MISMATCH_ERR with TypeError

https://bugs.webkit.org/show_bug.cgi?id=101604

Reviewed by Adam Barth.

Source/WebCore:

DOMException.TYPE_MISMATCH_ERR is deprecated in favor of using TypeError.

We have historically used TYPE_MISMATCH_ERR as a blanket DOMException code when
the spec mandates TypeError being thrown.

Updated existing tests.

* Modules/mediastream/MediaConstraintsImpl.cpp:
* Modules/mediastream/MediaStreamTrackList.cpp:
* Modules/mediastream/PeerConnection00.cpp:
* Modules/mediastream/RTCDataChannel.cpp:
* Modules/mediastream/RTCIceCandidate.cpp:
* Modules/mediastream/RTCPeerConnection.cpp:
* Modules/mediastream/RTCSessionDescription.cpp:
* Modules/mediastream/SessionDescription.cpp:
* bindings/js/CallbackFunction.cpp:
* bindings/js/JSCustomXPathNSResolver.cpp:
* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
* bindings/js/JSHTMLSelectElementCustom.cpp:
* bindings/js/JSMutationObserverCustom.cpp:
* bindings/js/JSSQLResultSetRowListCustom.cpp:
* bindings/js/JSSQLTransactionCustom.cpp:
* bindings/js/JSSQLTransactionSyncCustom.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
* bindings/scripts/CodeGeneratorObjC.pm:
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/V8Callback.h:
* bindings/v8/V8Collection.cpp:
* bindings/v8/custom/V8DocumentCustom.cpp:
* bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
* bindings/v8/custom/V8MutationObserverCustom.cpp:
* bindings/v8/custom/V8SQLTransactionCustom.cpp:
* bindings/v8/custom/V8SQLTransactionSyncCustom.cpp:
* dom/DOMCoreException.idl:
* html/HTMLElement.cpp:
* html/HTMLMediaElement.cpp:
* html/HTMLOptionsCollection.cpp:
* html/canvas/CanvasRenderingContext2D.cpp:
* page/Crypto.cpp:
* page/DOMSelection.cpp:
* svg/properties/SVGTransformListPropertyTearOff.h:

LayoutTests:

Update the tests to test for TypeError instead of DOMException with the TYPE_MISMATCH_ERR code.

* canvas/philip/tests/2d.drawImage.null.html:
* canvas/philip/tests/2d.imageData.put.null.html:
* canvas/philip/tests/2d.pattern.image.null.html:
* editing/selection/extend-expected.txt:
* fast/dom/Geolocation/argument-types-expected.txt:
* fast/dom/Geolocation/not-enough-arguments-expected.txt:
* fast/dom/Geolocation/script-tests/argument-types.js:
* fast/dom/HTMLSelectElement/select-selectedIndex-expected.txt:
* fast/dom/HTMLSelectElement/select-selectedIndex-multiple-expected.txt:
* fast/js/select-options-add-expected.txt:
* fast/mediastream/RTCIceCandidate-expected.txt:
* fast/mediastream/RTCPeerConnection-expected.txt:
* fast/mediastream/RTCSessionDescription-expected.txt:
* fast/mediastream/SessionDescription-expected.txt:
* fast/mediastream/peerconnection-addstream-expected.txt:
* fast/mediastream/peerconnection-iceoptions-expected.txt:
* fast/mediastream/peerconnection-iceoptions.html:
* fast/mediastream/peerconnection-removestream-expected.txt:
* media/encrypted-media/encrypted-media-syntax.html:
* media/video-test.js:
* platform/chromium/fast/dynamic/insertAdjacentElement-expected.txt:
* security/crypto-random-values-types-expected.txt:
* svg/dom/SVGTransformList-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@134345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d4a2bf71
2012-11-12 Erik Arvidsson <arv@chromium.org>
Replace DOMException TYPE_MISMATCH_ERR with TypeError
https://bugs.webkit.org/show_bug.cgi?id=101604
Reviewed by Adam Barth.
Update the tests to test for TypeError instead of DOMException with the TYPE_MISMATCH_ERR code.
* canvas/philip/tests/2d.drawImage.null.html:
* canvas/philip/tests/2d.imageData.put.null.html:
* canvas/philip/tests/2d.pattern.image.null.html:
* editing/selection/extend-expected.txt:
* fast/dom/Geolocation/argument-types-expected.txt:
* fast/dom/Geolocation/not-enough-arguments-expected.txt:
* fast/dom/Geolocation/script-tests/argument-types.js:
* fast/dom/HTMLSelectElement/select-selectedIndex-expected.txt:
* fast/dom/HTMLSelectElement/select-selectedIndex-multiple-expected.txt:
* fast/js/select-options-add-expected.txt:
* fast/mediastream/RTCIceCandidate-expected.txt:
* fast/mediastream/RTCPeerConnection-expected.txt:
* fast/mediastream/RTCSessionDescription-expected.txt:
* fast/mediastream/SessionDescription-expected.txt:
* fast/mediastream/peerconnection-addstream-expected.txt:
* fast/mediastream/peerconnection-iceoptions-expected.txt:
* fast/mediastream/peerconnection-iceoptions.html:
* fast/mediastream/peerconnection-removestream-expected.txt:
* media/encrypted-media/encrypted-media-syntax.html:
* media/video-test.js:
* platform/chromium/fast/dynamic/insertAdjacentElement-expected.txt:
* security/crypto-random-values-types-expected.txt:
* svg/dom/SVGTransformList-expected.txt:
2012-11-12 Joshua Bell <jsbell@chromium.org>
IndexedDB: storage/indexeddb/cursor-prev-no-duplicate.html is flaky
......@@ -14,7 +14,7 @@ _addTest(function(canvas, ctx) {
try { var _thrown = false;
ctx.drawImage(null, 0, 0);
} catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(null, 0, 0)"); }
} catch (e) { if (e.name != "TypeError") _fail("Failed assertion: expected exception of type TypeError, got: "+e.name); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.drawImage(null, 0, 0)"); }
});
......
......@@ -14,7 +14,7 @@ _addTest(function(canvas, ctx) {
try { var _thrown = false;
ctx.putImageData(null, 0, 0);
} catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.putImageData(null, 0, 0)"); }
} catch (e) { if (e.name != "TypeError") _fail("Failed assertion: expected exception of type TypeError, got: "+e.name); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.putImageData(null, 0, 0)"); }
});
......
......@@ -14,7 +14,7 @@ _addTest(function(canvas, ctx) {
try { var _thrown = false;
ctx.createPattern(null, 'repeat');
} catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.createPattern(null, 'repeat')"); }
} catch (e) { if (e.name != "TypeError") _fail("Failed assertion: expected exception of type TypeError, got: "+e.name); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.createPattern(null, 'repeat')"); }
});
......
......@@ -4,5 +4,5 @@ Success: s.extend(span2.firstChild, 4) raised Error: INDEX_SIZE_ERR: DOM Excepti
Success: s.extend(span2.firstChild, -1) raised Error: INDEX_SIZE_ERR: DOM Exception 1.
Success: window.getSelection() is b.
Success: window.getSelection() is arbaz.
Success: s.extend() raised Error: TYPE_MISMATCH_ERR: DOM Exception 17.
Success: s.extend(null, 0) raised Error: TYPE_MISMATCH_ERR: DOM Exception 17.
Success: s.extend() raised TypeError: Type error.
Success: s.extend(null, 0) raised TypeError: Type error.
......@@ -3,31 +3,31 @@ Tests the acceptable types for arguments to Geolocation methods.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS navigator.geolocation.getCurrentPosition() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition({}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition() threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(undefined) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(null) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition({}) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(objectThrowingException) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(Math.abs) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(testRunner.setGeolocationPermission) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(-Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition("string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(true) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(42) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(Infinity) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(-Infinity) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition("string") threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, null) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, {}) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, Math.abs) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, testRunner.setGeolocationPermission) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, "string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, true) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, 42) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, Infinity) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity) threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, "string") threw exception TypeError: Type error.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, null) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {}) did not throw exception.
......
......@@ -3,8 +3,8 @@ Tests how Geolocation handles receiving too few arguments.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS window.navigator.geolocation.getCurrentPosition() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS window.navigator.geolocation.watchPosition() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS window.navigator.geolocation.getCurrentPosition() threw exception TypeError: Type error.
PASS window.navigator.geolocation.watchPosition() threw exception TypeError: Type error.
PASS window.navigator.geolocation.clearWatch() threw exception TypeError: Not enough arguments.
PASS successfullyParsed is true
......
......@@ -13,9 +13,9 @@ function shouldNotThrow(expression)
function test(expression, expressionShouldThrow, expectedException) {
if (expressionShouldThrow) {
if (expectedException)
shouldThrow(expression, '(function() { return "' + expectedException + '"; })();');
shouldThrow(expression, '"' + expectedException + '"');
else
shouldThrow(expression, '(function() { return "Error: TYPE_MISMATCH_ERR: DOM Exception 17"; })();');
shouldThrow(expression, '"TypeError: Type error"');
} else {
shouldNotThrow(expression);
}
......
......@@ -57,7 +57,7 @@ PASS mySelect.selectedIndex is -1
PASS mySelect.options.length is 10
PASS mySelect.selectedIndex is -1
19) trying to set an element that's not an option: select element
PASS mySelect.options[10] = mySelect; threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS mySelect.options[10] = mySelect; threw exception TypeError: Type error.
PASS mySelect.options.length is 10
PASS mySelect.selectedIndex is -1
20) trying to set a option element using an invalid index: negative infinity
......
......@@ -57,7 +57,7 @@ PASS mySelect.selectedIndex is 0
PASS mySelect.options.length is 10
PASS mySelect.selectedIndex is 0
19) trying to set an element that's not an option: select element
PASS mySelect.options[10] = mySelect; threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS mySelect.options[10] = mySelect; threw exception TypeError: Type error.
PASS mySelect.options.length is 10
PASS mySelect.selectedIndex is 0
20) trying to set a option element using an invalid index: negative infinity
......
......@@ -29,47 +29,47 @@ PASS select1.options[2].value is '3'
PASS select1.options[2].textContent is 'C'
1.4 Add a non-Option element
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.5 Add a non-element (string)
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.6 Add a non-element (number)
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.7 Add a non-element (boolean)
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.8 Add undefined
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.9 Add null
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.10 Add negative infinity
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.11 Add NaN
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
1.12 Add positive infinity
PASS select1.options.add(option1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select1.options.add(option1) threw exception TypeError: Type error.
PASS select1.options.length is 3
PASS select1.selectedIndex is 0
......@@ -163,62 +163,62 @@ PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.9 Add an Option at index -Infinity
PASS select2.options.add(option2, -1/0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, -1/0) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.10 Add an Option at index NaN
PASS select2.options.add(option2, 0/0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 0/0) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.11 Add an Option at index Infinity
PASS select2.options.add(option2, 1/0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1/0) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.12 Add a non-Option element
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.13 Add a non-element (string)
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.14 Add a non-element (number)
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.15 Add a non-element (boolean)
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.16 Add undefined
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.17 Add null
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.18 Add negative infinity
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.19 Add NaN
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
2.20 Add positive infinity
PASS select2.options.add(option2, 1) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
PASS select2.options.length is 7
PASS select2.selectedIndex is 1
......
......@@ -12,7 +12,7 @@ PASS candidate = new RTCIceCandidate(initializer); did not throw exception.
PASS candidate.candidate is "foo"
PASS candidate.sdpMid is "bar"
PASS candidate.sdpMLineIndex is 6
PASS new RTCIceCandidate({}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new RTCIceCandidate({}); threw exception TypeError: Type error.
PASS new RTCIceCandidate(5); threw exception TypeError: Not an object..
PASS new RTCIceCandidate("foobar"); threw exception TypeError: Not an object..
PASS new RTCIceCandidate(candidate:""); threw exception SyntaxError: Unexpected token :.
......
......@@ -14,11 +14,11 @@ PASS new webkitRTCPeerConnection({iceServers:[]}, null); did not throw exception
PASS new webkitRTCPeerConnection({iceServers:[{url:'stun:foo.com'}]}, null); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'}]}, null); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'},{url:'stun:bar.com'}]}, null); did not throw exception.
PASS new webkitRTCPeerConnection({fooServers:[]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection({iceServers:true}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection({iceServers:[{}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection({fooServers:[]}, null); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection({iceServers:true}, null); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}, null); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection({iceServers:[{}]}, null); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception.
......@@ -28,12 +28,12 @@ PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}});
PASS new webkitRTCPeerConnection(null, {mandatory:{invalid:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}}); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]}); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection(null, {optional:[{invalid:0}]}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
PASS new webkitRTCPeerConnection(null, {valid_and_supported_1:1}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new webkitRTCPeerConnection(null, {valid_and_supported_1:1}); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1}); threw exception TypeError: Type error.
PASS new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}}); threw exception TypeError: Type error.
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -10,11 +10,11 @@ PASS initializer = JSON.parse(JSON.stringify(sessionDescription)); did not throw
PASS sessionDescription = new RTCSessionDescription(initializer); did not throw exception.
PASS sessionDescription.type is "offer"
PASS sessionDescription.sdp is "foobar"
PASS new RTCSessionDescription({}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new RTCSessionDescription({}); threw exception TypeError: Type error.
PASS new RTCSessionDescription(5); threw exception TypeError: Not an object..
PASS new RTCSessionDescription('foobar'); threw exception TypeError: Not an object..
PASS new RTCSessionDescription({type:'foobar', sdp:'x'}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new RTCSessionDescription({type:'offer', sdp:''}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS new RTCSessionDescription({type:'foobar', sdp:'x'}); threw exception TypeError: Type error.
PASS new RTCSessionDescription({type:'offer', sdp:''}); threw exception TypeError: Type error.
PASS new RTCSessionDescription({type:'offer', sdp:'x'}); did not throw exception.
PASS new RTCSessionDescription({type:'answer', sdp:'x'}); did not throw exception.
PASS new RTCSessionDescription({type:'pranswer', sdp:'x'}); did not throw exception.
......
......@@ -25,7 +25,7 @@ TEST(video.webkitAddKey('webkit-org.w3.clearkey', null)) THROWS(DOMException.SYN
TEST(video.webkitAddKey('webkit-org.w3.clearkey', undefined)) THROWS(DOMException.SYNTAX_ERR) OK
0-length key is caught before load state is checked.
TEST(video.webkitAddKey('webkit-org.w3.clearkey', new Uint8Array())) THROWS(DOMException.TYPE_MISMATCH_ERR) OK
TEST(video.webkitAddKey('webkit-org.w3.clearkey', new Uint8Array())) THROWS('TypeError') OK
Key system validity is not checked before loading.
TEST(video.webkitGenerateKeyRequest('com.example.invalid')) THROWS(DOMException.INVALID_STATE_ERR) OK
......
......@@ -61,7 +61,7 @@
testException("video.webkitAddKey('webkit-org.w3.clearkey', undefined)", "DOMException.SYNTAX_ERR");
consoleWrite("<br>0-length key is caught before load state is checked.");
testException("video.webkitAddKey('webkit-org.w3.clearkey', new Uint8Array())", "DOMException.TYPE_MISMATCH_ERR");
testError("video.webkitAddKey('webkit-org.w3.clearkey', new Uint8Array())", "'TypeError'");
consoleWrite("<br>Key system validity is not checked before loading.");
testException("video.webkitGenerateKeyRequest('com.example.invalid')", "DOMException.INVALID_STATE_ERR");
......
......@@ -211,6 +211,15 @@ function testException(testString, exceptionString)
}
}
function testError(testString, errorName)
{
try {
eval(testString);
} catch (ex) {
logResult(ex.name == eval(errorName), "TEST(" + testString + ") THROWS("+errorName+")");
}
}
var testEnded = false;
function endTest()
......
Caught expected exception: Error: NOT_SUPPORTED_ERR: DOM Exception 9
Caught expected exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17
Caught expected exception: TypeError: Type error
1 (black) 2 (green) 3 (green) 4 (black)
PASS
......@@ -11,7 +11,7 @@ PASS crypto.getRandomValues(new Uint16Array(3)) is undefined.
PASS crypto.getRandomValues(new Int16Array(3)) is undefined.
PASS crypto.getRandomValues(new Uint32Array(3)) is undefined.
PASS crypto.getRandomValues(new Int32Array(3)) is undefined.
PASS crypto.getRandomValues(new Float32Array(3)) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS crypto.getRandomValues(new Float32Array(3)) threw exception TypeError: Type error.
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -11,8 +11,8 @@ PASS transform.createSVGTransformFromMatrix(svgElement) threw exception TypeErro
PASS transform.createSVGTransformFromMatrix('aString') threw exception TypeError: Type error.
PASS transform.createSVGTransformFromMatrix(1) threw exception TypeError: Type error.
PASS transform.createSVGTransformFromMatrix(true) threw exception TypeError: Type error.
PASS transform.createSVGTransformFromMatrix(undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS transform.createSVGTransformFromMatrix(null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS transform.createSVGTransformFromMatrix(undefined) threw exception TypeError: Type error.
PASS transform.createSVGTransformFromMatrix(null) threw exception TypeError: Type error.
PASS successfullyParsed is true
TEST COMPLETE
......
2012-11-12 Erik Arvidsson <arv@chromium.org>
Replace DOMException TYPE_MISMATCH_ERR with TypeError
https://bugs.webkit.org/show_bug.cgi?id=101604
Reviewed by Adam Barth.
DOMException.TYPE_MISMATCH_ERR is deprecated in favor of using TypeError.
We have historically used TYPE_MISMATCH_ERR as a blanket DOMException code when
the spec mandates TypeError being thrown.
Updated existing tests.
* Modules/mediastream/MediaConstraintsImpl.cpp:
* Modules/mediastream/MediaStreamTrackList.cpp:
* Modules/mediastream/PeerConnection00.cpp:
* Modules/mediastream/RTCDataChannel.cpp:
* Modules/mediastream/RTCIceCandidate.cpp:
* Modules/mediastream/RTCPeerConnection.cpp:
* Modules/mediastream/RTCSessionDescription.cpp:
* Modules/mediastream/SessionDescription.cpp:
* bindings/js/CallbackFunction.cpp:
* bindings/js/JSCustomXPathNSResolver.cpp:
* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
* bindings/js/JSHTMLSelectElementCustom.cpp:
* bindings/js/JSMutationObserverCustom.cpp:
* bindings/js/JSSQLResultSetRowListCustom.cpp:
* bindings/js/JSSQLTransactionCustom.cpp:
* bindings/js/JSSQLTransactionSyncCustom.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
* bindings/scripts/CodeGeneratorObjC.pm:
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/V8Callback.h:
* bindings/v8/V8Collection.cpp:
* bindings/v8/custom/V8DocumentCustom.cpp:
* bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
* bindings/v8/custom/V8MutationObserverCustom.cpp:
* bindings/v8/custom/V8SQLTransactionCustom.cpp:
* bindings/v8/custom/V8SQLTransactionSyncCustom.cpp:
* dom/DOMCoreException.idl:
* html/HTMLElement.cpp:
* html/HTMLMediaElement.cpp:
* html/HTMLOptionsCollection.cpp:
* html/canvas/CanvasRenderingContext2D.cpp:
* page/Crypto.cpp:
* page/DOMSelection.cpp:
* svg/properties/SVGTransformListPropertyTearOff.h:
2012-11-12 Joshua Bell <jsbell@chromium.org>
IndexedDB: Use sequence<> instead of DOMString[] in IDL
......@@ -45,7 +45,7 @@ PassRefPtr<MediaConstraintsImpl> MediaConstraintsImpl::create(const Dictionary&
{
RefPtr<MediaConstraintsImpl> object = adoptRef(new MediaConstraintsImpl());
if (!object->initialize(constraints)) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
return object.release();
......
......@@ -80,7 +80,7 @@ void MediaStreamTrackList::add(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionC
RefPtr<MediaStreamTrack> track = prpTrack;
if (!track) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......@@ -105,7 +105,7 @@ void MediaStreamTrackList::remove(PassRefPtr<MediaStreamTrack> prpTrack, Excepti
RefPtr<MediaStreamTrack> track = prpTrack;
if (!track) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......
......@@ -124,7 +124,7 @@ void RTCDataChannel::setBinaryType(const String& binaryType, ExceptionCode& ec)
else if (binaryType == "arraybuffer")
m_binaryType = BinaryTypeArrayBuffer;
else
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
}
void RTCDataChannel::send(const String& data, ExceptionCode& ec)
......
......@@ -46,7 +46,7 @@ PassRefPtr<RTCIceCandidate> RTCIceCandidate::create(const Dictionary& dictionary
String candidate;
bool ok = dictionary.get("candidate", candidate);
if (!ok || !candidate.length()) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
......
......@@ -69,14 +69,14 @@ PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
ArrayValue iceServers;
bool ok = configuration.get("iceServers", iceServers);
if (!ok || iceServers.isUndefinedOrNull()) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
size_t numberOfServers;
ok = iceServers.length(numberOfServers);
if (!ok) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
......@@ -86,19 +86,19 @@ PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
Dictionary iceServer;
ok = iceServers.get(i, iceServer);
if (!ok) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
String urlString, credential;
ok = iceServer.get("url", urlString);
if (!ok) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
KURL url(KURL(), urlString);
if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("stun"))) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
......@@ -170,7 +170,7 @@ void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su
}
if (!successCallback) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......@@ -190,7 +190,7 @@ void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s
}
if (!successCallback) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......@@ -211,7 +211,7 @@ void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr
RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
if (!sessionDescription) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......@@ -243,7 +243,7 @@ void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p
RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
if (!sessionDescription) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......@@ -294,7 +294,7 @@ void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception
}
if (!iceCandidate) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......@@ -356,7 +356,7 @@ void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti
RefPtr<MediaStream> stream = prpStream;
if (!stream) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......@@ -382,7 +382,7 @@ void RTCPeerConnection::removeStream(MediaStream* stream, ExceptionCode& ec)
}
if (!stream) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return;
}
......
......@@ -50,14 +50,14 @@ PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(const Dictionary
String type;
bool ok = dictionary.get("type", type);
if (!ok || !verifyType(type)) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
String sdp;
ok = dictionary.get("sdp", sdp);
if (!ok || sdp.isEmpty()) {
ec = TYPE_MISMATCH_ERR;
ec = NATIVE_TYPE_ERR;
return 0;
}
......@@ -89,7 +89,7 @@ void RTCSessionDescription::setType(const String& type, ExceptionCode& ec)
if (verifyType(type))
m_descriptor->setType(type);
else