| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Throwing in the context of an accessor setter (235223)</title> | 4 <title>Throwing in the context of an accessor setter (235223)</title> |
| 5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 </head> | 7 </head> |
| 8 <body> | 8 <body> |
| 9 <script type="text/javascript"> | 9 <script type="text/javascript"> |
| 10 var frame = document.createElement('iframe'); | 10 var frame = document.createElement('iframe'); |
| 11 document.body.appendChild(frame); | 11 document.body.appendChild(frame); |
| 12 var frameWindow = frame.contentWindow; | 12 var frameWindow = frame.contentWindow; |
| 13 | 13 |
| 14 function assert_dom_exception_in_frame(exception) { | 14 function assert_dom_exception_in_frame(exception) { |
| 15 assert_equals(frameWindow.DOMException.prototype, Object.getPrototypeOf(exce
ption)); | 15 assert_equals(frameWindow.DOMException.prototype, Object.getPrototypeOf(exce
ption)); |
| 16 assert_not_equals(DOMException.prototype, Object.getPrototypeOf(exception)); | 16 assert_not_equals(DOMException.prototype, Object.getPrototypeOf(exception)); |
| 17 } | 17 } |
| 18 | 18 |
| 19 function assert_dom_exception_in_incumbent(exception) { |
| 20 assert_not_equals(frameWindow.DOMException.prototype, Object.getPrototypeOf(
exception)); |
| 21 assert_equals(DOMException.prototype, Object.getPrototypeOf(exception)); |
| 22 } |
| 23 |
| 19 test(function () { | 24 test(function () { |
| 20 // Sanity check over functions. | 25 // Sanity check over functions. |
| 21 try { | 26 try { |
| 22 var element = frameWindow.document.createElement('textarea'); | 27 var element = frameWindow.document.createElement('textarea'); |
| 23 element.appendChild(element); | 28 element.appendChild(element); |
| 24 assert_unreached("Cyclic appendChild() should throw HierarchyRequestErro
r."); | 29 assert_unreached("Cyclic appendChild() should throw HierarchyRequestErro
r."); |
| 25 } catch (e) { | 30 } catch (e) { |
| 26 assert_true(e.name == "HierarchyRequestError"); | 31 assert_true(e.name == "HierarchyRequestError"); |
| 27 assert_dom_exception_in_frame(e); | 32 assert_dom_exception_in_frame(e); |
| 28 } | 33 } |
| 29 }, "Check that exception is created in called function's context."); | 34 try { |
| 35 var element = frameWindow.document.createElement('textarea'); |
| 36 Node.prototype.appendChild.call(element, element); |
| 37 assert_unreached("Cyclic appendChild() should throw HierarchyRequestErro
r."); |
| 38 } catch (e) { |
| 39 assert_true(e.name == "HierarchyRequestError"); |
| 40 assert_dom_exception_in_incumbent(e); |
| 41 } |
| 42 }, "Check that DOM exception is created in called function's context."); |
| 30 | 43 |
| 31 test(function () { | 44 test(function () { |
| 32 try { | 45 try { |
| 33 var i = frameWindow.document.createElement('input'); | 46 var input = frameWindow.document.createElement('input'); |
| 34 i.size = 0; | 47 input.size = 0; |
| 35 assert_unreached("Setting input.size to zero should throw IndexSizeError
."); | 48 assert_unreached("Setting input.size to zero should throw IndexSizeError
."); |
| 36 } catch (e) { | 49 } catch (e) { |
| 37 assert_true(e.name == "IndexSizeError"); | 50 assert_true(e.name == "IndexSizeError"); |
| 38 assert_dom_exception_in_frame(e); | 51 assert_dom_exception_in_frame(e); |
| 39 } | 52 } |
| 40 try { | 53 try { |
| 54 var input = frameWindow.document.createElement('input'); |
| 55 var pd = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'si
ze'); |
| 56 pd.set.call(input, 0); |
| 57 assert_unreached("Setting input.size to zero should throw IndexSizeError
."); |
| 58 } catch (e) { |
| 59 assert_true(e.name == "IndexSizeError"); |
| 60 assert_dom_exception_in_incumbent(e); |
| 61 } |
| 62 |
| 63 try { |
| 41 var xhr = new frameWindow.XMLHttpRequest(); | 64 var xhr = new frameWindow.XMLHttpRequest(); |
| 42 xhr.open('GET', 'nonExistent.html', false); | 65 xhr.open('GET', 'nonExistent.html', false); |
| 43 xhr.timeout = 10; | 66 xhr.timeout = 10; |
| 44 assert_unreached("Setting xhr.timeout on sync XHR object should throw In
validAccessError."); | 67 assert_unreached("Setting xhr.timeout on sync XHR object should throw In
validAccessError."); |
| 45 } catch (e) { | 68 } catch (e) { |
| 46 assert_true(e.name == "InvalidAccessError"); | 69 assert_true(e.name == "InvalidAccessError"); |
| 47 assert_dom_exception_in_frame(e); | 70 assert_dom_exception_in_frame(e); |
| 48 } | 71 } |
| 72 try { |
| 73 var xhr = new frameWindow.XMLHttpRequest(); |
| 74 xhr.open('GET', 'nonExistent.html', false); |
| 75 var pd = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'time
out'); |
| 76 pd.set.call(xhr, 10); |
| 77 assert_unreached("Setting xhr.timeout on sync XHR object should throw In
validAccessError."); |
| 78 } catch (e) { |
| 79 assert_true(e.name == "InvalidAccessError"); |
| 80 assert_dom_exception_in_incumbent(e); |
| 81 } |
| 49 }, "Check that DOM exception is created in setter's context."); | 82 }, "Check that DOM exception is created in setter's context."); |
| 50 | 83 |
| 51 test(function () { | 84 test(function () { |
| 52 try { | 85 try { |
| 53 var serializer = new frameWindow.XMLSerializer(); | 86 var serializer = new frameWindow.XMLSerializer(); |
| 54 » serializer.serializeToString(null); | 87 serializer.serializeToString(null); |
| 55 assert_unreached("serializing null should throw a TypeError"); | 88 assert_unreached("serializing null should throw a TypeError"); |
| 56 } catch (e) { | 89 } catch (e) { |
| 57 assert_true(e.name == "TypeError"); | 90 assert_true(e.name == "TypeError"); |
| 58 assert_equals(frameWindow.TypeError.prototype, Object.getPrototypeOf(e))
; | 91 assert_equals(frameWindow.TypeError.prototype, Object.getPrototypeOf(e))
; |
| 59 assert_not_equals(TypeError.prototype, Object.getPrototypeOf(e)); | 92 assert_not_equals(TypeError.prototype, Object.getPrototypeOf(e)); |
| 60 } | 93 } |
| 94 try { |
| 95 var serializer = new frameWindow.XMLSerializer(); |
| 96 XMLSerializer.prototype.serializeToString.call(serializer, null); |
| 97 assert_unreached("serializing null should throw a TypeError"); |
| 98 } catch (e) { |
| 99 assert_true(e.name == "TypeError"); |
| 100 assert_not_equals(frameWindow.TypeError.prototype, Object.getPrototypeOf
(e)); |
| 101 assert_equals(TypeError.prototype, Object.getPrototypeOf(e)); |
| 102 } |
| 61 }, "Check that native exception is created in setter's context."); | 103 }, "Check that native exception is created in setter's context."); |
| 62 </script> | 104 </script> |
| 63 </body> | 105 </body> |
| 64 </html> | 106 </html> |
| OLD | NEW |