OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script> | 4 <script> |
5 var base_uuid = "00000000-0000-1000-8000-00805f9b34fb" | 5 var base_uuid = "00000000-0000-1000-8000-00805f9b34fb" |
6 | 6 |
7 test(function() { | 7 test(function() { |
8 var base_alias = 0x0 | 8 var base_alias = 0x0 |
9 assert_equals(BluetoothUUID.getService(base_alias), base_uuid); | 9 assert_equals(BluetoothUUID.getService(base_alias), base_uuid); |
10 assert_equals(BluetoothUUID.getCharacteristic(base_alias), base_uuid); | 10 assert_equals(BluetoothUUID.getCharacteristic(base_alias), base_uuid); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 BluetoothUUID.getDescriptor(wrong_name); | 143 BluetoothUUID.getDescriptor(wrong_name); |
144 }); | 144 }); |
145 }, "Invalid Descriptor name"); | 145 }, "Invalid Descriptor name"); |
146 | 146 |
147 test(function() { | 147 test(function() { |
148 var object = {}; | 148 var object = {}; |
149 var array = []; | 149 var array = []; |
150 var func = function() {}; | 150 var func = function() {}; |
151 | 151 |
152 // cannonicalUUID | 152 // cannonicalUUID |
153 assert_equals(BluetoothUUID.canonicalUUID(object), base_uuid); | 153 assert_throws(new TypeError, function() {BluetoothUUID.canonicalUUID(object)})
; |
| 154 // [] converts to "", which converts to 0 before the range check. |
154 assert_equals(BluetoothUUID.canonicalUUID(array), base_uuid); | 155 assert_equals(BluetoothUUID.canonicalUUID(array), base_uuid); |
155 assert_equals(BluetoothUUID.canonicalUUID(func), base_uuid); | 156 assert_throws(new TypeError, function() {BluetoothUUID.canonicalUUID(func)}); |
156 assert_equals(BluetoothUUID.canonicalUUID(undefined), base_uuid); | 157 assert_throws(new TypeError, function() {BluetoothUUID.canonicalUUID(undefined
)}); |
157 assert_equals(BluetoothUUID.canonicalUUID(null), base_uuid); | 158 assert_equals(BluetoothUUID.canonicalUUID(null), base_uuid); |
158 assert_equals(BluetoothUUID.canonicalUUID(false), base_uuid); | 159 assert_equals(BluetoothUUID.canonicalUUID(false), base_uuid); |
159 assert_equals(BluetoothUUID.canonicalUUID(NaN), base_uuid); | 160 assert_equals(BluetoothUUID.canonicalUUID(true), BluetoothUUID.canonicalUUID(1
)); |
| 161 assert_throws(new TypeError, function() {BluetoothUUID.canonicalUUID(NaN)}); |
160 | 162 |
161 // getService | 163 // getService |
162 assert_throws("SyntaxError", function() { | 164 assert_throws("SyntaxError", function() { |
163 BluetoothUUID.getService(object); | 165 BluetoothUUID.getService(object); |
164 }); | 166 }); |
165 assert_throws("SyntaxError", function() { | 167 assert_throws("SyntaxError", function() { |
166 BluetoothUUID.getService(array); | 168 BluetoothUUID.getService(array); |
167 }); | 169 }); |
168 assert_throws("SyntaxError", function() { | 170 assert_throws("SyntaxError", function() { |
169 BluetoothUUID.getService(func); | 171 BluetoothUUID.getService(func); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 BluetoothUUID.getDescriptor(undefined); | 214 BluetoothUUID.getDescriptor(undefined); |
213 }); | 215 }); |
214 assert_throws("SyntaxError", function() { | 216 assert_throws("SyntaxError", function() { |
215 BluetoothUUID.getDescriptor(null); | 217 BluetoothUUID.getDescriptor(null); |
216 }); | 218 }); |
217 assert_throws("SyntaxError", function() { | 219 assert_throws("SyntaxError", function() { |
218 BluetoothUUID.getDescriptor(false); | 220 BluetoothUUID.getDescriptor(false); |
219 }); | 221 }); |
220 }, "Non-number and non-strings"); | 222 }, "Non-number and non-strings"); |
221 </script> | 223 </script> |
OLD | NEW |