Commit 4f8cac3b authored by Jinho Bang's avatar Jinho Bang Committed by Commit Bot

WebBluetooth: Use [SecureContext] instead of manual check

Until now, we had to use IsSecureContext() to check whether an execution
context is a secure context manually. But we can use [SecureContext]
instead of the manual check now.

Bug: none
Change-Id: Ibfcd4a9a2eed3e7ac67819b9bf4204f4c73412d8
Reviewed-on: https://chromium-review.googlesource.com/990014Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Commit-Queue: Jinho Bang <jinho.bang@samsung.com>
Cr-Commit-Position: refs/heads/master@{#548464}
parent baede72c
......@@ -7,11 +7,8 @@
if (window.location.origin != get_host_info().UNAUTHENTICATED_ORIGIN) {
window.location = get_host_info().UNAUTHENTICATED_ORIGIN + window.location.pathname;
} else {
promise_test(function(test) {
return promise_rejects(test, 'SecurityError',
navigator.bluetooth.requestDevice({
filters: [{services: ['generic_access']}]
}));
}, "Requires secure context before user gesture");
test(t => {
assert_false('requestDevice' in navigator.bluetooth, 'navigator.bluetooth.requestDevice should not be present');
}, 'navigator.bluetooth.requestDevice requires a secure context');
}
</script>
......@@ -164,13 +164,7 @@ ScriptPromise Bluetooth::requestDevice(ScriptState* script_state,
"implementation-status.md"));
#endif
// If the Relevant settings object is not a secure context, reject promise
// with a SecurityError and abort these steps.
String error_message;
if (!context->IsSecureContext(error_message)) {
return ScriptPromise::RejectWithDOMException(
script_state, DOMException::Create(kSecurityError, error_message));
}
CHECK(context->IsSecureContext());
// If the algorithm is not allowed to show a popup, reject promise with a
// SecurityError and abort these steps.
......
......@@ -7,5 +7,5 @@
[
RuntimeEnabled=WebBluetooth
] interface Bluetooth {
[CallWith=ScriptState, RaisesException, MeasureAs=WebBluetoothRequestDevice] Promise<BluetoothDevice> requestDevice (optional RequestDeviceOptions options);
[CallWith=ScriptState, RaisesException, MeasureAs=WebBluetoothRequestDevice, SecureContext] Promise<BluetoothDevice> requestDevice (optional RequestDeviceOptions options);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment