mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
script: Support creating a DOMStringList for any global. (#37567)
There were a lot of crashing IndexedDB tests caused by code in DOMStringList that required a Window object despite being exposed to non-Window globals. Testing: Lots of existing tests no longer crash. Fixes: part of #6963 Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
b331cb4603
commit
52dc1fa88d
81 changed files with 1324 additions and 313 deletions
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::DOMStringListBinding::DOMStringList
|
|||
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::window::Window;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -18,7 +18,6 @@ pub(crate) struct DOMStringList {
|
|||
}
|
||||
|
||||
impl DOMStringList {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn new_inherited(strings: Vec<DOMString>) -> DOMStringList {
|
||||
DOMStringList {
|
||||
reflector_: Reflector::new(),
|
||||
|
@ -26,15 +25,14 @@ impl DOMStringList {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub(crate) fn new(
|
||||
window: &Window,
|
||||
global: &GlobalScope,
|
||||
strings: Vec<DOMString>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<DOMStringList> {
|
||||
reflect_dom_object(
|
||||
Box::new(DOMStringList::new_inherited(strings)),
|
||||
window,
|
||||
global,
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ impl IDBDatabase {
|
|||
|
||||
pub fn object_stores(&self) -> DomRoot<DOMStringList> {
|
||||
DOMStringList::new(
|
||||
self.global().as_window(),
|
||||
&self.global(),
|
||||
self.object_store_names.borrow().clone(),
|
||||
CanGc::note(),
|
||||
)
|
||||
|
@ -161,7 +161,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
|||
&self.global(),
|
||||
self,
|
||||
mode,
|
||||
&DOMStringList::new(self.global().as_window(), vec![name], CanGc::note()),
|
||||
&DOMStringList::new(&self.global(), vec![name], CanGc::note()),
|
||||
CanGc::note(),
|
||||
),
|
||||
StringOrStringSequence::StringSequence(sequence) => {
|
||||
|
@ -171,7 +171,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
|||
&self.global(),
|
||||
self,
|
||||
mode,
|
||||
&DOMStringList::new(self.global().as_window(), sequence, CanGc::note()),
|
||||
&DOMStringList::new(&self.global(), sequence, CanGc::note()),
|
||||
CanGc::note(),
|
||||
)
|
||||
},
|
||||
|
@ -343,7 +343,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
|||
fn ObjectStoreNames(&self) -> DomRoot<DOMStringList> {
|
||||
// FIXME: (arihant2math) Sort the list of names, as per spec
|
||||
DOMStringList::new(
|
||||
self.global().as_window(),
|
||||
&self.global(),
|
||||
self.object_store_names.borrow().clone(),
|
||||
CanGc::note(),
|
||||
)
|
||||
|
|
|
@ -79,7 +79,7 @@ impl IDBObjectStore {
|
|||
name: DomRefCell::new(name),
|
||||
key_path,
|
||||
|
||||
index_names: DOMStringList::new(global.as_window(), Vec::new(), can_gc),
|
||||
index_names: DOMStringList::new(global, Vec::new(), can_gc),
|
||||
transaction: Default::default(),
|
||||
// FIXME:(arihant2math)
|
||||
auto_increment: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue