OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains browsertests for Web Bluetooth that depend on behavior | 5 // This file contains browsertests for Web Bluetooth that depend on behavior |
6 // defined in chrome/, not just in content/. | 6 // defined in chrome/, not just in content/. |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "chrome/browser/permissions/permission_context_base.h" | 10 #include "chrome/browser/permissions/permission_context_base.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" | 69 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" |
70 " .then(() => { domAutomationController.send('Success'); }," | 70 " .then(() => { domAutomationController.send('Success'); }," |
71 " reason => {" | 71 " reason => {" |
72 " domAutomationController.send(reason.name + ': ' + reason.message);" | 72 " domAutomationController.send(reason.name + ': ' + reason.message);" |
73 " });", | 73 " });", |
74 &rejection)); | 74 &rejection)); |
75 EXPECT_THAT(rejection, | 75 EXPECT_THAT(rejection, |
76 testing::MatchesRegex("NotFoundError: .*globally disabled.*")); | 76 testing::MatchesRegex("NotFoundError: .*globally disabled.*")); |
77 } | 77 } |
78 | 78 |
| 79 // Tests that using Finch field trial parameters for blacklist additions has |
| 80 // the effect of rejecting requestDevice calls. |
| 81 IN_PROC_BROWSER_TEST_F(WebBluetoothTest, BlacklistShouldBlock) { |
| 82 // Fake the BluetoothAdapter to say it's present. |
| 83 scoped_refptr<device::MockBluetoothAdapter> adapter = |
| 84 new testing::NiceMock<device::MockBluetoothAdapter>; |
| 85 EXPECT_CALL(*adapter, IsPresent()).WillRepeatedly(testing::Return(true)); |
| 86 device::BluetoothAdapterFactory::SetAdapterForTesting(adapter); |
| 87 |
| 88 std::map<std::string, std::string> params; |
| 89 params["blacklist_additions"] = "ee01:e"; |
| 90 variations::AssociateVariationParams("WebBluetoothBlacklist", "TestGroup", |
| 91 params); |
| 92 base::FieldTrialList::CreateFieldTrial("WebBluetoothBlacklist", "TestGroup"); |
| 93 |
| 94 std::string rejection; |
| 95 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 96 web_contents_, |
| 97 "navigator.bluetooth.requestDevice({filters: [{services: [0xee01]}]})" |
| 98 " .then(() => { domAutomationController.send('Success'); }," |
| 99 " reason => {" |
| 100 " domAutomationController.send(reason.name + ': ' + reason.message);" |
| 101 " });", |
| 102 &rejection)); |
| 103 EXPECT_THAT(rejection, |
| 104 testing::MatchesRegex("SecurityError: .*blacklisted UUID.*")); |
| 105 } |
| 106 |
79 } // namespace | 107 } // namespace |
OLD | NEW |