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

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: Fix one test line 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..368d9c9684089d48f54daf6f9152641639940fef
--- /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]'");
jsbell 2015/05/11 16:18:09 These could use shouldBeEqualToString to avoid dou
+ shouldBe("window.toString()", "'[object Window]'");
+ shouldBe("Object.prototype.toString.call(window)", "'[object Window]'");
+ shouldBe("Window.prototype + ''", "'[object WindowPrototype]'");
+ shouldBe("Window.prototype.toString()", "'[object WindowPrototype]'");
+ shouldBe("Object.prototype.toString.call(Window.prototype)", "'[object WindowPrototype]'");
+
+ 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 WindowPrototype]'");
+ shouldBe("Window.prototype.toString()", "'[object WindowPrototype]'");
+ shouldBe("Object.prototype.toString.call(Window.prototype)", "'[object WindowPrototype]'");
+ 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>

Powered by Google App Engine
This is Rietveld 408576698