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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/rel-noopener/window-open.html

Issue 2379313002: Fix 'noopener' targeting and return value. (Closed)
Patch Set: Rebase Created 4 years, 2 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: third_party/WebKit/LayoutTests/http/tests/security/rel-noopener/window-open.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/rel-noopener/window-open.html b/third_party/WebKit/LayoutTests/http/tests/security/rel-noopener/window-open.html
new file mode 100644
index 0000000000000000000000000000000000000000..5b68b3e79d072bb450014eaa44b7c3d1e6d2275d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/rel-noopener/window-open.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ if (window.testRunner)
+ testRunner.setCanOpenWindows();
+
+ var windowsInThisProcess = 1; // This window counts.
+
+ test(t => {
+ var w = window.open("", "", "noopener");
+ assert_equals(w, null);
+ if (window.testRunner)
+ assert_equals(testRunner.windowCount(), windowsInThisProcess, "Should have opened a window in a new process.");
+ }, "window.open returns 'null' when 'noopener' present.");
+
+ test(t => {
+ var w1 = window.open("", "windowname1", "noopener");
+ if (window.testRunner)
+ assert_equals(testRunner.windowCount(), windowsInThisProcess, "Should have opened a window in a new process.");
+ var w2 = window.open("", "windowname1");
+ if (window.testRunner)
+ assert_equals(testRunner.windowCount(), ++windowsInThisProcess, "Should have opened a window in this process.");
+ assert_equals(w1, null);
+ assert_not_equals(w2, null);
+ }, "Opening a named window as noopener, then normally should work.");
+
+ test(t => {
+ var w1 = window.open("", "windowname2");
+ if (window.testRunner)
+ assert_equals(testRunner.windowCount(), ++windowsInThisProcess, "Should have opened a window in this process.");
+ var w2 = window.open("", "windowname2", "noopener");
+ if (window.testRunner)
+ assert_equals(testRunner.windowCount(), windowsInThisProcess, "Should have opened a window a new process.");
+ assert_not_equals(w1, null);
+ assert_equals(w2, null);
+ }, "Opening a named window normally, then as noopener should work.");
+</script>

Powered by Google App Engine
This is Rietveld 408576698