| Index: third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/test_case_fuzzer.py
|
| diff --git a/third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/test_case_fuzzer.py b/third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/test_case_fuzzer.py
|
| index bc955deb2406721a1933444cece8af607195fb4a..16ba294c25357f9784dc88f8941678212a2b5635 100644
|
| --- a/third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/test_case_fuzzer.py
|
| +++ b/third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/test_case_fuzzer.py
|
| @@ -12,7 +12,8 @@ BASE_TOKENS = [
|
| 'TRANSFORM_BASIC_BASE',
|
| 'TRANSFORM_DEVICE_DISCOVERY_BASE',
|
| 'TRANSFORM_CONNECTABLE_BASE',
|
| - 'TRANSFORM_SERVICE_RETRIEVED_BASE',
|
| + 'TRANSFORM_SERVICES_RETRIEVED_BASE',
|
| + 'TRANSFORM_CHARACTERISTICS_RETRIEVED_BASE',
|
| ]
|
|
|
| # Contains strings that represent calls to the Web Bluetooth API. These
|
| @@ -20,11 +21,6 @@ BASE_TOKENS = [
|
| # calls to the API. These strings are separated by line and placed so
|
| # that indentation can be performed more easily.
|
| TOKENS = [
|
| - [
|
| - '})',
|
| - '.catch(e => console.log(e.name + \': \' + e.message))',
|
| - '.then(() => {',
|
| - ],
|
| # Request Device Tokens
|
| [
|
| ' requestDeviceWithKeyDown(TRANSFORM_REQUEST_DEVICE_OPTIONS);'
|
| @@ -32,41 +28,136 @@ TOKENS = [
|
| [
|
| ' return requestDeviceWithKeyDown(TRANSFORM_REQUEST_DEVICE_OPTIONS);',
|
| '})',
|
| + 'TRANSFORM_CATCH',
|
| '.then(device => {',
|
| + ' var gatt = device ? device.gatt : undefined;',
|
| ],
|
| # Connect Tokens
|
| [
|
| - ' device.gatt.connect();',
|
| + ' if (typeof gatt !== \'undefined\') gatt.connect();',
|
| ],
|
| [
|
| - ' return device.gatt.connect();',
|
| - '})'
|
| + ' return gatt.connect();',
|
| + '})',
|
| + 'TRANSFORM_CATCH',
|
| '.then(gatt => {',
|
| + ' var device = gatt ? gatt.device : undefined;',
|
| ],
|
| + # Disconnect
|
| [
|
| - ' gatt.connect();',
|
| + ' if (typeof gatt !==\'undefined\') gatt.disconnect();',
|
| ],
|
| + # GetPrimaryServices Tokens
|
| [
|
| - ' return gatt.connect();',
|
| - '})'
|
| - '.then(gatt => {',
|
| + ' if (typeof gatt !== \'undefined\') gatt.TRANSFORM_GET_PRIMARY_SERVICES;',
|
| + ],
|
| + [
|
| + ' return gatt.TRANSFORM_GET_PRIMARY_SERVICES;',
|
| + '})',
|
| + 'TRANSFORM_CATCH',
|
| + '.then(services => {',
|
| + ' var device = services ? Array.isArray(services) ? services[0].device : services.device : undefined;',
|
| + ' var gatt = device ? device.gatt : undefined;',
|
| ],
|
| - # GetPrimaryService(s) Tokens
|
| + # GetCharacteristics Tokens
|
| [
|
| - ' device.gatt.getPrimaryServices();',
|
| + ' TRANSFORM_PICK_A_SERVICE;',
|
| + ' if (typeof service !== \'undefined\') service.TRANSFORM_GET_CHARACTERISTICS;',
|
| ],
|
| [
|
| - ' gatt.getPrimaryServices();',
|
| + ' TRANSFORM_PICK_A_SERVICE;',
|
| + ' return service.TRANSFORM_GET_CHARACTERISTICS;',
|
| + '})',
|
| + 'TRANSFORM_CATCH',
|
| + '.then(characteristics => {',
|
| + ' var service = characteristics ? Array.isArray(services) ? characteristics[0].service : characteristics.service : undefined;'
|
| + ' var device = service ? service.device : undefined;',
|
| + ' var gatt = device ? device.gatt : undefined;',
|
| ],
|
| + # ReadValue Tokens
|
| [
|
| - ' return device.gatt.getPrimaryServices();',
|
| - '})'
|
| - '.then(services => {',
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' if (typeof characteristic != \'undefined\') characteristic.readValue();',
|
| ],
|
| [
|
| - ' return gatt.getPrimaryServices();',
|
| - '})'
|
| - '.then(services => {',
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' return characteristic.readValue().then(_ => characteristics);',
|
| + '})',
|
| + 'TRANSFORM_CATCH',
|
| + '.then((characteristics) => {',
|
| + ],
|
| + # WriteValue Tokens
|
| + [
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' if (typeof characteristic != \'undefined\') characteristic.writeValue(TRANSFORM_WRITE_VALUE);'
|
| + ],
|
| + [
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' return characteristic.writeValue(TRANSFORM_WRITE_VALUE).then(() => characteristics);',
|
| + '})',
|
| + 'TRANSFORM_CATCH',
|
| + '.then(characteristics => {',
|
| + ],
|
| + # Notifications Tokens
|
| + [
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' if (typeof characteristic != \'undefined\') characteristic.startNotifications();',
|
| + ],
|
| + [
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' return characteristic.startNotitications().then(() => characteristics);',
|
| + '})',
|
| + 'TRANSFORM_CATCH',
|
| + '.then(characteristics => {',
|
| + ],
|
| + [
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' if (typeof characteristic != \'undefined\') characteristic.stopNotifications();',
|
| + ],
|
| + [
|
| + ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + ' return characteristic.stopNotitications().then(() => characteristics);',
|
| + '})',
|
| + 'TRANSFORM_CATCH',
|
| + '.then(characteristics => {',
|
| + ],
|
| + # Event listener tokens
|
| + # [
|
| + # ' if (typeof device != \'undefined\')',
|
| + # ' device.TRANSFORM_LISTENER_CALL;',
|
| + # ],
|
| + # [
|
| + # ' if (typeof gatt != \'undefined\')',
|
| + # ' gatt.TRANSFORM_LISTENER_CALL;',
|
| + # ],
|
| + # [
|
| + # ' TRANSFORM_PICK_A_SERVICE;',
|
| + # ' if (typeof service != \'undefined\')',
|
| + # ' service.TRANSFORM_LISTENER_CALL;',
|
| + # ],
|
| + # [
|
| + # ' TRANSFORM_PICK_A_CHARACTERISTIC;',
|
| + # ' if (typeof characteristic != \'undefined\')',
|
| + # ' characteristic.TRANSFORM_LISTENER_CALL;',
|
| + # ],
|
| + # Garbage Collection
|
| + [
|
| + ' runGarbageCollection();',
|
| + ],
|
| + [
|
| + ' return runGarbageCollection();',
|
| + '})',
|
| + '.then(() => {',
|
| + ],
|
| + # Reload
|
| + [
|
| + ' (() => {',
|
| + ' let reload_id = TRANSFORM_RELOAD_ID;',
|
| + ' if (!sessionStorage.getItem(reload_id)) {',
|
| + ' sessionStorage.setItem(reload_id, true);',
|
| + ' location.reload();',
|
| + ' }',
|
| + ' })();',
|
| ],
|
| ]
|
|
|
|
|