Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.cpp

Issue 2380843002: Throw a TypeError instead of a SyntaxError on invalid UUIDs. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/bluetooth/BluetoothUUID.h" 5 #include "modules/bluetooth/BluetoothUUID.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptRegexp.h" 8 #include "bindings/core/v8/ScriptRegexp.h"
9 #include "core/dom/ExceptionCode.h" 9 #include "core/dom/ExceptionCode.h"
10 #include "platform/UUID.h" 10 #include "platform/UUID.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 break; 320 break;
321 case GATTAttribute::Characteristic: 321 case GATTAttribute::Characteristic:
322 errorMessage.append("https://developer.bluetooth.org/gatt/characteristic s/Pages/CharacteristicsHome.aspx" 322 errorMessage.append("https://developer.bluetooth.org/gatt/characteristic s/Pages/CharacteristicsHome.aspx"
323 " e.g. 'aerobic_heart_rate_lower_limit'."); 323 " e.g. 'aerobic_heart_rate_lower_limit'.");
324 break; 324 break;
325 case GATTAttribute::Descriptor: 325 case GATTAttribute::Descriptor:
326 errorMessage.append("https://developer.bluetooth.org/gatt/descriptors/Pa ges/DescriptorsHomePage.aspx" 326 errorMessage.append("https://developer.bluetooth.org/gatt/descriptors/Pa ges/DescriptorsHomePage.aspx"
327 " e.g. 'gatt.characteristic_presentation_format'."); 327 " e.g. 'gatt.characteristic_presentation_format'.");
328 break; 328 break;
329 } 329 }
330 // Otherwise, throw a SyntaxError. 330 // Otherwise, throw a TypeError.
331 exceptionState.throwDOMException(SyntaxError, errorMessage.toString()); 331 exceptionState.throwDOMException(V8TypeError, errorMessage.toString());
332 return String(); 332 return String();
333 } 333 }
334 334
335 } // namespace 335 } // namespace
336 336
337 // static 337 // static
338 String BluetoothUUID::getService(StringOrUnsignedLong name, ExceptionState& exce ptionState) 338 String BluetoothUUID::getService(StringOrUnsignedLong name, ExceptionState& exce ptionState)
339 { 339 {
340 return getUUIDForGATTAttribute(GATTAttribute::Service, name, exceptionState) ; 340 return getUUIDForGATTAttribute(GATTAttribute::Service, name, exceptionState) ;
341 } 341 }
(...skipping 18 matching lines...) Expand all
360 appendUnsignedAsHexFixedSize( 360 appendUnsignedAsHexFixedSize(
361 alias, 361 alias,
362 builder, 8 /* 8 chars or 32 bits, prefix length */, 362 builder, 8 /* 8 chars or 32 bits, prefix length */,
363 Lowercase); 363 Lowercase);
364 364
365 builder.append("-0000-1000-8000-00805f9b34fb"); 365 builder.append("-0000-1000-8000-00805f9b34fb");
366 return builder.toString(); 366 return builder.toString();
367 } 367 }
368 368
369 } // namespace blink 369 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698