| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <script src="../../resources/testharness.js"></script> | |
| 3 <script src="../../resources/testharnessreport.js"></script> | |
| 4 <script src="../../resources/bluetooth/bluetooth-helpers.js"></script> | |
| 5 <script> | |
| 6 'use strict'; | |
| 7 // The following tests make sure the Web Bluetooth implementation | |
| 8 // responds correctly to the different types of errors the | |
| 9 // underlying platform might throw. | |
| 10 | |
| 11 // Each implementation maps these devices to specific code paths | |
| 12 // that result in different errors thus increasing code coverage | |
| 13 // when testing. Therefore some of these devices might not be useful | |
| 14 // for all implementations. | |
| 15 | |
| 16 let connection_test_specs = [{ | |
| 17 testName: 'Unknown error when connnecting.', | |
| 18 uuid: errorUUID(0x0), | |
| 19 error: new DOMException('Unknown error when connecting to the device.', | |
| 20 'NetworkError') | |
| 21 }, { | |
| 22 testName: 'Connection was already in progress.', | |
| 23 uuid: errorUUID(0x1), | |
| 24 error: new DOMException('Connection already in progress.', | |
| 25 'NetworkError') | |
| 26 }, { | |
| 27 testName: 'Connection failed.', | |
| 28 uuid: errorUUID(0x2), | |
| 29 error: new DOMException('Connection failed for unknown reason.', | |
| 30 'NetworkError') | |
| 31 }, { | |
| 32 testName: 'Authentication failed when connecting.', | |
| 33 uuid: errorUUID(0x3), | |
| 34 error: new DOMException('Authentication failed.', | |
| 35 'NetworkError') | |
| 36 }, { | |
| 37 testName: 'Authentication canceled when connecting.', | |
| 38 uuid: errorUUID(0x4), | |
| 39 error: new DOMException('Authentication canceled.', | |
| 40 'NetworkError') | |
| 41 }, { | |
| 42 testName: 'Authentication rejected when connecting.', | |
| 43 uuid: errorUUID(0x5), | |
| 44 error: new DOMException('Authentication rejected.', | |
| 45 'NetworkError') | |
| 46 }, { | |
| 47 testName: 'Authentication timed out when connecting.', | |
| 48 uuid: errorUUID(0x6), | |
| 49 error: new DOMException('Authentication timeout.', | |
| 50 'NetworkError') | |
| 51 }, { | |
| 52 testName: 'Tried to connect to an unsupported device.', | |
| 53 uuid: errorUUID(0x7), | |
| 54 error: new DOMException('Unsupported device.', | |
| 55 'NetworkError') | |
| 56 }, { | |
| 57 testName: 'A write operation exceeds the maximum length of the attribute.', | |
| 58 uuid: errorUUID(0x8), | |
| 59 error: new DOMException('Attribute length invalid.', | |
| 60 'NetworkError') | |
| 61 }, { | |
| 62 testName: 'A remote device connection is congested.', | |
| 63 uuid: errorUUID(0x9), | |
| 64 error: new DOMException('Connection congested.', | |
| 65 'NetworkError') | |
| 66 }, { | |
| 67 testName: 'Insufficient encryption for a given operation.', | |
| 68 uuid: errorUUID(0xa), | |
| 69 error: new DOMException('Insufficient encryption.', | |
| 70 'NetworkError') | |
| 71 }, { | |
| 72 testName: 'A read or write operation was requested with an invalid offset.', | |
| 73 uuid: errorUUID(0xb), | |
| 74 error: new DOMException('Offset invalid.', | |
| 75 'NetworkError') | |
| 76 }, { | |
| 77 testName: 'GATT read operation is not permitted.', | |
| 78 uuid: errorUUID(0xc), | |
| 79 error: new DOMException('Read not permitted.', | |
| 80 'NetworkError') | |
| 81 }, { | |
| 82 testName: 'The given request is not supported.', | |
| 83 uuid: errorUUID(0xd), | |
| 84 error: new DOMException('Request not supported.', | |
| 85 'NetworkError') | |
| 86 }, { | |
| 87 testName: 'GATT write operation is not permitted.', | |
| 88 uuid: errorUUID(0xe), | |
| 89 error: new DOMException('Write not permitted.', | |
| 90 'NetworkError') | |
| 91 }]; | |
| 92 | |
| 93 promise_test(() => { | |
| 94 return setBluetoothFakeAdapter('FailingConnectionsAdapter') | |
| 95 .then(() => { | |
| 96 let test_promises = Promise.resolve(); | |
| 97 connection_test_specs.forEach(testSpec => { | |
| 98 test_promises = test_promises | |
| 99 .then(() => requestDeviceWithKeyDown({ | |
| 100 filters: [{services: [testSpec.uuid]}]})); | |
| 101 // This test was not returning the assert_promise_rejects_with_messa
ge | |
| 102 // promise so when the underlying implementation of BluetoothDevice | |
| 103 // changed no one noticed that the promise started to reject. | |
| 104 // Furthermore, no platform returns the new errors added so they | |
| 105 // need to be cleaned up. | |
| 106 // TODO(ortuno): Re-enable the test when the errors are cleaned up. | |
| 107 // http://crbug.com/598341 | |
| 108 // .then(device => assert_promise_rejects_with_message( | |
| 109 // device.gatt.connect(), | |
| 110 // testSpec.error, | |
| 111 // testSpec.testName)); | |
| 112 }); | |
| 113 return test_promises; | |
| 114 }); | |
| 115 }, 'Adapter fails to connect to device. Should reject with the correct ' + | |
| 116 'exception.'); | |
| 117 </script> | |
| OLD | NEW |