Skip to content

Commit

Permalink
Merge pull request #4463 from brave/disable_websql
Browse files Browse the repository at this point in the history
Fix 7522: Disable WebSQL
  • Loading branch information
jumde committed Feb 6, 2020
2 parents cd4edd3 + afa2e49 commit a50fa1d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitchASCII(switches::kSyncServiceURL,
"https://no-thanks.invalid");

command_line.AppendSwitch(switches::kDisableDatabases);

// Enabled features.
const std::unordered_set<const char*> enabled_features = {
password_manager::features::kPasswordImport.name,
Expand Down
6 changes: 6 additions & 0 deletions app/brave_main_delegate_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "components/password_manager/core/common/password_manager_features.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/web_preferences.h"
#include "gpu/config/gpu_finch_features.h"
#include "services/network/public/cpp/features.h"
Expand All @@ -39,6 +40,11 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisableHyperlinkAuditing) {
EXPECT_FALSE(prefs.hyperlink_auditing_enabled);
}

IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisableWebSQL) {
EXPECT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableDatabases));
}

IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisabledFeatures) {
const base::Feature* disabled_features[] = {
&autofill::features::kAutofillServerCommunication,
Expand Down
43 changes: 43 additions & 0 deletions app/websql_browsertest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "base/path_service.h"
#include "brave/common/brave_paths.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"

class WebSQLDisabledTest : public InProcessBrowserTest {
public:
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
content::SetupCrossSiteRedirector(embedded_test_server());

brave::RegisterPathProvider();
base::FilePath test_data_dir;
base::PathService::Get(brave::DIR_TEST_DATA, &test_data_dir);
embedded_test_server()->ServeFilesFromDirectory(test_data_dir);

ASSERT_TRUE(embedded_test_server()->Start());
}
};

IN_PROC_BROWSER_TEST_F(WebSQLDisabledTest, IsDisabled) {
GURL url = embedded_test_server()->GetURL("/simple.html");
ui_test_utils::NavigateToURL(browser(), url);
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(content::WaitForLoadStop(contents));
EXPECT_EQ(url, contents->GetURL());

bool websql_blocked;
ASSERT_TRUE(ExecuteScriptAndExtractBool(
contents,
"window.domAutomationController.send(window.openDatabase == undefined)",
&websql_blocked));
EXPECT_TRUE(websql_blocked);
}
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ test("brave_browser_tests") {
testonly = true
sources = [
"//brave/app/brave_main_delegate_browsertest.cc",
"//brave/app/websql_browsertest.cc",
"//brave/browser/autocomplete/brave_autocomplete_provider_client_browsertest.cc",
"//brave/browser/brave_scheme_load_browsertest.cc",
"//brave/browser/autoplay/autoplay_permission_context_browsertest.cc",
Expand Down

0 comments on commit a50fa1d

Please sign in to comment.