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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2951913002: [DevTools] Support multiple sessions in Target domain (Closed)
Patch Set: simplify Created 3 years, 5 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 unified diff | Download patch
OLDNEW
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 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 params = WaitForNotification("Target.targetDestroyed", true); 1655 params = WaitForNotification("Target.targetDestroyed", true);
1656 EXPECT_TRUE(params->GetString("targetId", &temp)); 1656 EXPECT_TRUE(params->GetString("targetId", &temp));
1657 EXPECT_TRUE(ids.find(temp) != ids.end()); 1657 EXPECT_TRUE(ids.find(temp) != ids.end());
1658 ids.erase(temp); 1658 ids.erase(temp);
1659 EXPECT_TRUE(notifications_.empty()); 1659 EXPECT_TRUE(notifications_.empty());
1660 1660
1661 command_params.reset(new base::DictionaryValue()); 1661 command_params.reset(new base::DictionaryValue());
1662 command_params->SetString("targetId", attached_id); 1662 command_params->SetString("targetId", attached_id);
1663 SendCommand("Target.attachToTarget", std::move(command_params), true); 1663 SendCommand("Target.attachToTarget", std::move(command_params), true);
1664 params = WaitForNotification("Target.attachedToTarget", true); 1664 params = WaitForNotification("Target.attachedToTarget", true);
1665 std::string session_id;
1666 EXPECT_TRUE(params->GetString("sessionId", &session_id));
1665 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp)); 1667 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
1666 EXPECT_EQ(attached_id, temp); 1668 EXPECT_EQ(attached_id, temp);
1667 EXPECT_TRUE(notifications_.empty()); 1669 EXPECT_TRUE(notifications_.empty());
1668 1670
1669 command_params.reset(new base::DictionaryValue()); 1671 command_params.reset(new base::DictionaryValue());
1670 command_params->SetBoolean("discover", false); 1672 command_params->SetBoolean("discover", false);
1671 SendCommand("Target.setDiscoverTargets", std::move(command_params), true); 1673 SendCommand("Target.setDiscoverTargets", std::move(command_params), true);
1672 EXPECT_TRUE(notifications_.empty()); 1674 EXPECT_TRUE(notifications_.empty());
1673 1675
1674 command_params.reset(new base::DictionaryValue()); 1676 command_params.reset(new base::DictionaryValue());
1675 command_params->SetString("targetId", attached_id); 1677 command_params->SetString("sessionId", session_id);
1676 SendCommand("Target.detachFromTarget", std::move(command_params), true); 1678 SendCommand("Target.detachFromTarget", std::move(command_params), true);
1677 params = WaitForNotification("Target.detachedFromTarget", true); 1679 params = WaitForNotification("Target.detachedFromTarget", true);
1678 EXPECT_TRUE(params->GetString("targetId", &temp)); 1680 EXPECT_TRUE(params->GetString("sessionId", &temp));
1679 EXPECT_EQ(attached_id, temp); 1681 EXPECT_EQ(session_id, temp);
1680 EXPECT_TRUE(notifications_.empty()); 1682 EXPECT_TRUE(notifications_.empty());
1681 } 1683 }
1682 1684
1683 // Tests that an interstitialShown event is sent when an interstitial is showing 1685 // Tests that an interstitialShown event is sent when an interstitial is showing
1684 // on attach. 1686 // on attach.
1685 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, InterstitialShownOnAttach) { 1687 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, InterstitialShownOnAttach) {
1686 TestInterstitialDelegate* delegate = new TestInterstitialDelegate; 1688 TestInterstitialDelegate* delegate = new TestInterstitialDelegate;
1687 WebContentsImpl* web_contents = 1689 WebContentsImpl* web_contents =
1688 static_cast<WebContentsImpl*>(shell()->web_contents()); 1690 static_cast<WebContentsImpl*>(shell()->web_contents());
1689 GURL interstitial_url("https://example.test"); 1691 GURL interstitial_url("https://example.test");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 Attach(); 1737 Attach();
1736 command_params.reset(new base::DictionaryValue()); 1738 command_params.reset(new base::DictionaryValue());
1737 command_params->SetBoolean("autoAttach", true); 1739 command_params->SetBoolean("autoAttach", true);
1738 command_params->SetBoolean("waitForDebuggerOnStart", true); 1740 command_params->SetBoolean("waitForDebuggerOnStart", true);
1739 SendCommand("Target.setAutoAttach", std::move(command_params), true); 1741 SendCommand("Target.setAutoAttach", std::move(command_params), true);
1740 EXPECT_TRUE(notifications_.empty()); 1742 EXPECT_TRUE(notifications_.empty());
1741 command_params.reset(new base::DictionaryValue()); 1743 command_params.reset(new base::DictionaryValue());
1742 command_params->SetBoolean("value", true); 1744 command_params->SetBoolean("value", true);
1743 SendCommand("Target.setAttachToFrames", std::move(command_params), false); 1745 SendCommand("Target.setAttachToFrames", std::move(command_params), false);
1744 params = WaitForNotification("Target.attachedToTarget", true); 1746 params = WaitForNotification("Target.attachedToTarget", true);
1747 std::string session_id;
1748 EXPECT_TRUE(params->GetString("sessionId", &session_id));
1745 EXPECT_TRUE(params->GetString("targetInfo.targetId", &target_id)); 1749 EXPECT_TRUE(params->GetString("targetInfo.targetId", &target_id));
1746 EXPECT_TRUE(params->GetString("targetInfo.type", &temp)); 1750 EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
1747 EXPECT_EQ("iframe", temp); 1751 EXPECT_EQ("iframe", temp);
1748 1752
1749 // Load same-site page into iframe. 1753 // Load same-site page into iframe.
1750 FrameTreeNode* child = root->child_at(0); 1754 FrameTreeNode* child = root->child_at(0);
1751 GURL http_url(embedded_test_server()->GetURL("/title1.html")); 1755 GURL http_url(embedded_test_server()->GetURL("/title1.html"));
1752 NavigateFrameToURL(child, http_url); 1756 NavigateFrameToURL(child, http_url);
1753 params = WaitForNotification("Target.detachedFromTarget", true); 1757 params = WaitForNotification("Target.detachedFromTarget", true);
1754 EXPECT_TRUE(params->GetString("targetId", &temp)); 1758 EXPECT_TRUE(params->GetString("sessionId", &temp));
1755 EXPECT_EQ(target_id, temp); 1759 EXPECT_EQ(session_id, temp);
1756 1760
1757 // Navigate back to cross-site iframe. 1761 // Navigate back to cross-site iframe.
1758 NavigateFrameToURL(root->child_at(0), cross_site_url); 1762 NavigateFrameToURL(root->child_at(0), cross_site_url);
1759 params = WaitForNotification("Target.attachedToTarget", true); 1763 params = WaitForNotification("Target.attachedToTarget", true);
1764 EXPECT_TRUE(params->GetString("sessionId", &session_id));
1760 EXPECT_TRUE(params->GetString("targetInfo.targetId", &target_id)); 1765 EXPECT_TRUE(params->GetString("targetInfo.targetId", &target_id));
1761 EXPECT_TRUE(params->GetString("targetInfo.type", &temp)); 1766 EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
1762 EXPECT_EQ("iframe", temp); 1767 EXPECT_EQ("iframe", temp);
1763 1768
1764 // Disable auto-attach. 1769 // Disable auto-attach.
1765 command_params.reset(new base::DictionaryValue()); 1770 command_params.reset(new base::DictionaryValue());
1766 command_params->SetBoolean("autoAttach", false); 1771 command_params->SetBoolean("autoAttach", false);
1767 command_params->SetBoolean("waitForDebuggerOnStart", false); 1772 command_params->SetBoolean("waitForDebuggerOnStart", false);
1768 SendCommand("Target.setAutoAttach", std::move(command_params), false); 1773 SendCommand("Target.setAutoAttach", std::move(command_params), false);
1769 params = WaitForNotification("Target.detachedFromTarget", true); 1774 params = WaitForNotification("Target.detachedFromTarget", true);
1770 EXPECT_TRUE(params->GetString("targetId", &temp)); 1775 EXPECT_TRUE(params->GetString("sessionId", &temp));
1771 EXPECT_EQ(target_id, temp); 1776 EXPECT_EQ(session_id, temp);
1772 } 1777 }
1773 1778
1774 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, SetAndGetCookies) { 1779 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, SetAndGetCookies) {
1775 ASSERT_TRUE(embedded_test_server()->Start()); 1780 ASSERT_TRUE(embedded_test_server()->Start());
1776 GURL test_url = embedded_test_server()->GetURL("/title1.html"); 1781 GURL test_url = embedded_test_server()->GetURL("/title1.html");
1777 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); 1782 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1);
1778 Attach(); 1783 Attach();
1779 1784
1780 // Set two cookies, one of which matches the loaded URL and another that 1785 // Set two cookies, one of which matches the loaded URL and another that
1781 // doesn't. 1786 // doesn't.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 EXPECT_EQ("polyglottal", value); 1835 EXPECT_EQ("polyglottal", value);
1831 found++; 1836 found++;
1832 } else { 1837 } else {
1833 FAIL(); 1838 FAIL();
1834 } 1839 }
1835 } 1840 }
1836 EXPECT_EQ(2u, found); 1841 EXPECT_EQ(2u, found);
1837 } 1842 }
1838 1843
1839 } // namespace content 1844 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698