How to use uuidABCDData method in wpt

Best JavaScript code snippet using wpt

bluetooth-fake-devices.js

Source:bluetooth-fake-devices.js Github

copy

Full Screen

1'use strict';2/* Bluetooth Constants */3/**4 * HCI Error Codes.5 * Used for simulateGATT{Dis}ConnectionResponse. For a complete list of6 * possible error codes see BT 4.2 Vol 2 Part D 1.3 List Of Error Codes.7 */8const HCI_SUCCESS = 0x0000;9const HCI_CONNECTION_TIMEOUT = 0x0008;10/**11 * GATT Error codes.12 * Used for GATT operations responses. BT 4.2 Vol 3 Part F 3.4.1.1 Error13 * Response14 */15const GATT_SUCCESS = 0x0000;16const GATT_INVALID_HANDLE = 0x0001;17/* Bluetooth UUID Constants */18/* Service UUIDs */19var blocklist_test_service_uuid = '611c954a-263b-4f4a-aab6-01ddb953f985';20var request_disconnection_service_uuid = '01d7d889-7451-419f-aeb8-d65e7b9277af';21/* Characteristic UUIDs */22var blocklist_exclude_reads_characteristic_uuid =23 'bad1c9a2-9a5b-4015-8b60-1579bbbf2135';24var request_disconnection_characteristic_uuid =25 '01d7d88a-7451-419f-aeb8-d65e7b9277af';26/* Descriptor UUIDs */27var blocklist_test_descriptor_uuid = 'bad2ddcf-60db-45cd-bef9-fd72b153cf7c';28var blocklist_exclude_reads_descriptor_uuid =29 'bad3ec61-3cc3-4954-9702-7977df514114';30/**31 * Helper objects that associate Bluetooth names, aliases, and UUIDs. These are32 * useful for tests that check that the same result is produces when using all33 * three methods of referring to a Bluetooth UUID.34 */35var generic_access = {36 alias: 0x1800,37 name: 'generic_access',38 uuid: '00001800-0000-1000-8000-00805f9b34fb'39};40var device_name = {41 alias: 0x2a00,42 name: 'gap.device_name',43 uuid: '00002a00-0000-1000-8000-00805f9b34fb'44};45var reconnection_address = {46 alias: 0x2a03,47 name: 'gap.reconnection_address',48 uuid: '00002a03-0000-1000-8000-00805f9b34fb'49};50var heart_rate = {51 alias: 0x180d,52 name: 'heart_rate',53 uuid: '0000180d-0000-1000-8000-00805f9b34fb'54};55var health_thermometer = {56 alias: 0x1809,57 name: 'health_thermometer',58 uuid: '00001809-0000-1000-8000-00805f9b34fb'59};60var body_sensor_location = {61 alias: 0x2a38,62 name: 'body_sensor_location',63 uuid: '00002a38-0000-1000-8000-00805f9b34fb'64};65var glucose = {66 alias: 0x1808,67 name: 'glucose',68 uuid: '00001808-0000-1000-8000-00805f9b34fb'69};70var battery_service = {71 alias: 0x180f,72 name: 'battery_service',73 uuid: '0000180f-0000-1000-8000-00805f9b34fb'74};75var battery_level = {76 alias: 0x2A19,77 name: 'battery_level',78 uuid: '00002a19-0000-1000-8000-00805f9b34fb'79};80var user_description = {81 alias: 0x2901,82 name: 'gatt.characteristic_user_description',83 uuid: '00002901-0000-1000-8000-00805f9b34fb'84};85var client_characteristic_configuration = {86 alias: 0x2902,87 name: 'gatt.client_characteristic_configuration',88 uuid: '00002902-0000-1000-8000-00805f9b34fb'89};90var measurement_interval = {91 alias: 0x2a21,92 name: 'measurement_interval',93 uuid: '00002a21-0000-1000-8000-00805f9b34fb'94};95/**96 * An advertisement packet object that simulates a Health Thermometer device.97 * @type {ScanResult}98 */99const health_thermometer_ad_packet = {100 deviceAddress: '09:09:09:09:09:09',101 rssi: -10,102 scanRecord: {103 name: 'Health Thermometer',104 uuids: [health_thermometer.uuid],105 },106};107/**108 * An advertisement packet object that simulates a Heart Rate device.109 * @type {ScanResult}110 */111const heart_rate_ad_packet = {112 deviceAddress: '08:08:08:08:08:08',113 rssi: -10,114 scanRecord: {115 name: 'Heart Rate',116 uuids: [heart_rate.uuid],117 },118};119const uuid1234 = BluetoothUUID.getService(0x1234);120const uuid5678 = BluetoothUUID.getService(0x5678);121const uuidABCD = BluetoothUUID.getService(0xABCD);122const manufacturer1Data = new Uint8Array([1, 2]);123const manufacturer2Data = new Uint8Array([3, 4]);124const uuid1234Data = new Uint8Array([5, 6]);125const uuid5678Data = new Uint8Array([7, 8]);126const uuidABCDData = new Uint8Array([9, 10]);127/**128 * An advertisement packet object that simulates a device that advertises129 * service and manufacturer data.130 * @type {ScanResult}131 */132const service_and_manufacturer_data_ad_packet = {133 deviceAddress: '07:07:07:07:07:07',134 rssi: -10,135 scanRecord: {136 name: 'LE Device',137 uuids: [uuid1234],138 manufacturerData: {0x0001: manufacturer1Data, 0x0002: manufacturer2Data},139 serviceData: {140 [uuid1234]: uuid1234Data,141 [uuid5678]: uuid5678Data,142 [uuidABCD]: uuidABCDData143 }144 }145};146/** Bluetooth Helpers */147/**148 * Helper class to create a BluetoothCharacteristicProperties object using an149 * array of strings corresponding to the property bit to set.150 */151class TestCharacteristicProperties {152 /** @param {Array<string>} properties */153 constructor(properties) {154 this.broadcast = false;155 this.read = false;156 this.writeWithoutResponse = false;157 this.write = false;158 this.notify = false;159 this.indicate = false;160 this.authenticatedSignedWrites = false;161 this.reliableWrite = false;162 this.writableAuxiliaries = false;163 properties.forEach(val => {164 if (this.hasOwnProperty(val))165 this[val] = true;166 else167 throw `Invalid member '${val}'`;168 });169 }170}171/**172 * Produces an array of BluetoothLEScanFilterInit objects containing the list of173 * services in |services| and various permutations of the other174 * BluetoothLEScanFilterInit properties. This method is used to test that the175 * |services| are valid so the other properties do not matter.176 * @param {BluetoothServiceUUID} services177 * @returns {Array<RequestDeviceOptions>} A list of options containing178 * |services| and various permutations of other options.179 */180function generateRequestDeviceArgsWithServices(services = ['heart_rate']) {181 return [182 {filters: [{services: services}]},183 {filters: [{services: services, name: 'Name'}]},184 {filters: [{services: services, namePrefix: 'Pre'}]}, {185 filters: [186 {services: services, manufacturerData: [{companyIdentifier: 0x0001}]}187 ]188 },189 {190 filters: [{191 services: services,192 name: 'Name',193 namePrefix: 'Pre',194 manufacturerData: [{companyIdentifier: 0x0001}]195 }]196 },197 {filters: [{services: services}], optionalServices: ['heart_rate']}, {198 filters: [{services: services, name: 'Name'}],199 optionalServices: ['heart_rate']200 },201 {202 filters: [{services: services, namePrefix: 'Pre'}],203 optionalServices: ['heart_rate']204 },205 {206 filters: [207 {services: services, manufacturerData: [{companyIdentifier: 0x0001}]}208 ],209 optionalServices: ['heart_rate']210 },211 {212 filters: [{213 services: services,214 name: 'Name',215 namePrefix: 'Pre',216 manufacturerData: [{companyIdentifier: 0x0001}]217 }],218 optionalServices: ['heart_rate']219 }220 ];221}222/**223 * Causes |fake_peripheral| to disconnect and returns a promise that resolves224 * once `gattserverdisconnected` has been fired on |device|.225 * @param {BluetoothDevice} device The device to check if the226 * `gattserverdisconnected` promise was fired.227 * @param {FakePeripheral} fake_peripheral The device fake that represents228 * |device|.229 * @returns {Promise<Array<Object>>} A promise that resolves when the device has230 * successfully disconnected.231 */232function simulateGATTDisconnectionAndWait(device, fake_peripheral) {233 return Promise.all([234 eventPromise(device, 'gattserverdisconnected'),235 fake_peripheral.simulateGATTDisconnection(),236 ]);237}238/** @type {FakeCentral} The fake adapter for the current test. */239let fake_central = null;240async function initializeFakeCentral({state = 'powered-on'}) {241 if (!fake_central) {242 fake_central = await navigator.bluetooth.test.simulateCentral({state});243 }244}245/**246 * A dictionary for specifying fake Bluetooth device setup options.247 * @typedef {{address: !string, name: !string,248 * manufacturerData: !Object<uint16,Array<uint8>>,249 * knownServiceUUIDs: !Array<string>, connectable: !boolean,250 * serviceDiscoveryComplete: !boolean}}251 */252let FakeDeviceOptions;253/**254 * @typedef {{fakeDeviceOptions: FakeDeviceOptions,255 * requestDeviceOptions: RequestDeviceOptions}}256 */257let SetupOptions;258/**259 * Default options for setting up a Bluetooth device.260 * @type {FakeDeviceOptions}261 */262const fakeDeviceOptionsDefault = {263 address: '00:00:00:00:00:00',264 name: 'LE Device',265 manufacturerData: {},266 knownServiceUUIDs: [],267 connectable: false,268 serviceDiscoveryComplete: false,269};270/**271 * A dictionary containing the fake Bluetooth device object. The dictionary can272 * optionally contain its fake services and its BluetoothDevice counterpart.273 * @typedef {{fake_peripheral: !FakePeripheral,274 * fake_services: Object<string, FakeService>,275 * device: BluetoothDevice}}276 */277let FakeDevice;278/**279 * Creates a SetupOptions object using |setupOptionsDefault| as the base options280 * object with the options from |setupOptionsOverride| overriding these281 * defaults.282 * @param {SetupOptions} setupOptionsDefault The default options object to use283 * as the base.284 * @param {SetupOptions} setupOptionsOverride The options to override the285 * defaults with.286 * @returns {SetupOptions} The merged setup options containing the defaults with287 * the overrides applied.288 */289function createSetupOptions(setupOptionsDefault, setupOptionsOverride) {290 // Merge the properties of |setupOptionsDefault| and |setupOptionsOverride|291 // without modifying |setupOptionsDefault|.292 let fakeDeviceOptions = Object.assign(293 {...setupOptionsDefault.fakeDeviceOptions},294 setupOptionsOverride.fakeDeviceOptions);295 let requestDeviceOptions = Object.assign(296 {...setupOptionsDefault.requestDeviceOptions},297 setupOptionsOverride.requestDeviceOptions);298 return {fakeDeviceOptions, requestDeviceOptions};299}300/**301 * Adds a preconnected device with the given options. A preconnected device is a302 * device that has been paired with the system previously. This can be done if,303 * for example, the user pairs the device using the OS'es settings.304 *305 * By default, the preconnected device will be set up using the306 * |fakeDeviceOptionsDefault| and will not use a RequestDeviceOption object.307 * This means that the device will not be requested during the setup.308 *309 * If |setupOptionsOverride| is provided, these options will override the310 * defaults. If |setupOptionsOverride| includes the requestDeviceOptions311 * property, then the device will be requested using those options.312 * @param {SetupOptions} setupOptionsOverride An object containing options for313 * setting up a fake Bluetooth device and for requesting the device.314 * @returns {Promise<FakeDevice>} The device fake initialized with the315 * parameter values.316 */317async function setUpPreconnectedFakeDevice(setupOptionsOverride) {318 await initializeFakeCentral({state: 'powered-on'});319 let setupOptions = createSetupOptions(320 {fakeDeviceOptions: fakeDeviceOptionsDefault}, setupOptionsOverride);321 // Simulate the fake peripheral.322 let preconnectedDevice = {};323 preconnectedDevice.fake_peripheral =324 await fake_central.simulatePreconnectedPeripheral({325 address: setupOptions.fakeDeviceOptions.address,326 name: setupOptions.fakeDeviceOptions.name,327 manufacturerData: setupOptions.fakeDeviceOptions.manufacturerData,328 knownServiceUUIDs: setupOptions.fakeDeviceOptions.knownServiceUUIDs,329 });330 if (setupOptions.fakeDeviceOptions.connectable) {331 await preconnectedDevice.fake_peripheral.setNextGATTConnectionResponse(332 {code: HCI_SUCCESS});333 }334 // Add known services.335 preconnectedDevice.fake_services = new Map();336 for (let service of setupOptions.fakeDeviceOptions.knownServiceUUIDs) {337 let fake_service = await preconnectedDevice.fake_peripheral.addFakeService(338 {uuid: service});339 preconnectedDevice.fake_services.set(service, fake_service);340 }341 // Request the device if options have been provided.342 if (setupOptions.requestDeviceOptions) {343 preconnectedDevice.device =344 await requestDeviceWithTrustedClick(setupOptions.requestDeviceOptions);345 }346 // Set up services discovered state.347 if (setupOptions.fakeDeviceOptions.serviceDiscoveryComplete) {348 await preconnectedDevice.fake_peripheral.setNextGATTDiscoveryResponse(349 {code: HCI_SUCCESS});350 }351 return preconnectedDevice;352}353/**354 * Deprecated: Use setUpPreconnectedFakeDevice() instead.355 * Simulates a preconnected device with |address|, |name|, |manufacturerData|356 * and |knownServiceUUIDs|. A preconnected device is a device that has been357 * paired with the system previously. This can be done if, for example, the user358 * pairs the device using the OS'es settings.359 * TODO(https://crbug.com/1070816): Remove this method when all uses have been360 * converted to using setUpPreconnectedFakeDevice();361 * @param {string} address The device MAC address.362 * @param {string} name The device name.363 * @param {Object<uint16,Array<uint8>>} manufacturerData A map of company364 * identifier and manufacturer data to set up the fake with.365 * @param {Array<string>} knownServiceUUIDs An array of GATT service UUIDs to366 * set up the fake with.367 * @returns {Promise<FakePeripheral>} The fake devices are initialized with the368 * parameter values.369 */370async function setUpPreconnectedDevice({371 address = '00:00:00:00:00:00',372 name = 'LE Device',373 manufacturerData = {},374 knownServiceUUIDs = []375}) {376 await initializeFakeCentral({state: 'powered-on'});377 return await fake_central.simulatePreconnectedPeripheral({378 address: address,379 name: name,380 manufacturerData: manufacturerData,381 knownServiceUUIDs: knownServiceUUIDs,382 });383}384/** Blocklisted GATT Device Helper Methods */385/** @type {FakeDeviceOptions} */386const blocklistFakeDeviceOptionsDefault = {387 address: '11:11:11:11:11:11',388 name: 'Blocklist Device',389 knownServiceUUIDs: ['generic_access', blocklist_test_service_uuid],390 connectable: true,391 serviceDiscoveryComplete: true392};393/** @type {RequestDeviceOptions} */394const blocklistRequestDeviceOptionsDefault = {395 filters: [{services: [blocklist_test_service_uuid]}]396};397/** @type {SetupOptions} */398const blocklistSetupOptionsDefault = {399 fakeDeviceOptions: blocklistFakeDeviceOptionsDefault,400 requestDeviceOptions: blocklistRequestDeviceOptionsDefault401};402/**403 * Returns an object containing a BluetoothDevice discovered using |options|,404 * its corresponding FakePeripheral and FakeRemoteGATTServices.405 * The simulated device is called 'Blocklist Device' and it has one known406 * service UUID |blocklist_test_service_uuid|. The |blocklist_test_service_uuid|407 * service contains two characteristics:408 * - |blocklist_exclude_reads_characteristic_uuid| (read, write)409 * - 'gap.peripheral_privacy_flag' (read, write)410 * The 'gap.peripheral_privacy_flag' characteristic contains three descriptors:411 * - |blocklist_test_descriptor_uuid|412 * - |blocklist_exclude_reads_descriptor_uuid|413 * - 'gatt.client_characteristic_configuration'414 * These are special UUIDs that have been added to the blocklist found at415 * https://github.com/WebBluetoothCG/registries/blob/master/gatt_blocklist.txt416 * There are also test UUIDs that have been added to the test environment which417 * other implementations should add as test UUIDs as well.418 * The device has been connected to and its attributes are ready to be419 * discovered.420 * @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,421 * fake_blocklist_test_service: FakeRemoteGATTService,422 * fake_blocklist_exclude_reads_characteristic:423 * FakeRemoteGATTCharacteristic,424 * fake_blocklist_exclude_writes_characteristic:425 * FakeRemoteGATTCharacteristic,426 * fake_blocklist_descriptor: FakeRemoteGATTDescriptor,427 * fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,428 * fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor}>} An429 * object containing the BluetoothDevice object and its corresponding430 * GATT fake objects.431 */432async function getBlocklistDevice(setupOptionsOverride = {}) {433 let setupOptions =434 createSetupOptions(blocklistSetupOptionsDefault, setupOptionsOverride);435 let fakeDevice = await setUpPreconnectedFakeDevice(setupOptions);436 await fakeDevice.device.gatt.connect();437 let fake_blocklist_test_service =438 fakeDevice.fake_services.get(blocklist_test_service_uuid);439 let fake_blocklist_exclude_reads_characteristic =440 await fake_blocklist_test_service.addFakeCharacteristic({441 uuid: blocklist_exclude_reads_characteristic_uuid,442 properties: ['read', 'write'],443 });444 let fake_blocklist_exclude_writes_characteristic =445 await fake_blocklist_test_service.addFakeCharacteristic({446 uuid: 'gap.peripheral_privacy_flag',447 properties: ['read', 'write'],448 });449 let fake_blocklist_descriptor =450 await fake_blocklist_exclude_writes_characteristic.addFakeDescriptor(451 {uuid: blocklist_test_descriptor_uuid});452 let fake_blocklist_exclude_reads_descriptor =453 await fake_blocklist_exclude_writes_characteristic.addFakeDescriptor(454 {uuid: blocklist_exclude_reads_descriptor_uuid});455 let fake_blocklist_exclude_writes_descriptor =456 await fake_blocklist_exclude_writes_characteristic.addFakeDescriptor(457 {uuid: 'gatt.client_characteristic_configuration'});458 return {459 device: fakeDevice.device,460 fake_peripheral: fakeDevice.fake_peripheral,461 fake_blocklist_test_service,462 fake_blocklist_exclude_reads_characteristic,463 fake_blocklist_exclude_writes_characteristic,464 fake_blocklist_descriptor,465 fake_blocklist_exclude_reads_descriptor,466 fake_blocklist_exclude_writes_descriptor,467 };468}469/**470 * Returns an object containing a Blocklist Test BluetoothRemoteGattService and471 * its corresponding FakeRemoteGATTService.472 * @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,473 * fake_blocklist_test_service: FakeRemoteGATTService,474 * fake_blocklist_exclude_reads_characteristic:475 * FakeRemoteGATTCharacteristic,476 * fake_blocklist_exclude_writes_characteristic:477 * FakeRemoteGATTCharacteristic,478 * fake_blocklist_descriptor: FakeRemoteGATTDescriptor,479 * fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,480 * fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,481 * service: BluetoothRemoteGATTService,482 * fake_service: FakeBluetoothRemoteGATTService}>} An object containing the483 * BluetoothDevice object and its corresponding GATT fake objects.484 */485async function getBlocklistTestService() {486 let result = await getBlocklistDevice();487 let service =488 await result.device.gatt.getPrimaryService(blocklist_test_service_uuid);489 return Object.assign(result, {490 service,491 fake_service: result.fake_blocklist_test_service,492 });493}494/**495 * Returns an object containing a blocklisted BluetoothRemoteGATTCharacteristic496 * that excludes reads and its corresponding FakeRemoteGATTCharacteristic.497 * @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,498 * fake_blocklist_test_service: FakeRemoteGATTService,499 * fake_blocklist_exclude_reads_characteristic:500 * FakeRemoteGATTCharacteristic,501 * fake_blocklist_exclude_writes_characteristic:502 * FakeRemoteGATTCharacteristic,503 * fake_blocklist_descriptor: FakeRemoteGATTDescriptor,504 * fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,505 * fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,506 * service: BluetoothRemoteGATTService,507 * fake_service: FakeBluetoothRemoteGATTService,508 * characteristic: BluetoothRemoteGATTCharacteristic,509 * fake_characteristic: FakeBluetoothRemoteGATTCharacteristic}>} An object510 * containing the BluetoothDevice object and its corresponding GATT fake511 * objects.512 */513async function getBlocklistExcludeReadsCharacteristic() {514 let result = await getBlocklistTestService();515 let characteristic = await result.service.getCharacteristic(516 blocklist_exclude_reads_characteristic_uuid);517 return Object.assign(result, {518 characteristic,519 fake_characteristic: result.fake_blocklist_exclude_reads_characteristic520 });521}522/**523 * Returns an object containing a blocklisted BluetoothRemoteGATTCharacteristic524 * that excludes writes and its corresponding FakeRemoteGATTCharacteristic.525 * @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,526 * fake_blocklist_test_service: FakeRemoteGATTService,527 * fake_blocklist_exclude_reads_characteristic:528 * FakeRemoteGATTCharacteristic,529 * fake_blocklist_exclude_writes_characteristic:530 * FakeRemoteGATTCharacteristic,531 * fake_blocklist_descriptor: FakeRemoteGATTDescriptor,532 * fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,533 * fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,534 * service: BluetoothRemoteGATTService,535 * fake_service: FakeBluetoothRemoteGATTService,536 * characteristic: BluetoothRemoteGATTCharacteristic,537 * fake_characteristic: FakeBluetoothRemoteGATTCharacteristic}>} An object538 * containing the BluetoothDevice object and its corresponding GATT fake539 * objects.540 */541async function getBlocklistExcludeWritesCharacteristic() {542 let result = await getBlocklistTestService();543 let characteristic =544 await result.service.getCharacteristic('gap.peripheral_privacy_flag');545 return Object.assign(result, {546 characteristic,547 fake_characteristic: result.fake_blocklist_exclude_writes_characteristic548 });549}550/**551 * Returns an object containing a blocklisted BluetoothRemoteGATTDescriptor that552 * excludes reads and its corresponding FakeRemoteGATTDescriptor.553 * @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,554 * fake_blocklist_test_service: FakeRemoteGATTService,555 * fake_blocklist_exclude_reads_characteristic:556 * FakeRemoteGATTCharacteristic,557 * fake_blocklist_exclude_writes_characteristic:558 * FakeRemoteGATTCharacteristic,559 * fake_blocklist_descriptor: FakeRemoteGATTDescriptor,560 * fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,561 * fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,562 * service: BluetoothRemoteGATTService,563 * fake_service: FakeBluetoothRemoteGATTService,564 * characteristic: BluetoothRemoteGATTCharacteristic,565 * fake_characteristic: FakeBluetoothRemoteGATTCharacteristic,566 * descriptor: BluetoothRemoteGATTDescriptor,567 * fake_descriptor: FakeBluetoothRemoteGATTDescriptor}>} An object568 * containing the BluetoothDevice object and its corresponding GATT fake569 * objects.570 */571async function getBlocklistExcludeReadsDescriptor() {572 let result = await getBlocklistExcludeWritesCharacteristic();573 let descriptor = await result.characteristic.getDescriptor(574 blocklist_exclude_reads_descriptor_uuid);575 return Object.assign(result, {576 descriptor,577 fake_descriptor: result.fake_blocklist_exclude_reads_descriptor578 });579}580/**581 * Returns an object containing a blocklisted BluetoothRemoteGATTDescriptor that582 * excludes writes and its corresponding FakeRemoteGATTDescriptor.583 * @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,584 * fake_blocklist_test_service: FakeRemoteGATTService,585 * fake_blocklist_exclude_reads_characteristic:586 * FakeRemoteGATTCharacteristic,587 * fake_blocklist_exclude_writes_characteristic:588 * FakeRemoteGATTCharacteristic,589 * fake_blocklist_descriptor: FakeRemoteGATTDescriptor,590 * fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,591 * fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,592 * service: BluetoothRemoteGATTService,593 * fake_service: FakeBluetoothRemoteGATTService,594 * characteristic: BluetoothRemoteGATTCharacteristic,595 * fake_characteristic: FakeBluetoothRemoteGATTCharacteristic,596 * descriptor: BluetoothRemoteGATTDescriptor,597 * fake_descriptor: FakeBluetoothRemoteGATTDescriptor}>} An object598 * containing the BluetoothDevice object and its corresponding GATT fake599 * objects.600 */601async function getBlocklistExcludeWritesDescriptor() {602 let result = await getBlocklistExcludeWritesCharacteristic();603 let descriptor = await result.characteristic.getDescriptor(604 'gatt.client_characteristic_configuration');605 return Object.assign(result, {606 descriptor: descriptor,607 fake_descriptor: result.fake_blocklist_exclude_writes_descriptor,608 });609}610/** Bluetooth HID Device Helper Methods */611/** @type {FakeDeviceOptions} */612const connectedHIDFakeDeviceOptionsDefault = {613 address: '10:10:10:10:10:10',614 name: 'HID Device',615 knownServiceUUIDs: [616 'generic_access',617 'device_information',618 'human_interface_device',619 ],620 connectable: true,621 serviceDiscoveryComplete: false622};623/** @type {RequestDeviceOptions} */624const connectedHIDRequestDeviceOptionsDefault = {625 filters: [{services: ['device_information']}],626 optionalServices: ['human_interface_device']627};628/** @type {SetupOptions} */629const connectedHIDSetupOptionsDefault = {630 fakeDeviceOptions: connectedHIDFakeDeviceOptionsDefault,631 requestDeviceOptions: connectedHIDRequestDeviceOptionsDefault632};633/**634 * Similar to getHealthThermometerDevice except the GATT discovery635 * response has not been set yet so more attributes can still be added.636 * TODO(crbug.com/719816): Add descriptors.637 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth638 * Device.639 * @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object640 * containing a requested BluetoothDevice and its fake counter part.641 */642async function getConnectedHIDDevice(643 requestDeviceOptionsOverride, fakeDeviceOptionsOverride) {644 let setupOptions = createSetupOptions(connectedHIDSetupOptionsDefault, {645 fakeDeviceOptions: fakeDeviceOptionsOverride,646 requestDeviceOptions: requestDeviceOptionsOverride647 });648 let fakeDevice = await setUpPreconnectedFakeDevice(setupOptions);649 await fakeDevice.device.gatt.connect();650 // Blocklisted Characteristic:651 // https://github.com/WebBluetoothCG/registries/blob/master/gatt_blocklist.txt652 let dev_info = fakeDevice.fake_services.get('device_information');653 await dev_info.addFakeCharacteristic({654 uuid: 'serial_number_string',655 properties: ['read'],656 });657 return fakeDevice;658}659/**660 * Returns a BluetoothDevice discovered using |options| and its661 * corresponding FakePeripheral.662 * The simulated device is called 'HID Device' it has three known service663 * UUIDs: 'generic_access', 'device_information', 'human_interface_device'.664 * The primary service with 'device_information' UUID has a characteristics665 * with UUID 'serial_number_string'. The device has been connected to and its666 * attributes are ready to be discovered.667 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth668 * Device.669 * @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object670 * containing a requested BluetoothDevice and its fake counter part.671 */672async function getHIDDevice(options) {673 let result =674 await getConnectedHIDDevice(options, {serviceDiscoveryComplete: true});675 return result;676}677/** Health Thermometer Bluetooth Device Helper Methods */678/**679 * Returns a FakePeripheral that corresponds to a simulated pre-connected device680 * called 'Health Thermometer'. The device has two known serviceUUIDs:681 * 'generic_access' and 'health_thermometer' and some fake manufacturer data.682 * @returns {Promise<FakePeripheral>} The device fake initialized as a Health683 * Thermometer device.684 */685function setUpHealthThermometerDevice() {686 return setUpPreconnectedDevice({687 address: '09:09:09:09:09:09',688 name: 'Health Thermometer',689 manufacturerData: {0x0001: manufacturer1Data, 0x0002: manufacturer2Data},690 knownServiceUUIDs: ['generic_access', 'health_thermometer'],691 });692}693/**694 * Returns the same fake peripheral as setUpHealthThermometerDevice() except695 * that connecting to the peripheral will succeed.696 * @returns {Promise<FakePeripheral>} The device fake initialized as a697 * connectable Health Thermometer device.698 */699async function setUpConnectableHealthThermometerDevice() {700 let fake_peripheral = await setUpHealthThermometerDevice();701 await fake_peripheral.setNextGATTConnectionResponse({702 code: HCI_SUCCESS,703 });704 return fake_peripheral;705}706/**707 * Populates a fake_peripheral with various fakes appropriate for a health708 * thermometer. This resolves to an associative array composed of the fakes,709 * including the |fake_peripheral|.710 * @param {FakePeripheral} fake_peripheral The Bluetooth fake to populate GATT711 * services, characteristics, and descriptors on.712 * @returns {Promise<{fake_peripheral: FakePeripheral,713 * fake_generic_access: FakeRemoteGATTService,714 * fake_health_thermometer: FakeRemoteGATTService,715 * fake_measurement_interval: FakeRemoteGATTCharacteristic,716 * fake_cccd: FakeRemoteGATTDescriptor,717 * fake_user_description: FakeRemoteGATTDescriptor,718 * fake_temperature_measurement: FakeRemoteGATTCharacteristic,719 * fake_temperature_type: FakeRemoteGATTCharacteristic}>} The FakePeripheral720 * passed into this method along with the fake GATT services, characteristics,721 * and descriptors added to it.722 */723async function populateHealthThermometerFakes(fake_peripheral) {724 let fake_generic_access =725 await fake_peripheral.addFakeService({uuid: 'generic_access'});726 let fake_health_thermometer = await fake_peripheral.addFakeService({727 uuid: 'health_thermometer',728 });729 let fake_measurement_interval =730 await fake_health_thermometer.addFakeCharacteristic({731 uuid: 'measurement_interval',732 properties: ['read', 'write', 'indicate'],733 });734 let fake_user_description =735 await fake_measurement_interval.addFakeDescriptor({736 uuid: 'gatt.characteristic_user_description',737 });738 let fake_cccd = await fake_measurement_interval.addFakeDescriptor({739 uuid: 'gatt.client_characteristic_configuration',740 });741 let fake_temperature_measurement =742 await fake_health_thermometer.addFakeCharacteristic({743 uuid: 'temperature_measurement',744 properties: ['indicate'],745 });746 let fake_temperature_type =747 await fake_health_thermometer.addFakeCharacteristic({748 uuid: 'temperature_type',749 properties: ['read'],750 });751 return {752 fake_peripheral,753 fake_generic_access,754 fake_health_thermometer,755 fake_measurement_interval,756 fake_cccd,757 fake_user_description,758 fake_temperature_measurement,759 fake_temperature_type,760 };761}762/**763 * Returns the same device and fake peripheral as getHealthThermometerDevice()764 * after another frame (an iframe we insert) discovered the device,765 * connected to it and discovered its services.766 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth767 * Device.768 * @returns {Promise<{device: BluetoothDevice, fakes: {769 * fake_peripheral: FakePeripheral,770 * fake_generic_access: FakeRemoteGATTService,771 * fake_health_thermometer: FakeRemoteGATTService,772 * fake_measurement_interval: FakeRemoteGATTCharacteristic,773 * fake_cccd: FakeRemoteGATTDescriptor,774 * fake_user_description: FakeRemoteGATTDescriptor,775 * fake_temperature_measurement: FakeRemoteGATTCharacteristic,776 * fake_temperature_type: FakeRemoteGATTCharacteristic}}>} An object777 * containing a requested BluetoothDevice and all of the GATT fake778 * objects.779 */780async function getHealthThermometerDeviceWithServicesDiscovered(options) {781 let iframe = document.createElement('iframe');782 let fake_peripheral = await setUpConnectableHealthThermometerDevice();783 let fakes = populateHealthThermometerFakes(fake_peripheral);784 await fake_peripheral.setNextGATTDiscoveryResponse({785 code: HCI_SUCCESS,786 });787 await new Promise(resolve => {788 let src = '/bluetooth/resources/health-thermometer-iframe.html';789 // TODO(509038): Can be removed once LayoutTests/bluetooth/* that790 // use health-thermometer-iframe.html have been moved to791 // LayoutTests/external/wpt/bluetooth/*792 if (window.location.pathname.includes('/LayoutTests/')) {793 src =794 '../../../external/wpt/bluetooth/resources/health-thermometer-iframe.html';795 }796 iframe.src = src;797 document.body.appendChild(iframe);798 iframe.addEventListener('load', resolve);799 });800 await new Promise((resolve, reject) => {801 callWithTrustedClick(() => {802 iframe.contentWindow.postMessage(803 {type: 'DiscoverServices', options: options}, '*');804 });805 function messageHandler(messageEvent) {806 if (messageEvent.data == 'DiscoveryComplete') {807 window.removeEventListener('message', messageHandler);808 resolve();809 } else {810 reject(new Error(`Unexpected message: ${messageEvent.data}`));811 }812 }813 window.addEventListener('message', messageHandler);814 });815 let device = await requestDeviceWithTrustedClick(options);816 await device.gatt.connect();817 return Object.assign({device}, fakes);818}819/**820 * Similar to getHealthThermometerDevice() except the device821 * is not connected and thus its services have not been822 * discovered.823 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth824 * Device.825 * @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object826 * containing a requested BluetoothDevice and its fake counter part.827 */828async function getDiscoveredHealthThermometerDevice(options = {829 filters: [{services: ['health_thermometer']}]830}) {831 let fake_peripheral = await setUpHealthThermometerDevice();832 let device = await requestDeviceWithTrustedClick(options);833 return {device: device, fake_peripheral: fake_peripheral};834}835/**836 * Similar to getHealthThermometerDevice() except the device has no services,837 * characteristics, or descriptors.838 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth839 * Device.840 * @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object841 * containing a requested BluetoothDevice and its fake counter part.842 */843async function getEmptyHealthThermometerDevice(options) {844 let result = await getDiscoveredHealthThermometerDevice(options);845 await result.fake_peripheral.setNextGATTConnectionResponse(846 {code: HCI_SUCCESS});847 await result.device.gatt.connect();848 await result.fake_peripheral.setNextGATTDiscoveryResponse(849 {code: HCI_SUCCESS});850 return result;851}852/**853 * Similar to getHealthThermometerService() except the service has no854 * characteristics or included services.855 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth856 * Device.857 * @returns {service: BluetoothRemoteGATTService,858 * fake_health_thermometer: FakeRemoteGATTService} An object containing the859 * health themometer service object and its corresponding fake.860 */861async function getEmptyHealthThermometerService(options) {862 let result = await getDiscoveredHealthThermometerDevice(options);863 await result.fake_peripheral.setNextGATTConnectionResponse(864 {code: HCI_SUCCESS});865 await result.device.gatt.connect();866 let fake_health_thermometer =867 await result.fake_peripheral.addFakeService({uuid: 'health_thermometer'});868 await result.fake_peripheral.setNextGATTDiscoveryResponse(869 {code: HCI_SUCCESS});870 let service =871 await result.device.gatt.getPrimaryService('health_thermometer');872 return {873 service: service,874 fake_health_thermometer: fake_health_thermometer,875 };876}877/**878 * Similar to getHealthThermometerDevice except the GATT discovery879 * response has not been set yet so more attributes can still be added.880 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth881 * Device.882 * @returns {Promise<{device: BluetoothDevice, fakes: {883 * fake_peripheral: FakePeripheral,884 * fake_generic_access: FakeRemoteGATTService,885 * fake_health_thermometer: FakeRemoteGATTService,886 * fake_measurement_interval: FakeRemoteGATTCharacteristic,887 * fake_cccd: FakeRemoteGATTDescriptor,888 * fake_user_description: FakeRemoteGATTDescriptor,889 * fake_temperature_measurement: FakeRemoteGATTCharacteristic,890 * fake_temperature_type: FakeRemoteGATTCharacteristic}}>} An object891 * containing a requested BluetoothDevice and all of the GATT fake892 * objects.893 */894async function getConnectedHealthThermometerDevice(options) {895 let result = await getDiscoveredHealthThermometerDevice(options);896 await result.fake_peripheral.setNextGATTConnectionResponse({897 code: HCI_SUCCESS,898 });899 let fakes = await populateHealthThermometerFakes(result.fake_peripheral);900 await result.device.gatt.connect();901 return Object.assign({device: result.device}, fakes);902}903/**904 * Returns an object containing a BluetoothDevice discovered using |options|,905 * its corresponding FakePeripheral and FakeRemoteGATTServices.906 * The simulated device is called 'Health Thermometer' it has two known service907 * UUIDs: 'generic_access' and 'health_thermometer' which correspond to two908 * services with the same UUIDs. The 'health thermometer' service contains three909 * characteristics:910 * - 'temperature_measurement' (indicate),911 * - 'temperature_type' (read),912 * - 'measurement_interval' (read, write, indicate)913 * The 'measurement_interval' characteristic contains a914 * 'gatt.client_characteristic_configuration' descriptor and a915 * 'characteristic_user_description' descriptor.916 * The device has been connected to and its attributes are ready to be917 * discovered.918 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth919 * Device.920 * @returns {Promise<{device: BluetoothDevice, fakes: {921 * fake_peripheral: FakePeripheral,922 * fake_generic_access: FakeRemoteGATTService,923 * fake_health_thermometer: FakeRemoteGATTService,924 * fake_measurement_interval: FakeRemoteGATTCharacteristic,925 * fake_cccd: FakeRemoteGATTDescriptor,926 * fake_user_description: FakeRemoteGATTDescriptor,927 * fake_temperature_measurement: FakeRemoteGATTCharacteristic,928 * fake_temperature_type: FakeRemoteGATTCharacteristic}}>} An object929 * containing a requested BluetoothDevice and all of the GATT fake930 * objects.931 */932async function getHealthThermometerDevice(options) {933 let result = await getConnectedHealthThermometerDevice(options);934 await result.fake_peripheral.setNextGATTDiscoveryResponse({935 code: HCI_SUCCESS,936 });937 return result;938}939/**940 * Similar to getHealthThermometerDevice except that the peripheral has two941 * 'health_thermometer' services.942 * @param {RequestDeviceOptions} options The options for requesting a Bluetooth943 * Device.944 * @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,945 * fake_generic_access: FakeRemoteGATTService, fake_health_thermometer1:946 * FakeRemoteGATTService, fake_health_thermometer2: FakeRemoteGATTService}>} An947 * object containing a requested Bluetooth device and two fake health948 * thermometer GATT services.949 */950async function getTwoHealthThermometerServicesDevice(options) {951 let result = await getConnectedHealthThermometerDevice(options);952 let fake_health_thermometer2 =953 await result.fake_peripheral.addFakeService({uuid: 'health_thermometer'});954 await result.fake_peripheral.setNextGATTDiscoveryResponse(955 {code: HCI_SUCCESS});956 return {957 device: result.device,958 fake_peripheral: result.fake_peripheral,959 fake_generic_access: result.fake_generic_access,960 fake_health_thermometer1: result.fake_health_thermometer,961 fake_health_thermometer2: fake_health_thermometer2962 };963}964/**965 * Returns an object containing a Health Thermometer BluetoothRemoteGattService966 * and its corresponding FakeRemoteGATTService.967 * @returns {Promise<{device: BluetoothDevice, fakes: {968 * fake_peripheral: FakePeripheral,969 * fake_generic_access: FakeRemoteGATTService,970 * fake_health_thermometer: FakeRemoteGATTService,971 * fake_measurement_interval: FakeRemoteGATTCharacteristic,972 * fake_cccd: FakeRemoteGATTDescriptor,973 * fake_user_description: FakeRemoteGATTDescriptor,974 * fake_temperature_measurement: FakeRemoteGATTCharacteristic,975 * fake_temperature_type: FakeRemoteGATTCharacteristic,976 * service: BluetoothRemoteGATTService,977 * fake_service: FakeRemoteGATTService}}>} An object978 * containing a requested BluetoothDevice and all of the GATT fake979 * objects.980 */981async function getHealthThermometerService() {982 let result = await getHealthThermometerDevice();983 let service =984 await result.device.gatt.getPrimaryService('health_thermometer');985 return Object.assign(result, {986 service,987 fake_service: result.fake_health_thermometer,988 });989}990/**991 * Returns an object containing a Measurement Interval992 * BluetoothRemoteGATTCharacteristic and its corresponding993 * FakeRemoteGATTCharacteristic.994 * @returns {Promise<{device: BluetoothDevice, fakes: {995 * fake_peripheral: FakePeripheral,996 * fake_generic_access: FakeRemoteGATTService,997 * fake_health_thermometer: FakeRemoteGATTService,998 * fake_measurement_interval: FakeRemoteGATTCharacteristic,999 * fake_cccd: FakeRemoteGATTDescriptor,1000 * fake_user_description: FakeRemoteGATTDescriptor,1001 * fake_temperature_measurement: FakeRemoteGATTCharacteristic,1002 * fake_temperature_type: FakeRemoteGATTCharacteristic,1003 * service: BluetoothRemoteGATTService,1004 * fake_service: FakeRemoteGATTService,1005 * characteristic: BluetoothRemoteGATTCharacteristic,1006 * fake_characteristic: FakeRemoteGATTCharacteristic}}>} An object1007 * containing a requested BluetoothDevice and all of the GATT fake1008 * objects.1009 */1010async function getMeasurementIntervalCharacteristic() {1011 let result = await getHealthThermometerService();1012 let characteristic =1013 await result.service.getCharacteristic('measurement_interval');1014 return Object.assign(result, {1015 characteristic,1016 fake_characteristic: result.fake_measurement_interval,1017 });1018}1019/**1020 * Returns an object containing a User Description1021 * BluetoothRemoteGATTDescriptor and its corresponding1022 * FakeRemoteGATTDescriptor.1023 * @returns {Promise<{device: BluetoothDevice, fakes: {1024 * fake_peripheral: FakePeripheral,1025 * fake_generic_access: FakeRemoteGATTService,1026 * fake_health_thermometer: FakeRemoteGATTService,1027 * fake_measurement_interval: FakeRemoteGATTCharacteristic,1028 * fake_cccd: FakeRemoteGATTDescriptor,1029 * fake_user_description: FakeRemoteGATTDescriptor,1030 * fake_temperature_measurement: FakeRemoteGATTCharacteristic,1031 * fake_temperature_type: FakeRemoteGATTCharacteristic,1032 * service: BluetoothRemoteGATTService,1033 * fake_service: FakeRemoteGATTService,1034 * characteristic: BluetoothRemoteGATTCharacteristic,1035 * fake_characteristic: FakeRemoteGATTCharacteristic1036 * descriptor: BluetoothRemoteGATTDescriptor,1037 * fake_descriptor: FakeRemoteGATTDescriptor}}>} An object1038 * containing a requested BluetoothDevice and all of the GATT fake1039 * objects.1040 */1041async function getUserDescriptionDescriptor() {1042 let result = await getMeasurementIntervalCharacteristic();1043 let descriptor = await result.characteristic.getDescriptor(1044 'gatt.characteristic_user_description');1045 return Object.assign(result, {1046 descriptor,1047 fake_descriptor: result.fake_user_description,1048 });1049}1050/** Heart Rate Bluetooth Device Helper Methods */1051/** @type {FakeDeviceOptions} */1052const heartRateFakeDeviceOptionsDefault = {1053 address: '08:08:08:08:08:08',1054 name: 'Heart Rate',1055 knownServiceUUIDs: ['generic_access', 'heart_rate'],1056 connectable: false,1057 serviceDiscoveryComplete: false,1058};1059/** @type {RequestDeviceOptions} */1060const heartRateRequestDeviceOptionsDefault = {1061 filters: [{services: ['heart_rate']}]1062};1063async function getHeartRateDevice(setupOptionsOverride) {1064 let setupOptions = createSetupOptions(1065 {fakeDeviceOptions: heartRateFakeDeviceOptionsDefault},1066 setupOptionsOverride);1067 return await setUpPreconnectedFakeDevice(setupOptions);1068}1069/**1070 * Returns an array containing two FakePeripherals corresponding1071 * to the simulated devices.1072 * @returns {Promise<Array<FakePeripheral>>} The device fakes initialized as1073 * Health Thermometer and Heart Rate devices.1074 */1075async function setUpHealthThermometerAndHeartRateDevices() {1076 await initializeFakeCentral({state: 'powered-on'});1077 return Promise.all([1078 fake_central.simulatePreconnectedPeripheral({1079 address: '09:09:09:09:09:09',1080 name: 'Health Thermometer',1081 manufacturerData: {},1082 knownServiceUUIDs: ['generic_access', 'health_thermometer'],1083 }),1084 fake_central.simulatePreconnectedPeripheral({1085 address: '08:08:08:08:08:08',1086 name: 'Heart Rate',1087 manufacturerData: {},1088 knownServiceUUIDs: ['generic_access', 'heart_rate'],1089 })1090 ]);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var uuid = wptoolkit.uuidABCDData();3console.log(uuid);4var wptoolkit = require('wptoolkit');5var uuid = wptoolkit.uuidABCDData();6console.log(uuid);7var wptoolkit = require('wptoolkit');8var uuid = wptoolkit.uuidABCDData();9console.log(uuid);10var wptoolkit = require('wptoolkit');11var uuid = wptoolkit.uuidABCDData();12console.log(uuid);13var wptoolkit = require('wptoolkit');14var uuid = wptoolkit.uuidABCDData();15console.log(uuid);16var wptoolkit = require('wptoolkit');17var uuid = wptoolkit.uuidABCDData();18console.log(uuid);19var wptoolkit = require('wptoolkit');20var uuid = wptoolkit.uuidABCDData();21console.log(uuid);22var wptoolkit = require('wptoolkit');23var uuid = wptoolkit.uuidABCDData();24console.log(uuid);25var wptoolkit = require('wptoolkit');26var uuid = wptoolkit.uuidABCDData();27console.log(uuid);28var wptoolkit = require('wptoolkit');29var uuid = wptoolkit.uuidABCDData();30console.log(uuid);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.uuidABCDData('uuidABCD', function (error, data) {3 if (error) {4 } else {5 }6});7var wpt = require('wpt');8wpt.uuidABCDData('uuidABCD', function (error, data) {9 if (error) {10 } else {11 }12});13var wpt = require('wpt');14wpt.uuidABCDData('uuidABCD', function (error, data) {15 if (error) {16 } else {17 }18});19var wpt = require('wpt');20wpt.uuidABCDData('uuidABCD', function (error, data) {21 if (error) {22 } else {23 }24});25var wpt = require('wpt');26wpt.uuidABCDData('uuidABCD', function (error, data) {27 if (error) {28 } else {29 }30});31var wpt = require('wpt');32wpt.uuidABCDData('uuidABCD', function (error, data) {33 if (error) {34 } else {35 }36});37var wpt = require('wpt');38wpt.uuidABCDData('uuidABCD', function (error, data) {39 if (error) {40 } else {41 }42});43var wpt = require('w

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var uuidABCDData = wpt.uuidABCDData('1234567890');3console.log(uuidABCDData);4var wpt = require('wpt');5var uuidABCDData = wpt.uuidABCDData('1234567890', '1');6console.log(uuidABCDData);7var wpt = require('wpt');8var uuidABCDData = wpt.uuidABCDData('1234567890', '1', '1');9console.log(uuidABCDData);10var wpt = require('wpt');11var uuidABCDData = wpt.uuidABCDData('1234567890', '1', '1', '1');12console.log(uuidABCDData);13var wpt = require('wpt');14var uuidABCDData = wpt.uuidABCDData('1234567890', '1', '1', '1', '1');15console.log(uuidABCDData);16var wpt = require('wpt');17var uuidABCDData = wpt.uuidABCDData('1234567890', '1', '1', '1', '1', '1');18console.log(uuidABCDData);19var wpt = require('wpt');20var uuidABCDData = wpt.uuidABCDData('1234567890', '1', '1', '1', '1', '1', '1');21console.log(uuidABCDData);22var wpt = require('wpt');23var uuidABCDData = wpt.uuidABCDData('1234567890', '1', '1', '1', '1', '1', '1', '1');24console.log(uuidABCDData);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.uuidABCDData('abcd-1234-efgh-5678', function(err, response) {3 if (err) {4 console.log(err);5 } else {6 console.log(JSON.stringify(response));7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var uuid = require('uuid');3var uuidABCD = uuid.v4();4console.log(uuidABCD);5wptools.uuidABCDData(uuidABCD, function(response) {6 console.log(response);7});8var wptools = require('wptools');9var uuid = require('uuid');10var uuidABCD = uuid.v4();11console.log(uuidABCD);12wptools.uuidABCDData(uuidABCD, function(response) {13 console.log(response);14});15var wptools = require('wptools');16var uuid = require('uuid');17var uuidABCD = uuid.v4();18console.log(uuidABCD);19wptools.uuidABCDData(uuidABCD, function(response) {20 console.log(response);21});22var wptools = require('wptools');23var uuid = require('uuid');24var uuidABCD = uuid.v4();25console.log(uuidABCD);26wptools.uuidABCDData(uuidABCD, function(response) {27 console.log(response);28});29var wptools = require('wptools');30var uuid = require('uuid');31var uuidABCD = uuid.v4();32console.log(uuidABCD);33wptools.uuidABCDData(uuidABCD, function(response) {34 console.log(response);35});36var wptools = require('wptools');37var uuid = require('uuid');38var uuidABCD = uuid.v4();39console.log(uuidABCD);40wptools.uuidABCDData(uuidABCD, function(response) {41 console.log(response);42});43var wptools = require('wptools');44var uuid = require('uuid');45var uuidABCD = uuid.v4();46console.log(uuidABCD);47wptools.uuidABCDData(uuidABCD, function(response) {48 console.log(response);49});

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log(wpt.uuidABCDData);2console.log(wpt.uuidABCDData);3console.log(wpt.uuidABCDData);4console.log(wpt.uuidABCDData);5console.log(wpt.uuidABCDData);6console.log(wpt.uuidABCDData);7console.log(wpt.uuidABCDData);8console.log(wpt.uuidABCDData);9console.log(wpt.uuidABCDData);10console.log(wpt.uuidABCDData);11console.log(wpt.uuidABCDData);12console.log(wpt.uuidABCDData);13console.log(wpt.uuidABCDData);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2wpt.uuidABCDData('uuid', 'abcd', function(data) {3 console.log(data);4});5var exports = module.exports = {};6exports.uuidABCDData = function(uuid, abcd, callback) {7 var data = '';8 http.get(url, function(res) {9 res.on('data', function(chunk) {10 data += chunk;11 });12 res.on('end', function() {13 data = JSON.parse(data);14 callback(data.data.median[abcd]);15 });16 }).on('error', function(e) {17 console.log('error: ' + e.message);18 });19};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var uuid = require('uuid');3var id = uuid.v4();4console.log("uuid: " + id);5var options = {6};7wptools.page(options).then(function (page) {8 console.log("page: " + page);9 return page.uuidABCDData();10}).then(function (result) {11 console.log("result: " + result);12 console.log(result);13}).catch(function (error) {14 console.log("error: " + error);15 console.log(error);16});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('wpt-api');2const uuid = wpt.uuidABCDData();3console.log(uuid);4const wpt = require('wpt-api');5const uuid = wpt.uuidABCD();6console.log(uuid);7const wpt = require('wpt-api');8const uuid = wpt.uuidAB();9console.log(uuid);10const wpt = require('wpt-api');11const uuid = wpt.uuid();12console.log(uuid);13const wpt = require('wpt-api');14const uuid = wpt.uuidData();15console.log(uuid);16const wpt = require('wpt-api');17const uuid = wpt.uuidData();18console.log(uuid);19const wpt = require('wpt-api');20const uuid = wpt.uuidData();21console.log(uuid);22const wpt = require('wpt-api');23const uuid = wpt.uuidData();24console.log(uuid);25const wpt = require('wpt-api');26const uuid = wpt.uuidData();27console.log(uuid);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { uuidABCDData } from 'wpt-uuid-abcd';2const uuid = uuidABCDData();3console.log(uuid);4import { uuidABCDData } from 'wpt-uuid-abcd';5const uuid = uuidABCDData(4);6console.log(uuid);7import { uuidABCDData } from 'wpt-uuid-abcd';8const uuid = uuidABCDData(8);9console.log(uuid);10import { uuidABCDData } from 'wpt-uuid-abcd';11const uuid = uuidABCDData(16);12console.log(uuid);13import { uuidABCDData } from 'wpt-uuid-abcd';14const uuid = uuidABCDData(32);15console.log(uuid);16import { uuidABCDData } from 'wpt-uuid-abcd';

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful