OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src='../resources/testharness.js'></script> | |
3 <script src='../resources/testharnessreport.js'></script> | |
4 <script> | |
5 | |
6 // This test makes sure that the IndexedDB object store and index name setters | |
7 // are only exposed when the experimental Web Platform features flag is set. | |
8 // This is implemented in Blink because our bindings generator does not support | |
9 // separate settings for exposing a property's getter and setter. | |
10 // | |
11 // TODO(crbug.com/644889): Remove this test after we ship IndexedDB v2. | |
12 | |
13 async_test(t => { | |
14 const dbName = 'db' + self.location.pathname + '-' + t.name; | |
15 indexedDB.deleteDatabase(dbName); | |
16 const request = indexedDB.open(dbName, 1); | |
17 request.onupgradeneeded = t.step_func(event => { | |
18 const database = event.target.result; | |
19 const transaction = event.target.transaction; | |
20 const store = database.createObjectStore('books'); | |
21 const index = store.createIndex('by_author', 'author'); | |
22 | |
23 store.name = 'renamed_books'; | |
24 assert_equals( | |
25 store.name, 'books', | |
26 'IndexedDB object store renaming should not be web-exposed'); | |
27 index.name = 'renamed_by_author'; | |
28 assert_equals( | |
29 index.name, 'by_author', | |
30 'IndexedDB index renaming should not be web-exposed'); | |
31 | |
32 // In strict mode, attempting to set a read-only property should throw | |
pwnall
2016/09/09 22:24:09
foolip: I added a test that covers our strict mode
foolip
2016/09/09 22:31:17
Yep, looks good!
| |
33 // a TypeError. We do not implement the correct semantics here because | |
34 // detecting strict mode would require writing custom bindings. The | |
35 // deviation is small, and will go away when we ship IndexedDB v2. Thus, | |
36 // avoiding the deviation is not worth the engineering effort of writing | |
37 // and testing a custom binding. | |
38 (() => { | |
39 'use strict'; | |
40 | |
41 store.name = 'renamed_books'; | |
42 assert_equals( | |
43 store.name, 'books', | |
44 'IndexedDB object store renaming should not be web-exposed ' + | |
45 'in strict mode'); | |
46 index.name = 'renamed_by_author'; | |
47 assert_equals( | |
48 index.name, 'by_author', | |
49 'IndexedDB index renaming should not be web-exposed ' + | |
50 'in strict mode'); | |
51 })(); | |
52 }); | |
53 request.onsuccess = t.step_func_done(event => { | |
54 const database = event.target.result; | |
55 database.close(); | |
56 }); | |
57 request.onerror = t.unreached_func( | |
58 'The IndexedDB request should not receive an error event'); | |
59 }, 'IndexedDB object store and index renaming should not be web-exposed\nThis te st is expected to fail in LayoutTests/webexposed'); | |
60 | |
61 </script> | |
OLD | NEW |