OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Throwing in the context of an accessor setter (235223)</title> |
| 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <script type="text/javascript"> |
| 10 var frame = document.createElement('iframe'); |
| 11 document.body.appendChild(frame); |
| 12 var frameWindow = frame.contentWindow; |
| 13 |
| 14 function assert_dom_exception_in_frame(exception) { |
| 15 assert_equals(frameWindow.DOMException.prototype, Object.getPrototypeOf(exce
ption)); |
| 16 assert_not_equals(DOMException.prototype, Object.getPrototypeOf(exception)); |
| 17 } |
| 18 |
| 19 test(function () { |
| 20 // Sanity check over functions. |
| 21 try { |
| 22 var element = frameWindow.document.createElement('textarea'); |
| 23 element.appendChild(element); |
| 24 assert_unreached("Cyclic appendChild() should throw HierarchyRequestErro
r."); |
| 25 } catch (e) { |
| 26 assert_true(e.name == "HierarchyRequestError"); |
| 27 assert_dom_exception_in_frame(e); |
| 28 } |
| 29 }, "Check that exception is created in called function's context."); |
| 30 |
| 31 test(function () { |
| 32 try { |
| 33 var i = frameWindow.document.createElement('input'); |
| 34 i.size = 0; |
| 35 assert_unreached("Setting input.size to zero should throw IndexSizeError
."); |
| 36 } catch (e) { |
| 37 assert_true(e.name == "IndexSizeError"); |
| 38 assert_dom_exception_in_frame(e); |
| 39 } |
| 40 try { |
| 41 var xhr = new frameWindow.XMLHttpRequest(); |
| 42 xhr.open('GET', 'nonExistent.html', false); |
| 43 xhr.timeout = 10; |
| 44 assert_unreached("Setting xhr.timeout on sync XHR object should throw In
validAccessError."); |
| 45 } catch (e) { |
| 46 assert_true(e.name == "InvalidAccessError"); |
| 47 assert_dom_exception_in_frame(e); |
| 48 } |
| 49 }, "Check that DOM exception is created in setter's context."); |
| 50 |
| 51 test(function () { |
| 52 try { |
| 53 var serializer = new frameWindow.XMLSerializer(); |
| 54 serializer.serializeToString(null); |
| 55 assert_unreached("serializing null should throw a TypeError"); |
| 56 } catch (e) { |
| 57 assert_true(e.name == "TypeError"); |
| 58 assert_equals(frameWindow.TypeError.prototype, Object.getPrototypeOf(e))
; |
| 59 assert_not_equals(TypeError.prototype, Object.getPrototypeOf(e)); |
| 60 } |
| 61 }, "Check that native exception is created in setter's context."); |
| 62 </script> |
| 63 </body> |
| 64 </html> |
OLD | NEW |