script: Expose IDBVersionChangeEvent to worker globals. (#37573)

IDBVersionChangeEvent is already used internally from non-Window
globals, but the constructor wasn't set up to expose the interface
object in worker globals.

Testing: The effort involved in adding a test for this does not seem
worthwhile—we get this for free once we enable the indexeddb preference
while our interfaces.worker.js test is running.
Fixes: part of #6963

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-06-20 03:42:36 -04:00 committed by GitHub
parent b622157c10
commit 518729a4f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 9 deletions

View file

@ -11,12 +11,11 @@ use crate::dom::bindings::codegen::Bindings::IDBVersionChangeEventBinding::{
};
use crate::dom::bindings::import::module::HandleObject;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::{DomGlobal, reflect_dom_object};
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
use crate::script_runtime::CanGc;
#[dom_struct]
@ -46,6 +45,7 @@ impl IDBVersionChangeEvent {
) -> DomRoot<IDBVersionChangeEvent> {
Self::new_with_proto(
global,
None,
type_,
bool::from(bubbles),
bool::from(cancelable),
@ -55,8 +55,10 @@ impl IDBVersionChangeEvent {
)
}
#[allow(clippy::too_many_arguments)]
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
type_: Atom,
bubbles: bool,
cancelable: bool,
@ -64,12 +66,13 @@ impl IDBVersionChangeEvent {
new_version: Option<u64>,
can_gc: CanGc,
) -> DomRoot<Self> {
let ev = reflect_dom_object(
let ev = reflect_dom_object_with_proto(
Box::new(IDBVersionChangeEvent::new_inherited(
old_version,
new_version,
)),
global,
proto,
can_gc,
);
{
@ -83,14 +86,15 @@ impl IDBVersionChangeEvent {
impl IDBVersionChangeEventMethods<crate::DomTypeHolder> for IDBVersionChangeEvent {
/// <https://w3c.github.io/IndexedDB/#dom-idbversionchangeevent-idbversionchangeevent>
fn Constructor(
window: &Window,
_proto: Option<HandleObject>,
global: &GlobalScope,
proto: Option<HandleObject>,
can_gc: CanGc,
type_: DOMString,
init: &IDBVersionChangeEventInit,
) -> DomRoot<Self> {
Self::new_with_proto(
&window.global(),
global,
proto,
Atom::from(type_),
init.parent.bubbles,
init.parent.cancelable,

View file

@ -7,10 +7,8 @@
*
*/
// FIXME:(arihant2math) Expose to Worker too
// https://w3c.github.io/IndexedDB/#idbversionchangeevent
[Pref="dom_indexeddb_enabled", Exposed=(Window)]
[Pref="dom_indexeddb_enabled", Exposed=(Window,Worker)]
interface IDBVersionChangeEvent : Event {
constructor(DOMString type, optional IDBVersionChangeEventInit eventInitDict = {});