summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/keypath_invalid.htm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/IndexedDB/keypath_invalid.htm
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/keypath_invalid.htm')
-rw-r--r--testing/web-platform/tests/IndexedDB/keypath_invalid.htm65
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/keypath_invalid.htm b/testing/web-platform/tests/IndexedDB/keypath_invalid.htm
new file mode 100644
index 0000000000..6aa33c854a
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/keypath_invalid.htm
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<!-- Submitted from TestTWF Paris -->
+<meta charset="utf-8">
+<title>Invalid keypath</title>
+<link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#key-path-construct">
+<link rel=assert title="A key path is a DOMString that defines how to extract a key from a value. A valid key path is either the empty string, a JavaScript identifier, or multiple Javascript identifiers separated by periods (ASCII character code 46) [ECMA-262].">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/support.js"></script>
+
+<script>
+
+ var global_db = createdb_for_multiple_tests();
+
+ function invalid_keypath(keypath, desc) {
+ var t = async_test("Invalid keyPath - " + (desc ? desc : format_value(keypath)), undefined, 2);
+
+ var openrq = global_db.setTest(t),
+ store_name = "store-" + Date.now() + Math.random();
+
+ openrq.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ assert_throws_dom('SyntaxError', function() {
+ db.createObjectStore(store_name, { keyPath: keypath })
+ }, "createObjectStore with keyPath");
+
+ var store = db.createObjectStore(store_name);
+ assert_throws_dom('SyntaxError', function() {
+ store.createIndex('index', keypath);
+ }, "createIndex with keyPath");
+
+ db.close();
+
+ this.done();
+ };
+ }
+
+ invalid_keypath('j a');
+ invalid_keypath('.yo');
+ invalid_keypath('yo,lo');
+ invalid_keypath([]);
+ invalid_keypath(['array with space']);
+ invalid_keypath(['multi_array', ['a', 'b']], "multidimensional array (invalid toString)"); // => ['multi_array', 'a,b']
+ invalid_keypath('3m');
+ invalid_keypath({toString:function(){return '3m'}}, '{toString->3m}');
+ invalid_keypath('my.1337');
+ invalid_keypath('..yo');
+ invalid_keypath('y..o');
+ invalid_keypath('y.o.');
+ invalid_keypath('y.o..');
+ invalid_keypath('m.*');
+ invalid_keypath('"m"');
+ invalid_keypath('m%');
+ invalid_keypath('m/');
+ invalid_keypath('m/a');
+ invalid_keypath('m&');
+ invalid_keypath('m!');
+ invalid_keypath('*');
+ invalid_keypath('*.*');
+ invalid_keypath('^m');
+ invalid_keypath('/m/');
+
+</script>
+
+<div id=log></div>