setters.tentative.https.sub.html (3299B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 5 <body> 6 <script> 7 'use strict'; 8 9 promise_test(async t => { 10 return promise_rejects_js(t, TypeError, sharedStorage.set()); 11 }, 'sharedStorage.set with 0 argument'); 12 13 promise_test(async t => { 14 return promise_rejects_js(t, TypeError, sharedStorage.set("a")); 15 }, 'sharedStorage.set with 1 argument'); 16 17 promise_test(() => { 18 return sharedStorage.set("a", "b"); 19 }, 'sharedStorage.set with 2 arguments'); 20 21 promise_test(() => { 22 return sharedStorage.set("a", "b", {ignoreIfPresent: true}); 23 }, 'sharedStorage.set with options'); 24 25 promise_test(async t => { 26 return promise_rejects_js(t, TypeError, sharedStorage.set("a", "b", "c")); 27 }, 'sharedStorage.set with invalid options'); 28 29 promise_test(async t => { 30 try { 31 await sharedStorage.set('', 'b'); 32 } catch (e) { 33 assert_equals(e.name, 'DataError'); 34 return; 35 } 36 assert_unreached("did not reject"); 37 }, 'sharedStorage.set with empty key'); 38 39 promise_test(() => { 40 return sharedStorage.append("a", "b"); 41 }, 'sharedStorage.append'); 42 43 promise_test(() => { 44 return sharedStorage.clear(); 45 }, 'sharedStorage.clear'); 46 47 promise_test(() => { 48 return sharedStorage.delete("a"); 49 }, 'sharedStorage.delete'); 50 51 test(() => { 52 try { 53 let a = new SharedStorageSetMethod('a'); 54 } catch (e) { 55 assert_equals(e.name, 'TypeError'); 56 return; 57 } 58 assert_unreached("did not throw"); 59 }, 'new SharedStorageSetMethod with 1 argument'); 60 61 test(() => { 62 let a = new SharedStorageSetMethod('a', 'b'); 63 }, 'new SharedStorageSetMethod with 2 arguments'); 64 65 test(() => { 66 try { 67 let a = new SharedStorageAppendMethod('a'); 68 } catch (e) { 69 assert_equals(e.name, 'TypeError'); 70 return; 71 } 72 assert_unreached("did not throw"); 73 }, 'new SharedStorageAppendMethod with 1 argument'); 74 75 test(() => { 76 let a = new SharedStorageAppendMethod('a', 'b'); 77 }, 'new SharedStorageAppendMethod with 2 arguments'); 78 79 test(() => { 80 try { 81 let a = new SharedStorageDeleteMethod(); 82 } catch (e) { 83 assert_equals(e.name, 'TypeError'); 84 return; 85 } 86 assert_unreached("did not throw"); 87 }, 'new SharedStorageDeleteMethod with no arguments'); 88 89 test(() => { 90 let a = new SharedStorageDeleteMethod('a'); 91 }, 'new SharedStorageDeleteMethod with 1 argument'); 92 93 test(() => { 94 try { 95 let a = SharedStorageClearMethod(); 96 } catch (e) { 97 assert_equals(e.name, 'TypeError'); 98 return; 99 } 100 assert_unreached("did not throw"); 101 }, 'call SharedStorageClearMethod() as a function'); 102 103 test(() => { 104 let a = new SharedStorageClearMethod(); 105 }, 'new SharedStorageClearMethod with no arguments'); 106 107 promise_test(() => { 108 return sharedStorage.batchUpdate([ 109 new SharedStorageSetMethod("key0", "value0"), 110 new SharedStorageAppendMethod("key1", "value1"), 111 new SharedStorageDeleteMethod("key2"), 112 new SharedStorageClearMethod() 113 ], {withLock: "lock3"}); 114 }, 'sharedStorage.batchUpdate'); 115 116 promise_test(async t => { 117 return promise_rejects_js(t, TypeError, sharedStorage.batchUpdate()); 118 }, 'sharedStorage.batchUpdate without \'methods\' argument'); 119 120 promise_test(async t => { 121 return promise_rejects_js(t, TypeError, sharedStorage.batchUpdate(["123"])); 122 }, 'sharedStorage.batchUpdate with invalid \'methods\' argument'); 123 124 </script> 125 </body>