OLD | NEW |
(Empty) | |
| 1 <script> |
| 2 chrome.test.runTests([ |
| 3 function getWhenEmpty() { |
| 4 function stage1(settings) { |
| 5 chrome.test.assertEq({}, settings); |
| 6 chrome.experimental.settings.get(['foo', 'bar'], stage2); |
| 7 } |
| 8 function stage2(settings) { |
| 9 chrome.test.assertEq({}, settings); |
| 10 chrome.experimental.settings.get(undefined, stage3); |
| 11 } |
| 12 function stage3(settings) { |
| 13 chrome.test.assertEq({}, settings); |
| 14 chrome.test.succeed(); |
| 15 } |
| 16 chrome.experimental.settings.get('foo', stage1); |
| 17 }, |
| 18 |
| 19 function getWhenNonempty() { |
| 20 function stage1(settings) { |
| 21 chrome.test.assertEq({ |
| 22 'foo' : 'bar', |
| 23 'baz' : 'qux', |
| 24 'hello': 'world' |
| 25 }, settings); |
| 26 chrome.experimental.settings.get(['foo', 'baz'], stage2); |
| 27 } |
| 28 function stage2(settings) { |
| 29 chrome.test.assertEq({ |
| 30 'foo': 'bar', |
| 31 'baz': 'qux' |
| 32 }, settings); |
| 33 chrome.experimental.settings.get( |
| 34 ['nothing', 'baz', 'hello', 'ignore'], stage3); |
| 35 } |
| 36 function stage3(settings) { |
| 37 chrome.test.assertEq({ |
| 38 'baz' : 'qux', |
| 39 'hello': 'world' |
| 40 }, settings); |
| 41 chrome.experimental.settings.get(null, stage4); |
| 42 } |
| 43 function stage4(settings) { |
| 44 chrome.test.assertEq({ |
| 45 'foo' : 'bar', |
| 46 'baz' : 'qux', |
| 47 'hello': 'world' |
| 48 }, settings); |
| 49 chrome.test.succeed(); |
| 50 } |
| 51 chrome.experimental.settings.set({ |
| 52 'foo' : 'bar', |
| 53 'baz' : 'qux', |
| 54 'hello': 'world' |
| 55 }, stage1); |
| 56 }, |
| 57 |
| 58 function removeWhenEmpty() { |
| 59 function stage1(settings) { |
| 60 chrome.test.assertEq(undefined, settings); |
| 61 chrome.experimental.settings.remove(['foo', 'bar'], stage2); |
| 62 } |
| 63 function stage2(settings) { |
| 64 chrome.test.assertEq(undefined, settings); |
| 65 chrome.test.succeed(); |
| 66 } |
| 67 chrome.experimental.settings.remove('foo', stage1); |
| 68 }, |
| 69 |
| 70 function removeWhenNonempty() { |
| 71 function stage1(settings) { |
| 72 chrome.test.assertEq({ |
| 73 'foo' : 'bar', |
| 74 'baz' : 'qux', |
| 75 'hello': 'world' |
| 76 }, settings); |
| 77 chrome.experimental.settings.remove('foo', stage2); |
| 78 } |
| 79 function stage2(settings) { |
| 80 chrome.test.assertEq(undefined, settings); |
| 81 chrome.experimental.settings.get(null, stage3); |
| 82 } |
| 83 function stage3(settings) { |
| 84 chrome.test.assertEq({ |
| 85 'baz' : 'qux', |
| 86 'hello': 'world' |
| 87 }, settings); |
| 88 chrome.experimental.settings.remove(['baz', 'nothing'], stage4); |
| 89 } |
| 90 function stage4(settings) { |
| 91 chrome.test.assertEq(undefined, settings); |
| 92 chrome.experimental.settings.get(null, stage5); |
| 93 } |
| 94 function stage5(settings) { |
| 95 chrome.test.assertEq({ |
| 96 'hello': 'world' |
| 97 }, settings); |
| 98 chrome.experimental.settings.remove('hello', stage6); |
| 99 } |
| 100 function stage6(settings) { |
| 101 chrome.test.assertEq(undefined, settings); |
| 102 chrome.experimental.settings.get(null, stage7); |
| 103 } |
| 104 function stage7(settings) { |
| 105 chrome.test.assertEq({}, settings); |
| 106 chrome.test.succeed(); |
| 107 } |
| 108 chrome.experimental.settings.set({ |
| 109 'foo' : 'bar', |
| 110 'baz' : 'qux', |
| 111 'hello': 'world' |
| 112 }, stage1); |
| 113 }, |
| 114 |
| 115 function setWhenOverwriting() { |
| 116 function stage1(settings) { |
| 117 chrome.test.assertEq({ |
| 118 'foo' : 'bar', |
| 119 'baz' : 'qux', |
| 120 'hello': 'world' |
| 121 }, settings); |
| 122 chrome.experimental.settings.set({ |
| 123 'foo' : 'otherBar', |
| 124 'baz' : 'otherQux' |
| 125 }, stage2); |
| 126 } |
| 127 function stage2(settings) { |
| 128 chrome.test.assertEq({ |
| 129 'foo' : 'otherBar', |
| 130 'baz' : 'otherQux', |
| 131 }, settings); |
| 132 chrome.experimental.settings.get(null, stage3); |
| 133 } |
| 134 function stage3(settings) { |
| 135 chrome.test.assertEq({ |
| 136 'foo' : 'otherBar', |
| 137 'baz' : 'otherQux', |
| 138 'hello': 'world' |
| 139 }, settings); |
| 140 chrome.experimental.settings.set({ |
| 141 'baz' : 'anotherQux', |
| 142 'hello': 'otherWorld', |
| 143 'some' : 'value' |
| 144 }, stage4); |
| 145 } |
| 146 function stage4(settings) { |
| 147 chrome.test.assertEq({ |
| 148 'baz' : 'anotherQux', |
| 149 'hello': 'otherWorld', |
| 150 'some' : 'value' |
| 151 }, settings); |
| 152 chrome.experimental.settings.get(null, stage5); |
| 153 } |
| 154 function stage5(settings) { |
| 155 chrome.test.assertEq({ |
| 156 'foo' : 'otherBar', |
| 157 'baz' : 'anotherQux', |
| 158 'hello': 'otherWorld', |
| 159 'some' : 'value' |
| 160 }, settings); |
| 161 chrome.test.succeed(); |
| 162 } |
| 163 chrome.experimental.settings.set({ |
| 164 'foo' : 'bar', |
| 165 'baz' : 'qux', |
| 166 'hello': 'world' |
| 167 }, stage1); |
| 168 }, |
| 169 |
| 170 function clearWhenEmpty() { |
| 171 function stage1(settings) { |
| 172 chrome.test.assertEq(undefined, settings); |
| 173 chrome.experimental.settings.get(null, stage2); |
| 174 } |
| 175 function stage2(settings) { |
| 176 chrome.test.assertEq({}, settings); |
| 177 chrome.test.succeed(); |
| 178 } |
| 179 chrome.experimental.settings.clear(stage1); |
| 180 }, |
| 181 |
| 182 function clearWhenNonempty() { |
| 183 function stage1(settings) { |
| 184 chrome.test.assertEq({ |
| 185 'foo' : 'bar', |
| 186 'baz' : 'qux', |
| 187 'hello': 'world' |
| 188 }, settings); |
| 189 chrome.experimental.settings.clear(stage2); |
| 190 } |
| 191 function stage2(settings) { |
| 192 chrome.test.assertEq(undefined, settings); |
| 193 chrome.experimental.settings.get(null, stage3); |
| 194 } |
| 195 function stage3(settings) { |
| 196 chrome.test.assertEq({}, settings); |
| 197 chrome.test.succeed(); |
| 198 } |
| 199 chrome.experimental.settings.set({ |
| 200 'foo' : 'bar', |
| 201 'baz' : 'qux', |
| 202 'hello': 'world' |
| 203 }, stage1); |
| 204 } |
| 205 ]); |
| 206 </script> |
OLD | NEW |