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

Side by Side Diff: third_party/WebKit/LayoutTests/nfc/push.html

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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/nfc/NFC.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/nfc-helpers.js"></script> 5 <script src="resources/nfc-helpers.js"></script>
6 <script> 6 <script>
7 7
8 'use strict'; 8 'use strict';
9 9
10 const invalid_messages = 10 const invalid_messages =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 nfc.mockNFC.setHWStatus(NFCHWStatus.NOT_SUPPORTED); 79 nfc.mockNFC.setHWStatus(NFCHWStatus.NOT_SUPPORTED);
80 return assertRejectsWithError(navigator.nfc.push(test_text_data), 80 return assertRejectsWithError(navigator.nfc.push(test_text_data),
81 'NotSupportedError'); 81 'NotSupportedError');
82 }, 'nfc.push should fail when NFC HW is not supported.') 82 }, 'nfc.push should fail when NFC HW is not supported.')
83 83
84 nfc_test(nfc => { 84 nfc_test(nfc => {
85 return navigator.nfc.push(test_text_data, { timeout: 1 }); 85 return navigator.nfc.push(test_text_data, { timeout: 1 });
86 }, 'nfc.push should succeed when NFC HW is enabled'); 86 }, 'nfc.push should succeed when NFC HW is enabled');
87 87
88 nfc_test(nfc => { 88 nfc_test(nfc => {
89 return assertRejectsWithError(
90 navigator.nfc.push(test_text_data, { timeout: 'invalid' }), 'TypeError');
91 }, 'nfc.push should fail when invalid timeout is provided');
92
93 nfc_test(nfc => {
94 return assertRejectsWithError(
95 navigator.nfc.push(test_text_data, { timeout: -1 }), 'TypeError');
96 }, 'nfc.push should fail when invalid negative timeout value is provided');
97
98 nfc_test(nfc => {
89 nfc.mockNFC.setPendingPushCompleted(false); 99 nfc.mockNFC.setPendingPushCompleted(false);
90 return assertRejectsWithError( 100 return assertRejectsWithError(
91 navigator.nfc.push(test_text_data,{ timeout: 1 }), 101 navigator.nfc.push(test_text_data,{ timeout: 1 }),
92 'TimeoutError'); 102 'TimeoutError');
93 }, 'nfc.push should fail with TimeoutError when push operation is not' + 103 }, 'nfc.push should fail with TimeoutError when push operation is not' +
94 ' completed before specified timeout value.') 104 ' completed before specified timeout value.')
95 105
96 nfc_test(nfc => { 106 nfc_test(nfc => {
97 let message = createMessage([createTextRecord(test_text_data), 107 let message = createMessage([createTextRecord(test_text_data),
98 createJsonRecord(test_json_data), 108 createJsonRecord(test_json_data),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return assertRejectsWithError(promise, 'AbortError'); 154 return assertRejectsWithError(promise, 'AbortError');
145 }, 'nfc.cancelPush should reject pending promise with AbortError.') 155 }, 'nfc.cancelPush should reject pending promise with AbortError.')
146 156
147 nfc_test(nfc => { 157 nfc_test(nfc => {
148 return assertRejectsWithError( 158 return assertRejectsWithError(
149 navigator.nfc.push(new ArrayBuffer(32 * 1024 + 1)), 159 navigator.nfc.push(new ArrayBuffer(32 * 1024 + 1)),
150 'NotSupportedError'); 160 'NotSupportedError');
151 }, 'Reject promise with NotSupportedError if NFC message size exceeds 32KB.'); 161 }, 'Reject promise with NotSupportedError if NFC message size exceeds 32KB.');
152 162
153 </script> 163 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/nfc/NFC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698