| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 "frame.sandbox = 'allow-scripts allow-popups';\n" | 2506 "frame.sandbox = 'allow-scripts allow-popups';\n" |
| 2507 "document.body.appendChild(frame);\n"; | 2507 "document.body.appendChild(frame);\n"; |
| 2508 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | 2508 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
| 2509 } | 2509 } |
| 2510 | 2510 |
| 2511 // Navigate iframe to a page with target=_blank links, and rewrite the links | 2511 // Navigate iframe to a page with target=_blank links, and rewrite the links |
| 2512 // to point to valid cross-site URLs. | 2512 // to point to valid cross-site URLs. |
| 2513 GURL frame_url( | 2513 GURL frame_url( |
| 2514 embedded_test_server()->GetURL("a.com", "/click-noreferrer-links.html")); | 2514 embedded_test_server()->GetURL("a.com", "/click-noreferrer-links.html")); |
| 2515 NavigateFrameToURL(root->child_at(0), frame_url); | 2515 NavigateFrameToURL(root->child_at(0), frame_url); |
| 2516 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 2516 std::string script = "setOriginForLinks('http://b.com:" + | 2517 std::string script = "setOriginForLinks('http://b.com:" + |
| 2517 embedded_test_server()->base_url().port() + "/');"; | 2518 embedded_test_server()->base_url().port() + "/');"; |
| 2518 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | 2519 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); |
| 2519 | 2520 |
| 2520 // Helper to click on the 'rel=noreferrer target=_blank' and 'rel=noopener | 2521 // Helper to click on the 'rel=noreferrer target=_blank' and 'rel=noopener |
| 2521 // target=_blank' links. Checks that these links open a popup that ends up | 2522 // target=_blank' links. Checks that these links open a popup that ends up |
| 2522 // in a new SiteInstance even without site-per-process and then verifies that | 2523 // in a new SiteInstance even without site-per-process and then verifies that |
| 2523 // the popup is still sandboxed. | 2524 // the popup is still sandboxed. |
| 2524 auto click_link_and_verify_popup = [this, | 2525 auto click_link_and_verify_popup = [this, |
| 2525 root](std::string link_opening_script) { | 2526 root](std::string link_opening_script) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2543 new_shell->web_contents(), | 2544 new_shell->web_contents(), |
| 2544 "domAutomationController.send(document.origin)", &origin)); | 2545 "domAutomationController.send(document.origin)", &origin)); |
| 2545 EXPECT_EQ("null", origin); | 2546 EXPECT_EQ("null", origin); |
| 2546 }; | 2547 }; |
| 2547 | 2548 |
| 2548 click_link_and_verify_popup("clickNoOpenerTargetBlankLink()"); | 2549 click_link_and_verify_popup("clickNoOpenerTargetBlankLink()"); |
| 2549 click_link_and_verify_popup("clickNoRefTargetBlankLink()"); | 2550 click_link_and_verify_popup("clickNoRefTargetBlankLink()"); |
| 2550 } | 2551 } |
| 2551 | 2552 |
| 2552 } // namespace content | 2553 } // namespace content |
| OLD | NEW |