Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: LayoutTests/http/tests/security/cross-frame-window-to-tostring.html

Issue 1138583002: Make Window.prototype.toString return [object Window] at all times. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: shouldBeEqualToString Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f7a5ee10fa9588d259915f7b7e2287fb65aad2f0
--- /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();
+ }
+
+ shouldBeEqualToString("window + ''", "[object Window]");
+ shouldBeEqualToString("window.toString()", "[object Window]");
+ shouldBeEqualToString("Object.prototype.toString.call(window)", "[object Window]");
+ shouldBeEqualToString("Window.prototype + ''", "[object WindowPrototype]");
+ shouldBeEqualToString("Window.prototype.toString()", "[object WindowPrototype]");
+ shouldBeEqualToString("Object.prototype.toString.call(Window.prototype)", "[object WindowPrototype]");
+
+ Object.defineProperty(window, Symbol.toStringTag, {
+ value: 'iii',
+ configurable: true,
+ });
+ shouldBeEqualToString("window + ''", "[object iii]");
+ shouldBeEqualToString("window.toString()", "[object iii]");
+ shouldBeEqualToString("Object.prototype.toString.call(window)", "[object iii]");
+ shouldBeEqualToString("Window.prototype + ''", "[object WindowPrototype]");
+ shouldBeEqualToString("Window.prototype.toString()", "[object WindowPrototype]");
+ shouldBeEqualToString("Object.prototype.toString.call(Window.prototype)", "[object WindowPrototype]");
+ delete window[Symbol.toStringTag];
+
+ Object.defineProperty(Window.prototype, Symbol.toStringTag, {
+ value: 'jjj',
+ configurable: true,
+ });
+ shouldBeEqualToString("window + ''", "[object jjj]");
+ shouldBeEqualToString("window.toString()", "[object jjj]");
+ shouldBeEqualToString("Object.prototype.toString.call(window)", "[object jjj]");
+ shouldBeEqualToString("Window.prototype + ''", "[object jjj]");
+ shouldBeEqualToString("Window.prototype.toString()", "[object jjj]");
+ shouldBeEqualToString("Object.prototype.toString.call(Window.prototype)", "[object jjj]");
+ delete Window.prototype[Symbol.toStringTag];
+
+ debug("");
+ debug("Testing local iframe");
+ w = document.querySelectorAll('iframe')[0].contentWindow;
+
+ shouldBeEqualToString("w + ''", "[object inner]");
+ shouldBeEqualToString("w.toString()", "[object inner]");
+ shouldBeEqualToString("Object.prototype.toString.call(w)", "[object inner]");
+
+ Object.defineProperty(w, Symbol.toStringTag, {
+ value: 'kkk',
+ configurable: true,
+ });
+ shouldBeEqualToString("w + ''", "[object kkk]");
+ shouldBeEqualToString("w.toString()", "[object kkk]");
+ shouldBeEqualToString("Object.prototype.toString.call(w)", "[object kkk]");
+ delete w[Symbol.toStringTag];
+
+ Object.defineProperty(Window.prototype, Symbol.toStringTag, {
+ value: 'lll',
+ configurable: true,
+ });
+ shouldBeEqualToString("w + ''", "[object inner]");
+ shouldBeEqualToString("w.toString()", "[object inner]");
+ shouldBeEqualToString("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>

Powered by Google App Engine
This is Rietveld 408576698