aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAttila Dusnoki <dati91@gmail.com>2017-02-10 15:07:22 +0100
committerAttila Dusnoki <dati91@gmail.com>2017-02-13 14:58:13 +0100
commit4a62562b0f9deb642745a2cd735bc5a6e5187230 (patch)
tree25bdaef95010c93f263dd65528801bc2beac244f
parent3ec9f0bab9807ccaecd3f4b93d891f7cab82fbc5 (diff)
downloadservo-4a62562b0f9deb642745a2cd735bc5a6e5187230.tar.gz
servo-4a62562b0f9deb642745a2cd735bc5a6e5187230.zip
Add pref to ignore popup in testing
-rw-r--r--components/script/dom/bluetooth.rs10
-rw-r--r--components/script/dom/permissions.rs7
-rw-r--r--resources/prefs.json1
-rw-r--r--tests/wpt/mozilla/meta/mozilla/bluetooth/__dir__.ini2
4 files changed, 12 insertions, 8 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
index e681ce5b1da..ec8d6363793 100644
--- a/components/script/dom/bluetooth.rs
+++ b/components/script/dom/bluetooth.rs
@@ -17,7 +17,7 @@ use dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::Bluetoot
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerBinding::
BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
-use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState;
+use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, PermissionState};
use dom::bindings::codegen::UnionTypes::{StringOrStringSequence, StringOrUnsignedLong};
use dom::bindings::error::Error::{self, Network, Security, Type};
use dom::bindings::error::Fallible;
@@ -216,11 +216,9 @@ impl Bluetooth {
ServiceUUIDSequence::new(optional_services_uuids));
// Step 3 - 5
- // FIXME The following call will create a popup, which will mess up the testing...
- // Maybe create a call to the lower level to check if we are testing or not
- // if let PermissionState::Denied = get_descriptor_permission_state(PermissionName::Bluetooth, None) {
- // return p.reject_error(p.global().get_cx(), Error::NotFound);
- // }
+ if let PermissionState::Denied = get_descriptor_permission_state(PermissionName::Bluetooth, None) {
+ return p.reject_error(p.global().get_cx(), Error::NotFound);
+ }
// Note: Steps 6 - 8 are implemented in
// components/net/bluetooth_thread.rs in request_device function.
diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs
index e8d2b60a3d2..dec92bc1548 100644
--- a/components/script/dom/permissions.rs
+++ b/components/script/dom/permissions.rs
@@ -15,6 +15,7 @@ use dom::promise::Promise;
use js::conversions::ConversionResult;
use js::jsapi::{JSContext, JSObject};
use js::jsval::{ObjectValue, UndefinedValue};
+use servo_config::prefs::PREFS;
use std::rc::Rc;
#[cfg(target_os = "linux")]
use tinyfiledialogs::{self, MessageBoxIcon, YesNo};
@@ -231,7 +232,11 @@ pub fn get_descriptor_permission_state(permission_name: PermissionName ,
// if the feature is not allowed in non-secure contexcts,
// and let the user decide to grant the permission or not.
if !allowed_in_nonsecure_contexts(&permission_name) {
- return prompt_user(permission_name);
+ if PREFS.get("dom.permissions.testing.allowed_in_nonsecure_contexts").as_boolean().unwrap_or(false) {
+ return PermissionState::Granted;
+ } else {
+ return prompt_user(permission_name);
+ }
}
// TODO: Step 3: Store the invocation results
diff --git a/resources/prefs.json b/resources/prefs.json
index 2e8200d3b63..278c5c4f8bf 100644
--- a/resources/prefs.json
+++ b/resources/prefs.json
@@ -5,6 +5,7 @@
"dom.mouseevent.which.enabled": false,
"dom.mozbrowser.enabled": false,
"dom.permissions.enabled": false,
+ "dom.permissions.testing.allowed_in_nonsecure_contexts": false,
"dom.serviceworker.timeout_seconds": 60,
"dom.testable_crash.enabled": false,
"dom.testbinding.enabled": false,
diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/__dir__.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/__dir__.ini
index ad2557a1798..c95b7c11c1d 100644
--- a/tests/wpt/mozilla/meta/mozilla/bluetooth/__dir__.ini
+++ b/tests/wpt/mozilla/meta/mozilla/bluetooth/__dir__.ini
@@ -1 +1 @@
-prefs: [dom.bluetooth.enabled:true, dom.bluetooth.testing.enabled:true]
+prefs: [dom.bluetooth.enabled:true, dom.bluetooth.testing.enabled:true, dom.permissions.testing.allowed_in_nonsecure_contexts:true]