Chromium Code Reviews| Index: LayoutTests/http/tests/security/cross-frame-window-to-tostring.html |
| diff --git a/LayoutTests/http/tests/security/cross-frame-window-to-tostring.html b/LayoutTests/http/tests/security/cross-frame-window-to-tostring.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1467253378dc3bee9999f7e2fe189690c5c12b55 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/security/cross-frame-window-to-tostring.html |
| @@ -0,0 +1,86 @@ |
| +<!doctype html> |
| +<script src="/js-test-resources/js-test.js"></script> |
| +<script> |
| +var w; |
| + |
| +window.onload = function() |
| +{ |
| + if (window.testRunner) { |
| + testRunner.dumpAsText(); |
| + testRunner.waitUntilDone(); |
| + } |
| + |
| + shouldBe("window + ''", "'[object Window]'"); |
| + shouldBe("window.toString()", "'[object Window]'"); |
| + shouldBe("Object.prototype.toString.call(window)", "'[object Window]'"); |
|
arv (Not doing code reviews)
2015/05/08 21:42:24
WebIDL does not mention `[object WindowPrototype]`
adamk
2015/05/08 22:03:04
Oh huh, we currently return [object Object] for th
|
| + shouldBe("Window.prototype + ''", "'[object Window]'"); |
| + shouldBe("Window.prototype.toString()", "'[object Window]'"); |
| + shouldBe("Object.prototype.toString.call(Window.prototype)", "'[object Window]'"); |
| + |
| + Object.defineProperty(window, Symbol.toStringTag, { |
| + value: 'iii', |
| + configurable: true, |
| + }); |
| + shouldBe("window + ''", "'[object iii]'"); |
| + shouldBe("window.toString()", "'[object iii]'"); |
| + shouldBe("Object.prototype.toString.call(window)", "'[object iii]'"); |
| + shouldBe("Window.prototype + ''", "'[object Window]'"); |
| + shouldBe("Window.prototype.toString()", "'[object Window]'"); |
| + shouldBe("Object.prototype.toString.call(Window.prototype)", "'[object Window]'"); |
| + delete window[Symbol.toStringTag]; |
| + |
| + Object.defineProperty(Window.prototype, Symbol.toStringTag, { |
| + value: 'jjj', |
| + configurable: true, |
| + }); |
| + shouldBe("window + ''", "'[object jjj]'"); |
| + shouldBe("window.toString()", "'[object jjj]'"); |
| + shouldBe("Object.prototype.toString.call(window)", "'[object jjj]'"); |
| + shouldBe("Window.prototype + ''", "'[object jjj]'"); |
| + shouldBe("Window.prototype.toString()", "'[object jjj]'"); |
| + shouldBe("Object.prototype.toString.call(Window.prototype)", "'[object jjj]'"); |
| + delete Window.prototype[Symbol.toStringTag]; |
| + |
| + debug(""); |
| + debug("Testing local iframe"); |
| + w = document.querySelectorAll('iframe')[0].contentWindow; |
| + |
| + shouldBe("w + ''", "'[object inner]'"); |
| + shouldBe("w.toString()", "'[object inner]'"); |
| + shouldBe("Object.prototype.toString.call(w)", "'[object inner]'"); |
| + |
| + Object.defineProperty(w, Symbol.toStringTag, { |
| + value: 'kkk', |
| + configurable: true, |
| + }); |
| + shouldBe("w + ''", "'[object kkk]'"); |
| + shouldBe("w.toString()", "'[object kkk]'"); |
| + shouldBe("Object.prototype.toString.call(w)", "'[object kkk]'"); |
| + delete w[Symbol.toStringTag]; |
| + |
| + Object.defineProperty(Window.prototype, Symbol.toStringTag, { |
| + value: 'lll', |
| + configurable: true, |
| + }); |
| + shouldBe("w + ''", "'[object inner]'"); |
| + shouldBe("w.toString()", "'[object inner]'"); |
| + shouldBe("Object.prototype.toString.call(w)", "'[object inner]'"); |
| + delete Window.prototype[Symbol.toStringTag]; |
| + |
| + debug(""); |
| + debug("Testing remote iframe"); |
| + w = document.querySelectorAll('iframe')[1].contentWindow; |
| + |
| + shouldThrow("w + ''", "'SecurityError: Blocked a frame with origin \"http://127.0.0.1:8000\" from accessing a cross-origin frame.'"); |
| + shouldThrow("w.toString()", "'SecurityError: Blocked a frame with origin \"http://127.0.0.1:8000\" from accessing a cross-origin frame.'"); |
| + shouldThrow("Object.prototype.toString.call(w)", "'SecurityError: Blocked a frame with origin \"http://127.0.0.1:8000\" from accessing a cross-origin frame.'"); |
| + |
| + if (window.testRunner) |
| + testRunner.notifyDone(); |
| +}; |
| + |
| +</script> |
| + |
| +<iframe src="resources/cross-frame-window-to-string-test.html"></iframe> |
| +<iframe src="http://localhost:8000/security/resources/cross-frame-window-to-string-test.html"></iframe> |
| +<pre id="console"></pre> |