gecko-dev/testing/web-platform/tests/IndexedDB/keypath-exceptions.htm
James Graham 62afd489a0 Bug 1410245 - Update web-platform-tests to revision a372dce582c21c911056273eec042fd9073cbd60, a=testonly
MozReview-Commit-ID: CQzdR66hsXZ


--HG--
rename : testing/web-platform/tests/progress-events/interface.html => testing/web-platform/tests/XMLHttpRequest/progressevent-interface.html
rename : testing/web-platform/tests/cssom/MediaList.xhtml => testing/web-platform/tests/cssom/MediaList2.xhtml
rename : testing/web-platform/tests/old-tests/submission/Microsoft/dragdrop/dragdrop_support.js => testing/web-platform/tests/html/editing/dnd/resources/dragdrop_support.js
rename : testing/web-platform/tests/old-tests/submission/Microsoft/structuredclone/echo.js => testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/echo.js
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox_011.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/sandbox_011.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_002.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_002.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_003.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_003.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_006.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_006.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_007.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_007.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_012.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_012.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_023.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_023.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_024.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_024.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_028.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_028.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_029.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_029.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox.pdf => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/sandbox.pdf
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/023.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/023.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/050.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/050.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/067.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/067.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/069.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/069.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/075.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/075.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/077.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/077.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/078.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/078.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/079.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/079.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/101.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/101.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-import.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-noimport.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-import.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-noimport.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/111.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/111.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/112.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/112.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/119.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/119.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/background.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/background.css
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/import.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/import.css
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/count-script-tags.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/count-script-tags.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-body.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-body.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-foo.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-foo.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-1.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-1.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-10.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-10.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-11.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-11.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-2.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-2.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-3.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-3.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-4.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-4.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-5.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-5.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-6.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-6.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-7.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-7.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-8.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-8.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-9.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-9.js
rename : testing/web-platform/tests/assumptions/OWNERS => testing/web-platform/tests/infrastructure/assumptions/OWNERS
rename : testing/web-platform/tests/assumptions/canvas-background-ref.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background-ref.html
rename : testing/web-platform/tests/assumptions/canvas-background.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background.html
rename : testing/web-platform/tests/assumptions/html-elements.html => testing/web-platform/tests/infrastructure/assumptions/html-elements.html
rename : testing/web-platform/tests/assumptions/initial-color-ref.html => testing/web-platform/tests/infrastructure/assumptions/initial-color-ref.html
rename : testing/web-platform/tests/assumptions/initial-color.html => testing/web-platform/tests/infrastructure/assumptions/initial-color.html
rename : testing/web-platform/tests/assumptions/medium-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size-ref.html
rename : testing/web-platform/tests/assumptions/medium-font-size.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size.html
rename : testing/web-platform/tests/assumptions/min-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size-ref.html
rename : testing/web-platform/tests/assumptions/min-font-size.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size.html
rename : testing/web-platform/tests/assumptions/tools/build.sh => testing/web-platform/tests/infrastructure/assumptions/tools/build.sh
rename : testing/web-platform/tests/infrastructure/failing-test.html => testing/web-platform/tests/infrastructure/expected-fail/failing-test.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html => testing/web-platform/tests/requestidlecallback/callback-exception.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-idle-periods.html => testing/web-platform/tests/requestidlecallback/callback-idle-periods.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html => testing/web-platform/tests/requestidlecallback/callback-iframe.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html => testing/web-platform/tests/requestidlecallback/callback-invoked.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html => testing/web-platform/tests/requestidlecallback/callback-multiple-calls.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-removed-frame.html => testing/web-platform/tests/requestidlecallback/callback-removed-frame.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout-with-raf.html => testing/web-platform/tests/requestidlecallback/callback-timeout-with-raf.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html => testing/web-platform/tests/requestidlecallback/callback-timeout.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-xhr-sync.html => testing/web-platform/tests/requestidlecallback/callback-xhr-sync.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html => testing/web-platform/tests/requestidlecallback/cancel-invoked.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html => testing/web-platform/tests/requestidlecallback/idlharness.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/resources/post_name_on_load.html => testing/web-platform/tests/requestidlecallback/resources/post_name_on_load.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.html => testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.https.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.https.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.https.html
rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.https.html
rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.https.html
2017-10-25 10:45:59 +01:00

