diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/IndexedDB/keypath_invalid.htm | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
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.htm | 65 |
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> |