Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Require PromiseRejectionEventInit dictionary
  • Loading branch information
saschanaz committed Nov 22, 2019
1 parent 47e39af commit 22278a8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 26 deletions.
17 changes: 8 additions & 9 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -6425,7 +6425,8 @@ def struct(self):
mustRoot = ""
if self.membersNeedTracing():
mustRoot = "#[unrooted_must_root_lint::must_root]\n"
derive += ["Default"]
if not self.hasRequiredFields(self.dictionary):
derive += ["Default"]

return (string.Template(
"#[derive(${derive})]\n"
Expand Down Expand Up @@ -6485,16 +6486,14 @@ def memberInsert(memberInfo):
selfName = self.makeClassName(d)
if self.membersNeedTracing():
actualType = "RootedTraceableBox<%s>" % selfName
preInitial = "let mut dictionary = RootedTraceableBox::new(%s::default());\n" % selfName
initParent = initParent = ("dictionary.parent = %s;\n" % initParent) if initParent else ""
memberInits = CGList([memberInit(m, False) for m in self.memberInfo])
postInitial = ""
preInitial = "let dictionary = RootedTraceableBox::new(%s {\n" % selfName
postInitial = "});\n"
else:
actualType = selfName
preInitial = "let dictionary = %s {\n" % selfName
postInitial = "};\n"
initParent = ("parent: %s,\n" % initParent) if initParent else ""
memberInits = CGList([memberInit(m, True) for m in self.memberInfo])
initParent = ("parent: %s,\n" % initParent) if initParent else ""
memberInits = CGList([memberInit(m, True) for m in self.memberInfo])

return string.Template(
"impl ${selfName} {\n"
Expand Down Expand Up @@ -6540,8 +6539,8 @@ def memberInsert(memberInfo):
"initParent": CGIndenter(CGGeneric(initParent), indentLevel=16).define(),
"initMembers": CGIndenter(memberInits, indentLevel=16).define(),
"insertMembers": CGIndenter(memberInserts, indentLevel=8).define(),
"preInitial": CGIndenter(CGGeneric(preInitial), indentLevel=16).define(),
"postInitial": CGIndenter(CGGeneric(postInitial), indentLevel=16).define(),
"preInitial": CGIndenter(CGGeneric(preInitial), indentLevel=8).define(),
"postInitial": CGIndenter(CGGeneric(postInitial), indentLevel=8).define(),
})

def membersNeedTracing(self):
Expand Down
11 changes: 2 additions & 9 deletions components/script/dom/promiserejectionevent.rs
Expand Up @@ -5,7 +5,7 @@
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding;
use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding::PromiseRejectionEventMethods;
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::DomRoot;
Expand Down Expand Up @@ -72,14 +72,7 @@ impl PromiseRejectionEvent {
init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>,
) -> Fallible<DomRoot<Self>> {
let reason = init.reason.handle();
let promise = match init.promise.as_ref() {
Some(promise) => promise.clone(),
None => {
return Err(Error::Type(
"required member promise is undefined.".to_string(),
));
},
};
let promise = init.promise.clone();
let bubbles = EventBubbles::from(init.parent.bubbles);
let cancelable = EventCancelable::from(init.parent.cancelable);

Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/webidls/PromiseRejectionEvent.webidl
Expand Up @@ -6,12 +6,12 @@

[Exposed=(Window,Worker)]
interface PromiseRejectionEvent : Event {
[Throws] constructor(DOMString type, optional PromiseRejectionEventInit eventInitDict = {});
[Throws] constructor(DOMString type, PromiseRejectionEventInit eventInitDict);
readonly attribute Promise<any> promise;
readonly attribute any reason;
};

dictionary PromiseRejectionEventInit : EventInit {
/* required */ Promise<any> promise;
required Promise<any> promise;
any reason;
};
3 changes: 0 additions & 3 deletions tests/wpt/metadata/html/dom/idlharness.https.html.ini
Expand Up @@ -1163,9 +1163,6 @@
[OffscreenCanvasRenderingContext2D interface: operation closePath()]
expected: FAIL

[PromiseRejectionEvent interface object length]
expected: FAIL

[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "textAlign" with the proper type]
expected: FAIL

Expand Down
3 changes: 0 additions & 3 deletions tests/wpt/metadata/html/dom/idlharness.worker.js.ini
Expand Up @@ -68,9 +68,6 @@
[OffscreenCanvasRenderingContext2D interface: operation restore()]
expected: FAIL
[PromiseRejectionEvent interface object length]
expected: FAIL
[WorkerGlobalScope interface: calling createImageBitmap(ImageBitmapSource, ImageBitmapOptions) on self with too few arguments must throw TypeError]
expected: FAIL
Expand Down

0 comments on commit 22278a8

Please sign in to comment.