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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/storage/OWNERS ('k') | chrome/browser/storage/durable_storage_permission_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/storage/durable_storage_browsertest.cc
diff --git a/chrome/browser/storage/durable_storage_browsertest.cc b/chrome/browser/storage/durable_storage_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f39ba122ab9d529b88b9fc3cfe00f53f2681e26d
--- /dev/null
+++ b/chrome/browser/storage/durable_storage_browsertest.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/command_line.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/dom_operation_notification_details.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
+
+class DurableStorageBrowserTest : public InProcessBrowserTest {
+ public:
+ DurableStorageBrowserTest();
+ ~DurableStorageBrowserTest() override;
+
+ void SetUpCommandLine(base::CommandLine*) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DurableStorageBrowserTest);
+};
+
+DurableStorageBrowserTest::DurableStorageBrowserTest() {}
+
+DurableStorageBrowserTest::~DurableStorageBrowserTest() {}
+
+void DurableStorageBrowserTest::SetUpCommandLine(
+ base::CommandLine* command_line) {
+ command_line->AppendSwitch(
+ switches::kEnableExperimentalWebPlatformFeatures);
+}
+
+IN_PROC_BROWSER_TEST_F(DurableStorageBrowserTest, FirstTabSeesResult) {
+ EXPECT_TRUE(embedded_test_server()->Started() ||
+ embedded_test_server()->InitializeAndWaitUntilReady());
+
+ Browser* current_browser = browser();
+
+ const GURL& url =
+ embedded_test_server()->GetURL("/durable/durability-window1.html");
+ ui_test_utils::NavigateToURL(current_browser, url);
+ content::RenderFrameHost* render_frame_host =
+ current_browser->tab_strip_model()
+ ->GetActiveWebContents()
+ ->GetMainFrame();
+ std::string result;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractString(
+ render_frame_host, "checkPermission()", &result));
+ EXPECT_EQ("default", result);
+
+ chrome::NewTab(current_browser);
+ const GURL& url2 =
+ embedded_test_server()->GetURL("/durable/durability-window2.html");
+ ui_test_utils::NavigateToURL(current_browser, url2);
+ render_frame_host = current_browser->tab_strip_model()
+ ->GetActiveWebContents()
+ ->GetMainFrame();
+ PermissionBubbleManager::FromWebContents(
+ current_browser->tab_strip_model()->GetActiveWebContents())
+ ->set_auto_response_for_test(PermissionBubbleManager::ACCEPT_ALL);
+ EXPECT_TRUE(content::ExecuteScriptAndExtractString(
+ render_frame_host, "requestPermission()", &result));
+ EXPECT_EQ("granted", result);
+
+ current_browser->tab_strip_model()->ActivateTabAt(0, false);
+ render_frame_host = current_browser->tab_strip_model()
+ ->GetActiveWebContents()
+ ->GetMainFrame();
+ EXPECT_TRUE(content::ExecuteScriptAndExtractString(
+ render_frame_host, "checkPermission()", &result));
+ EXPECT_EQ("granted", result);
+}
« 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