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

Unified Diff: chrome/browser/web_bluetooth_browsertest.cc

Issue 1858633003: bluetooth: Populate Web Bluetooth blacklist from variations:: parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set adapter in tests: Created 4 years, 8 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
Index: chrome/browser/web_bluetooth_browsertest.cc
diff --git a/chrome/browser/web_bluetooth_browsertest.cc b/chrome/browser/web_bluetooth_browsertest.cc
index 6a94ea45e64b0bea1cb48c004943d62d35cf5405..2692b61e4ee680e960b4086ce19babaeb84d85b2 100644
--- a/chrome/browser/web_bluetooth_browsertest.cc
+++ b/chrome/browser/web_bluetooth_browsertest.cc
@@ -76,4 +76,32 @@ IN_PROC_BROWSER_TEST_F(WebBluetoothTest, KillSwitchShouldBlock) {
testing::MatchesRegex("NotFoundError: .*globally disabled.*"));
}
+// Tests that using Finch field trial parameters for blacklist additions has
+// the effect of rejecting requestDevice calls.
+IN_PROC_BROWSER_TEST_F(WebBluetoothTest, BlacklistShouldBlock) {
+ // Fake the BluetoothAdapter to say it's present.
+ scoped_refptr<device::MockBluetoothAdapter> adapter =
+ new testing::NiceMock<device::MockBluetoothAdapter>;
+ EXPECT_CALL(*adapter, IsPresent()).WillRepeatedly(testing::Return(true));
+ device::BluetoothAdapterFactory::SetAdapterForTesting(adapter);
+
+ std::map<std::string, std::string> params;
+ params["blacklist_additions"] = "ee01:e";
+ variations::AssociateVariationParams("WebBluetoothBlacklist", "TestGroup",
+ params);
+ base::FieldTrialList::CreateFieldTrial("WebBluetoothBlacklist", "TestGroup");
+
+ std::string rejection;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractString(
+ web_contents_,
+ "navigator.bluetooth.requestDevice({filters: [{services: [0xee01]}]})"
+ " .then(() => { domAutomationController.send('Success'); },"
+ " reason => {"
+ " domAutomationController.send(reason.name + ': ' + reason.message);"
+ " });",
+ &rejection));
+ EXPECT_THAT(rejection,
+ testing::MatchesRegex("SecurityError: .*blacklisted UUID.*"));
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698