-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 1549: Return constant results for navigator.plugins and navigat…
…or.mimeTypes auditors: @diracdeltas
- Loading branch information
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
chromium_src/third_party/blink/renderer/modules/plugins/navigator_pluginstest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* 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/browser/brave_content_browser_client.h" | ||
#include "brave/common/brave_paths.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/common/chrome_content_client.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "chrome/test/base/ui_test_utils.h" | ||
#include "content/public/test/browser_test_utils.h" | ||
|
||
const char kNavigatorPluginsTest[] = "/navigatorplugins.html"; | ||
const char kNavigatorMimeTypesTest[] = "/navigatormimetypes.html"; | ||
|
||
class NavigatorPluginsTest : public InProcessBrowserTest { | ||
public: | ||
void SetUpOnMainThread() override { | ||
InProcessBrowserTest::SetUpOnMainThread(); | ||
|
||
content_client_.reset(new ChromeContentClient); | ||
content::SetContentClient(content_client_.get()); | ||
browser_content_client_.reset(new BraveContentBrowserClient()); | ||
content::SetBrowserClientForTesting(browser_content_client_.get()); | ||
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()); | ||
} | ||
|
||
void TearDown() override { | ||
browser_content_client_.reset(); | ||
content_client_.reset(); | ||
} | ||
|
||
private: | ||
std::unique_ptr<ChromeContentClient> content_client_; | ||
std::unique_ptr<BraveContentBrowserClient> browser_content_client_; | ||
base::ScopedTempDir temp_user_data_dir_; | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(NavigatorPluginsTest, ConstPlugins) { | ||
GURL url = embedded_test_server()->GetURL(kNavigatorPluginsTest); | ||
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 constantPlugins; | ||
ASSERT_TRUE(ExecuteScriptAndExtractBool( | ||
contents, | ||
"window.domAutomationController.send(constantPlugins())", | ||
&constantPlugins)); | ||
EXPECT_TRUE(constantPlugins); | ||
} | ||
|
||
IN_PROC_BROWSER_TEST_F(NavigatorPluginsTest, ConstMimeTypes) { | ||
GURL url = embedded_test_server()->GetURL(kNavigatorMimeTypesTest); | ||
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 constantMimeTypes; | ||
ASSERT_TRUE(ExecuteScriptAndExtractBool( | ||
contents, | ||
"window.domAutomationController.send(constantMimeTypes())", | ||
&constantMimeTypes)); | ||
EXPECT_TRUE(constantMimeTypes); | ||
} |
14 changes: 14 additions & 0 deletions
14
patches/third_party-blink-renderer-platform-plugins-plugin_data.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/third_party/blink/renderer/platform/plugins/plugin_data.cc b/third_party/blink/renderer/platform/plugins/plugin_data.cc | ||
index 02d54d5f2dbf37a5de6ccaee3a825416b911b42c..6b1789b4fb65ad31a45bb764400f4aa040282857 100644 | ||
--- a/third_party/blink/renderer/platform/plugins/plugin_data.cc | ||
+++ b/third_party/blink/renderer/platform/plugins/plugin_data.cc | ||
@@ -108,6 +108,9 @@ void PluginData::UpdatePluginList(const SecurityOrigin* main_frame_origin) { | ||
Vector<mojom::blink::PluginInfoPtr> plugins; | ||
registry->GetPlugins(false, legacy_origin, &plugins); | ||
for (const auto& plugin : plugins) { | ||
+ if (plugin->name != "Shockwave Flash") { | ||
+ return; | ||
+ } | ||
auto* plugin_info = | ||
new PluginInfo(plugin->name, FilePathToWebString(plugin->filename), | ||
plugin->description, plugin->background_color); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
function constantMimeTypes() { | ||
return navigator.mimeTypes.length == 0; | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
function constantPlugins() { | ||
return navigator.plugins.length == 0; | ||
} | ||
</script> |