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

Unified Diff: third_party/WebKit/Source/modules/nfc/NFC.cpp

Issue 2836813007: [webnfc] Reject promise if passed timeout value is invalid (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/nfc/push.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/nfc/NFC.cpp
diff --git a/third_party/WebKit/Source/modules/nfc/NFC.cpp b/third_party/WebKit/Source/modules/nfc/NFC.cpp
index 4a3d6ece9cdd2b6a0ae11be11120a9e197a1d927..c404247ae0e2a2c90293b981d7987b5e1abc9387 100644
--- a/third_party/WebKit/Source/modules/nfc/NFC.cpp
+++ b/third_party/WebKit/Source/modules/nfc/NFC.cpp
@@ -618,6 +618,18 @@ ScriptPromise NFC::push(ScriptState* script_state,
if (exception)
return ScriptPromise::RejectWithDOMException(script_state, exception);
+ // https://w3c.github.io/web-nfc/#dom-nfc-push
+ // 9. If timeout value is NaN or negative, reject promise with "TypeError"
+ // and abort these steps.
+ if (options.hasTimeout() &&
+ (std::isnan(options.timeout()) || options.timeout() < 0)) {
+ return ScriptPromise::Reject(
+ script_state,
+ V8ThrowException::CreateTypeError(
+ script_state->GetIsolate(),
+ "Invalid NFCPushOptions.timeout value was provided."));
+ }
+
device::nfc::mojom::blink::NFCMessagePtr message =
device::nfc::mojom::blink::NFCMessage::From(push_message);
if (!message)
« no previous file with comments | « third_party/WebKit/LayoutTests/nfc/push.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698