272 lines
9.4 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>IndexedDB: Exceptions in extracting keys from values (ES bindings)</title>
<meta name="help" href="https://w3c.github.io/IndexedDB/#extract-key-from-value">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
indexeddb_test(
(t, db) => {
db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.c'});
},
(t, db) => {
const tx = db.transaction('store', 'readwrite');
assert_throws({name: 'DataError'}, () => {
tx.objectStore('store').put({a: {b: "foo"}});
}, 'Put should throw if key can not be inserted at key path location.');
t.done();
},
'The last element of keypath is validated'
);
function throws(name) {
return () => {
const err = Error();
err.name = name;
throw err;
};
}
indexeddb_test(
function(t, db) {
const o = {};
Object.defineProperty(o, 'throws', {get: throws('getter'),
enumerable: false, configurable: true});
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no such property, so key path evaluation
// will fail.
const s1 = db.createObjectStore('s1', {keyPath: 'throws'});
assert_throws('DataError', () => {
s1.put(o);
}, 'Key path failing to resolve should throw');
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no such property, so key path evaluation
// will fail.
const s2 = db.createObjectStore('s2', {keyPath: 'throws.x'});
assert_throws('DataError', () => {
s2.put(o);
}, 'Key path failing to resolve should throw');
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no such property, so generated key can be
// inserted.
const s3 = db.createObjectStore('s3',
{keyPath: 'throws', autoIncrement: true});
assert_class_string(s3.put(o), 'IDBRequest',
'Key injectability test at throwing getter should succeed');
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no such property, so intermediate object
// and generated key can be inserted.
const s4 = db.createObjectStore('s4',
{keyPath: 'throws.x', autoIncrement: true});
assert_class_string(s4.put(o), 'IDBRequest',
'Key injectability test past throwing getter should succeed');
},
(t, db) => {
t.done();
},
'Key path evaluation: Exceptions from non-enumerable getters'
);
indexeddb_test(
function(t, db) {
const o = {};
Object.defineProperty(o, 'throws', {get: throws('getter'),
enumerable: true, configurable: true});
// Value should be cloned before key path is evaluated,
// and enumerable getter will rethrow.
const s1 = db.createObjectStore('s1', {keyPath: 'throws'});
assert_throws({name: 'getter'}, () => {
s1.put(o);
}, 'Key path resolving to throwing getter rethrows');
// Value should be cloned before key path is evaluated,
// and enumerable getter will rethrow.
const s2 = db.createObjectStore('s2', {keyPath: 'throws.x'});
assert_throws({name: 'getter'}, () => {
s2.put(o);
}, 'Key path resolving past throwing getter rethrows');
// Value should be cloned before key path is evaluated,
// and enumerable getter will rethrow.
const s3 = db.createObjectStore('s3',
{keyPath: 'throws', autoIncrement: true});
assert_throws({name: 'getter'}, () => {
s3.put(o);
}, 'Key injectability test at throwing getter should rethrow');
// Value should be cloned before key path is evaluated,
// and enumerable getter will rethrow.
const s4 = db.createObjectStore('s4',
{keyPath: 'throws.x', autoIncrement: true});
assert_throws({name: 'getter'}, () => {
s4.put(o);
}, 'Key injectability test past throwing getter should rethrow');
},
(t, db) => {
t.done();
},
'Key path evaluation: Exceptions from enumerable getters'
);
indexeddb_test(
(t, db) => {
// Implemented as function wrapper to clean up
// immediately after use, otherwise it may
// interfere with the test harness.
function with_proto_getter(f) {
return function() {
Object.defineProperty(Object.prototype, 'throws', {
get: throws('getter'),
enumerable: false, configurable: true
});
try {
f();
} finally {
delete Object.prototype['throws'];
}
};
}
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no own property, so key path evaluation will
// fail and DataError should be thrown.
const s1 = db.createObjectStore('s1', {keyPath: 'throws'});
assert_throws('DataError', with_proto_getter(function() {
s1.put({});
}), 'Key path resolving to no own property throws DataError');
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no own property, so key path evaluation will
// fail and DataError should be thrown.
const s2 = db.createObjectStore('s2', {keyPath: 'throws.x'});
assert_throws('DataError', with_proto_getter(function() {
s2.put({});
}), 'Key path resolving past no own property throws DataError');
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no own property, so key path evaluation will
// fail and injection can succeed.
const s3 = db.createObjectStore('s3',
{keyPath: 'throws', autoIncrement: true});
assert_equals(s3.put({}).readyState, 'pending',
'put should not throw due to inherited property');
// Value should be cloned before key path is evaluated,
// and non-enumerable getter will be ignored. The clone
// will have no own property, so key path evaluation will
// fail and injection can succeed.
const s4 = db.createObjectStore('s4',
{keyPath: 'throws.x', autoIncrement: true});
assert_equals(s4.put({}).readyState, 'pending',
'put should not throw due to inherited property');
},
(t, db) => {
t.done();
},
'Key path evaluation: Exceptions from non-enumerable getters on prototype'
);
indexeddb_test(
(t, db) => {
// Implemented as function wrapper to clean up
// immediately after use, otherwise it may
// interfere with the test harness.
function with_proto_getter(f) {
return () => {
Object.defineProperty(Object.prototype, 'throws', {
get: throws('getter'),
enumerable: true, configurable: true
});
try {
f();
} finally {
delete Object.prototype['throws'];
}
};
}
// Value should be cloned before key path is evaluated.
// The clone will have no own property, so key path
// evaluation will fail and DataError should be thrown.
const s1 = db.createObjectStore('s1', {keyPath: 'throws'});
assert_throws('DataError', with_proto_getter(function() {
s1.put({});
}), 'Key path resolving to no own property throws DataError');
// Value should be cloned before key path is evaluated.
// The clone will have no own property, so key path
// evaluation will fail and DataError should be thrown.
const s2 = db.createObjectStore('s2', {keyPath: 'throws.x'});
assert_throws('DataError', with_proto_getter(function() {
s2.put({});
}), 'Key path resolving past throwing getter rethrows');
// Value should be cloned before key path is evaluated.
// The clone will have no own property, so key path
// evaluation will fail and injection can succeed.
var s3 = db.createObjectStore('s3',
{keyPath: 'throws', autoIncrement: true});
assert_equals(s3.put({}).readyState, 'pending',
'put should not throw due to inherited property');
// Value should be cloned before key path is evaluated.
// The clone will have no own property, so key path
// evaluation will fail and injection can succeed.
var s4 = db.createObjectStore('s4',
{keyPath: 'throws.x', autoIncrement: true});
assert_equals(s4.put({}).readyState, 'pending',
'put should not throw due to inherited property');
},
(t, db) => {
t.done();
},
'Key path evaluation: Exceptions from enumerable getters on prototype'
);
indexeddb_test(
(t, db) => {
const store = db.createObjectStore('store');
store.createIndex('index', 'index0');
},
(t, db) => {
const tx = db.transaction('store', 'readwrite');
const array = [];
array[99] = 1;
let getter_called = 0;
const prop = '50';
Object.defineProperty(Object.prototype, prop, {
enumerable: true, configurable: true,
get: () => {
++getter_called;
return 'foo';
},
});
const request = tx.objectStore('store').put({index0: array}, 'key');
request.onerror = t.unreached_func('put should not fail');
request.onsuccess = t.step_func(function() {
assert_equals(getter_called, 0, 'Prototype getter should not be called');
delete Object.prototype[prop];
t.done();
});
},
'Array key conversion should not invoke prototype getters'
);
</script>