mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
script: Implement IDBFactory.cmp (#38260)
Implements `IDBFactory.cmp`, most of the work was done by #38123. Testing: Covered by WPT (lots of flaky results: the appropriate tests are in tests/wpt/meta/IndexedDB/idlharness.any.js.ini) Fixes: None --------- Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This commit is contained in:
parent
6cd8578f8b
commit
ab78a76da6
7 changed files with 126 additions and 15 deletions
|
@ -1,17 +1,19 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleValue;
|
||||
use servo_url::origin::ImmutableOrigin;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::IDBFactoryBinding::IDBFactoryMethods;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::import::base::SafeJSContext;
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::idbopendbrequest::IDBOpenDBRequest;
|
||||
use crate::indexed_db::convert_value_to_key;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -89,9 +91,20 @@ impl IDBFactoryMethods<crate::DomTypeHolder> for IDBFactory {
|
|||
// fn Databases(&self) -> Rc<Promise> {
|
||||
// unimplemented!();
|
||||
// }
|
||||
//
|
||||
// // https://www.w3.org/TR/IndexedDB-2/#dom-idbfactory-cmp
|
||||
// fn Cmp(&self, _cx: SafeJSContext, _first: HandleValue, _second: HandleValue) -> i16 {
|
||||
// unimplemented!();
|
||||
// }
|
||||
|
||||
// https://www.w3.org/TR/IndexedDB-2/#dom-idbfactory-cmp
|
||||
fn Cmp(&self, cx: SafeJSContext, first: HandleValue, second: HandleValue) -> Fallible<i16> {
|
||||
let first_key = convert_value_to_key(cx, first, None)?;
|
||||
let second_key = convert_value_to_key(cx, second, None)?;
|
||||
let cmp = first_key.partial_cmp(&second_key);
|
||||
if let Some(cmp) = cmp {
|
||||
match cmp {
|
||||
std::cmp::Ordering::Less => Ok(-1),
|
||||
std::cmp::Ordering::Equal => Ok(0),
|
||||
std::cmp::Ordering::Greater => Ok(1),
|
||||
}
|
||||
} else {
|
||||
Ok(i16::MAX)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ interface IDBFactory {
|
|||
|
||||
// Promise<sequence<IDBDatabaseInfo>> databases();
|
||||
|
||||
// short cmp(any first, any second);
|
||||
[Throws] short cmp(any first, any second);
|
||||
};
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#dictdef-idbdatabaseinfo
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
expected: ERROR
|
||||
|
||||
[idbfactory_cmp.any.html]
|
||||
expected: CRASH
|
||||
[IDBFactory.cmp() - compared keys return correct value]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -37,6 +38,7 @@
|
|||
|
||||
|
||||
[idbfactory_cmp.any.worker.html]
|
||||
expected: CRASH
|
||||
[IDBFactory.cmp() - compared keys return correct value]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,11 +1,45 @@
|
|||
[idbobjectstore_delete.any.worker.html]
|
||||
expected: CRASH
|
||||
[delete() removes record (inline keys)]
|
||||
expected: FAIL
|
||||
|
||||
[delete() key doesn't match any records]
|
||||
expected: FAIL
|
||||
|
||||
[Object store's key path is an object attribute]
|
||||
expected: FAIL
|
||||
|
||||
[delete() removes record (out-of-line keys)]
|
||||
expected: FAIL
|
||||
|
||||
[delete() removes all of the records in the range]
|
||||
expected: FAIL
|
||||
|
||||
[If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[idbobjectstore_delete.any.serviceworker.html]
|
||||
expected: ERROR
|
||||
|
||||
[idbobjectstore_delete.any.html]
|
||||
expected: CRASH
|
||||
[delete() removes record (inline keys)]
|
||||
expected: FAIL
|
||||
|
||||
[delete() key doesn't match any records]
|
||||
expected: FAIL
|
||||
|
||||
[Object store's key path is an object attribute]
|
||||
expected: FAIL
|
||||
|
||||
[delete() removes record (out-of-line keys)]
|
||||
expected: FAIL
|
||||
|
||||
[delete() removes all of the records in the range]
|
||||
expected: FAIL
|
||||
|
||||
[If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[idbobjectstore_delete.any.sharedworker.html]
|
||||
expected: ERROR
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
[IDBFactory interface: operation databases()]
|
||||
expected: FAIL
|
||||
|
||||
[IDBFactory interface: operation cmp(any, any)]
|
||||
expected: FAIL
|
||||
|
||||
[IDBObjectStore interface: attribute keyPath]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -226,9 +223,6 @@
|
|||
[IDBFactory interface: operation databases()]
|
||||
expected: FAIL
|
||||
|
||||
[IDBFactory interface: operation cmp(any, any)]
|
||||
expected: FAIL
|
||||
|
||||
[IDBObjectStore interface: attribute keyPath]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
expected: ERROR
|
||||
|
||||
[key-conversion-exceptions.any.worker.html]
|
||||
expected: CRASH
|
||||
[IDBFactory cmp() static with throwing/invalid keys]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -19,6 +20,7 @@
|
|||
|
||||
|
||||
[key-conversion-exceptions.any.html]
|
||||
expected: CRASH
|
||||
[IDBFactory cmp() static with throwing/invalid keys]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -101,6 +101,27 @@
|
|||
[Date: Sat Nov 20 2286 12:46:40 GMT-0500 (Eastern Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 15:59:59 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 16:00:01 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 16:16:40 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Mon Jan 12 1970 05:46:40 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sat Sep 08 2001 18:46:40 GMT-0700 (Pacific Daylight Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sat Nov 20 2286 09:46:40 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[structured-clone.any.html?81-100]
|
||||
[Uint16Array: 0,1,65534,65535]
|
||||
|
@ -385,6 +406,18 @@
|
|||
[Date: Wed Dec 31 1969 18:43:20 GMT-0500 (Eastern Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sun Feb 09 1653 22:20:22 GMT-0752 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sun Apr 24 1938 14:13:20 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sat Dec 20 1969 02:13:20 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 15:43:20 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[structured-clone.any.worker.html?41-60]
|
||||
[Number: 0]
|
||||
|
@ -471,6 +504,18 @@
|
|||
[Date: Wed Dec 31 1969 18:43:20 GMT-0500 (Eastern Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sun Feb 09 1653 22:20:22 GMT-0752 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sun Apr 24 1938 14:13:20 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sat Dec 20 1969 02:13:20 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 15:43:20 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[structured-clone.any.html?61-80]
|
||||
[Date: Wed Dec 31 1969 23:59:59 GMT+0000 (Coordinated Universal Time)]
|
||||
|
@ -575,6 +620,27 @@
|
|||
[Date: Sat Nov 20 2286 12:46:40 GMT-0500 (Eastern Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 15:59:59 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 16:00:01 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Wed Dec 31 1969 16:16:40 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Mon Jan 12 1970 05:46:40 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sat Sep 08 2001 18:46:40 GMT-0700 (Pacific Daylight Time)]
|
||||
expected: FAIL
|
||||
|
||||
[Date: Sat Nov 20 2286 09:46:40 GMT-0800 (Pacific Standard Time)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[structured-clone.any.html?1-20]
|
||||
[undefined: undefined]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue