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

Side by Side Diff: chrome/browser/storage/durable_storage_browsertest.cc

Issue 1164073005: Allow script to request durable storage permission (chrome side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix conflicts after midi constant permission landed Created 5 years, 4 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/command_line.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/dom_operation_notification_details.h"
17 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/web_contents.h"
19 #include "content/public/test/browser_test_utils.h"
20 #include "net/test/embedded_test_server/embedded_test_server.h"
21
22 class DurableStorageBrowserTest : public InProcessBrowserTest {
23 public:
24 DurableStorageBrowserTest();
25 ~DurableStorageBrowserTest() override;
26
27 void SetUpCommandLine(base::CommandLine*) override;
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(DurableStorageBrowserTest);
31 };
32
33 DurableStorageBrowserTest::DurableStorageBrowserTest() {}
34
35 DurableStorageBrowserTest::~DurableStorageBrowserTest() {}
36
37 void DurableStorageBrowserTest::SetUpCommandLine(
38 base::CommandLine* command_line) {
39 command_line->AppendSwitch(
40 switches::kEnableExperimentalWebPlatformFeatures);
41 }
42
43 IN_PROC_BROWSER_TEST_F(DurableStorageBrowserTest, FirstTabSeesResult) {
44 EXPECT_TRUE(embedded_test_server()->Started() ||
45 embedded_test_server()->InitializeAndWaitUntilReady());
46
47 Browser* current_browser = browser();
48
49 const GURL& url =
50 embedded_test_server()->GetURL("/durable/durability-window1.html");
51 ui_test_utils::NavigateToURL(current_browser, url);
52 content::RenderFrameHost* render_frame_host =
53 current_browser->tab_strip_model()
54 ->GetActiveWebContents()
55 ->GetMainFrame();
56 std::string result;
57 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
58 render_frame_host, "checkPermission()", &result));
59 EXPECT_EQ("default", result);
60
61 chrome::NewTab(current_browser);
62 const GURL& url2 =
63 embedded_test_server()->GetURL("/durable/durability-window2.html");
64 ui_test_utils::NavigateToURL(current_browser, url2);
65 render_frame_host = current_browser->tab_strip_model()
66 ->GetActiveWebContents()
67 ->GetMainFrame();
68 PermissionBubbleManager::FromWebContents(
69 current_browser->tab_strip_model()->GetActiveWebContents())
70 ->set_auto_response_for_test(PermissionBubbleManager::ACCEPT_ALL);
71 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
72 render_frame_host, "requestPermission()", &result));
73 EXPECT_EQ("granted", result);
74
75 current_browser->tab_strip_model()->ActivateTabAt(0, false);
76 render_frame_host = current_browser->tab_strip_model()
77 ->GetActiveWebContents()
78 ->GetMainFrame();
79 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
80 render_frame_host, "checkPermission()", &result));
81 EXPECT_EQ("granted", result);
82 }
OLDNEW
« no previous file with comments | « chrome/browser/storage/OWNERS ('k') | chrome/browser/storage/durable_storage_permission_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698