Index: LayoutTests/fast/dom/cross-frame-accessor-throw.html |
diff --git a/LayoutTests/fast/dom/cross-frame-accessor-throw.html b/LayoutTests/fast/dom/cross-frame-accessor-throw.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7245ca571af3a5e0a0405885e2d0532393b4c23f |
--- /dev/null |
+++ b/LayoutTests/fast/dom/cross-frame-accessor-throw.html |
@@ -0,0 +1,64 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<title>Throwing in the context of an accessor setter (235223)</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+</head> |
+<body> |
+<script type="text/javascript"> |
+var frame = document.createElement('iframe'); |
+document.body.appendChild(frame); |
+var frameWindow = frame.contentWindow; |
+ |
+function assert_dom_exception_in_frame(exception) { |
+ assert_equals(frameWindow.DOMException.prototype, Object.getPrototypeOf(exception)); |
+ assert_not_equals(DOMException.prototype, Object.getPrototypeOf(exception)); |
+} |
+ |
+test(function () { |
+ // Sanity check over functions. |
+ try { |
+ var element = frameWindow.document.createElement('textarea'); |
+ element.appendChild(element); |
+ assert_unreached("Cyclic appendChild() should throw HierarchyRequestError."); |
+ } catch (e) { |
+ assert_true(e.name == "HierarchyRequestError"); |
+ assert_dom_exception_in_frame(e); |
+ } |
+}, "Check that exception is created in called function's context."); |
+ |
+test(function () { |
+ try { |
+ var i = frameWindow.document.createElement('input'); |
+ i.size = 0; |
+ assert_unreached("Setting input.size to zero should throw IndexSizeError."); |
+ } catch (e) { |
+ assert_true(e.name == "IndexSizeError"); |
+ assert_dom_exception_in_frame(e); |
+ } |
+ try { |
+ var xhr = new frameWindow.XMLHttpRequest(); |
+ xhr.open('GET', 'nonExistent.html', false); |
+ xhr.timeout = 10; |
+ assert_unreached("Setting xhr.timeout on sync XHR object should throw InvalidAccessError."); |
+ } catch (e) { |
+ assert_true(e.name == "InvalidAccessError"); |
+ assert_dom_exception_in_frame(e); |
+ } |
+}, "Check that DOM exception is created in setter's context."); |
+ |
+test(function () { |
+ try { |
+ var serializer = new frameWindow.XMLSerializer(); |
+ serializer.serializeToString(null); |
+ assert_unreached("serializing null should throw a TypeError"); |
+ } catch (e) { |
+ assert_true(e.name == "TypeError"); |
+ assert_equals(frameWindow.TypeError.prototype, Object.getPrototypeOf(e)); |
+ assert_not_equals(TypeError.prototype, Object.getPrototypeOf(e)); |
+ } |
+}, "Check that native exception is created in setter's context."); |
+</script> |
+</body> |
+</html> |