Commit 80000ac0 authored by Vincent Scheib's avatar Vincent Scheib Committed by Commit Bot

bluetooth: web: Add warning on unsupported platforms.

Developers sometimes do not notice that they are using a partially
supported platform when trying Web Bluetooth. Especially when using
the generic --enable-experimental-web-platform-features.

E.g. https://plus.google.com/117707543167867525197/posts/4nKECjvLD9D

This patch adds a warning to the developer console.

The definition of supported platforms comes from 
https://cs.chromium.org/chromium/src/content/child/runtime_features.cc?type=cs&q=WebRuntimeFeatures::EnableWebBluetooth%5C(true%5C)&l=69-71

Change-Id: I82f7e6fd800607372520d8474e339e5a7659259c
Reviewed-on: https://chromium-review.googlesource.com/557372
Commit-Queue: Vincent Scheib <scheib@chromium.org>
Reviewed-by: default avatarConley Owens <cco3@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486842}
parent 5333b7b2
CONSOLE MESSAGE: line 169: Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md
This is a testharness.js-based test.
FAIL BluetoothDevice IDL test Test bug: need to pass exception to assert_throws()
PASS BluetoothDevice attributes.
Harness: the test ran to completion.
CONSOLE MESSAGE: line 169: Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md
This is a testharness.js-based test.
FAIL BluetoothDevice IDL test Test bug: need to pass exception to assert_throws()
PASS BluetoothDevice attributes.
Harness: the test ran to completion.
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
#include "bindings/core/v8/CallbackPromiseAdapter.h" #include "bindings/core/v8/CallbackPromiseAdapter.h"
#include "bindings/core/v8/ScriptPromise.h" #include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptPromiseResolver.h" #include "bindings/core/v8/ScriptPromiseResolver.h"
#include "build/build_config.h"
#include "core/dom/DOMException.h" #include "core/dom/DOMException.h"
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h" #include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h" #include "core/dom/ExecutionContext.h"
#include "core/dom/UserGestureIndicator.h" #include "core/dom/UserGestureIndicator.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/inspector/ConsoleMessage.h"
#include "modules/bluetooth/BluetoothDevice.h" #include "modules/bluetooth/BluetoothDevice.h"
#include "modules/bluetooth/BluetoothError.h" #include "modules/bluetooth/BluetoothError.h"
#include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h"
...@@ -153,6 +155,15 @@ ScriptPromise Bluetooth::requestDevice(ScriptState* script_state, ...@@ -153,6 +155,15 @@ ScriptPromise Bluetooth::requestDevice(ScriptState* script_state,
ExceptionState& exception_state) { ExceptionState& exception_state) {
ExecutionContext* context = ExecutionContext::From(script_state); ExecutionContext* context = ExecutionContext::From(script_state);
// Remind developers when they are using Web Bluetooth on unsupported platforms.
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
context->AddConsoleMessage(ConsoleMessage::Create(
kJSMessageSource, kInfoMessageLevel,
"Web Bluetooth is experimental on this platform. See "
"https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/"
"implementation-status.md"));
#endif
// If the Relevant settings object is not a secure context, reject promise // If the Relevant settings object is not a secure context, reject promise
// with a SecurityError and abort these steps. // with a SecurityError and abort these steps.
String error_message; String error_message;
......
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