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

Unified Diff: third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html

Issue 2276593002: Support renaming of IndexedDB indexes and object stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test coverage for the (slightly incorrect) behavior in strict mode when our flag is not enabl… Created 4 years, 3 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
Index: third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html
diff --git a/third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html b/third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html
new file mode 100644
index 0000000000000000000000000000000000000000..724edc1eccb4d10bbad3da9cce922ad571b353b6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<script src='../resources/testharness.js'></script>
+<script src='../resources/testharnessreport.js'></script>
+<script>
+
+// This test makes sure that the IndexedDB object store and index name setters
+// are only exposed when the experimental Web Platform features flag is set.
+// This is implemented in Blink because our bindings generator does not support
+// separate settings for exposing a property's getter and setter.
+//
+// TODO(crbug.com/644889): Remove this test after we ship IndexedDB v2.
+
+async_test(t => {
+ const dbName = 'db' + self.location.pathname + '-' + t.name;
+ indexedDB.deleteDatabase(dbName);
+ const request = indexedDB.open(dbName, 1);
+ request.onupgradeneeded = t.step_func(event => {
+ const database = event.target.result;
+ const transaction = event.target.transaction;
+ const store = database.createObjectStore('books');
+ const index = store.createIndex('by_author', 'author');
+
+ store.name = 'renamed_books';
+ assert_equals(
+ store.name, 'books',
+ 'IndexedDB object store renaming should not be web-exposed');
+ index.name = 'renamed_by_author';
+ assert_equals(
+ index.name, 'by_author',
+ 'IndexedDB index renaming should not be web-exposed');
+
+ // 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!
+ // a TypeError. We do not implement the correct semantics here because
+ // detecting strict mode would require writing custom bindings. The
+ // deviation is small, and will go away when we ship IndexedDB v2. Thus,
+ // avoiding the deviation is not worth the engineering effort of writing
+ // and testing a custom binding.
+ (() => {
+ 'use strict';
+
+ store.name = 'renamed_books';
+ assert_equals(
+ store.name, 'books',
+ 'IndexedDB object store renaming should not be web-exposed ' +
+ 'in strict mode');
+ index.name = 'renamed_by_author';
+ assert_equals(
+ index.name, 'by_author',
+ 'IndexedDB index renaming should not be web-exposed ' +
+ 'in strict mode');
+ })();
+ });
+ request.onsuccess = t.step_func_done(event => {
+ const database = event.target.result;
+ database.close();
+ });
+ request.onerror = t.unreached_func(
+ 'The IndexedDB request should not receive an error event');
+}, 'IndexedDB object store and index renaming should not be web-exposed\nThis test is expected to fail in LayoutTests/webexposed');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698