Auto merge of #24816 - saschanaz:promiserejection, r=jdm

Require PromiseRejectionEventInit dictionary

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22670

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2019-11-21 21:39:44 -05:00 committed by GitHub
commit 49f47ea09f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 26 deletions

View file

@ -6425,7 +6425,8 @@ class CGDictionary(CGThing):
mustRoot = "" mustRoot = ""
if self.membersNeedTracing(): if self.membersNeedTracing():
mustRoot = "#[unrooted_must_root_lint::must_root]\n" mustRoot = "#[unrooted_must_root_lint::must_root]\n"
derive += ["Default"] if not self.hasRequiredFields(self.dictionary):
derive += ["Default"]
return (string.Template( return (string.Template(
"#[derive(${derive})]\n" "#[derive(${derive})]\n"
@ -6485,16 +6486,14 @@ class CGDictionary(CGThing):
selfName = self.makeClassName(d) selfName = self.makeClassName(d)
if self.membersNeedTracing(): if self.membersNeedTracing():
actualType = "RootedTraceableBox<%s>" % selfName actualType = "RootedTraceableBox<%s>" % selfName
preInitial = "let mut dictionary = RootedTraceableBox::new(%s::default());\n" % selfName preInitial = "let dictionary = RootedTraceableBox::new(%s {\n" % selfName
initParent = initParent = ("dictionary.parent = %s;\n" % initParent) if initParent else "" postInitial = "});\n"
memberInits = CGList([memberInit(m, False) for m in self.memberInfo])
postInitial = ""
else: else:
actualType = selfName actualType = selfName
preInitial = "let dictionary = %s {\n" % selfName preInitial = "let dictionary = %s {\n" % selfName
postInitial = "};\n" postInitial = "};\n"
initParent = ("parent: %s,\n" % initParent) if initParent else "" initParent = ("parent: %s,\n" % initParent) if initParent else ""
memberInits = CGList([memberInit(m, True) for m in self.memberInfo]) memberInits = CGList([memberInit(m, True) for m in self.memberInfo])
return string.Template( return string.Template(
"impl ${selfName} {\n" "impl ${selfName} {\n"
@ -6540,8 +6539,8 @@ class CGDictionary(CGThing):
"initParent": CGIndenter(CGGeneric(initParent), indentLevel=16).define(), "initParent": CGIndenter(CGGeneric(initParent), indentLevel=16).define(),
"initMembers": CGIndenter(memberInits, indentLevel=16).define(), "initMembers": CGIndenter(memberInits, indentLevel=16).define(),
"insertMembers": CGIndenter(memberInserts, indentLevel=8).define(), "insertMembers": CGIndenter(memberInserts, indentLevel=8).define(),
"preInitial": CGIndenter(CGGeneric(preInitial), indentLevel=16).define(), "preInitial": CGIndenter(CGGeneric(preInitial), indentLevel=8).define(),
"postInitial": CGIndenter(CGGeneric(postInitial), indentLevel=16).define(), "postInitial": CGIndenter(CGGeneric(postInitial), indentLevel=8).define(),
}) })
def membersNeedTracing(self): def membersNeedTracing(self):

View file

@ -5,7 +5,7 @@
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding; use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding;
use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding::PromiseRejectionEventMethods; 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::inheritance::Castable;
use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::root::DomRoot;
@ -72,14 +72,7 @@ impl PromiseRejectionEvent {
init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>, init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>,
) -> Fallible<DomRoot<Self>> { ) -> Fallible<DomRoot<Self>> {
let reason = init.reason.handle(); let reason = init.reason.handle();
let promise = match init.promise.as_ref() { let promise = init.promise.clone();
Some(promise) => promise.clone(),
None => {
return Err(Error::Type(
"required member promise is undefined.".to_string(),
));
},
};
let bubbles = EventBubbles::from(init.parent.bubbles); let bubbles = EventBubbles::from(init.parent.bubbles);
let cancelable = EventCancelable::from(init.parent.cancelable); let cancelable = EventCancelable::from(init.parent.cancelable);

View file

@ -6,12 +6,12 @@
[Exposed=(Window,Worker)] [Exposed=(Window,Worker)]
interface PromiseRejectionEvent : Event { interface PromiseRejectionEvent : Event {
[Throws] constructor(DOMString type, optional PromiseRejectionEventInit eventInitDict = {}); [Throws] constructor(DOMString type, PromiseRejectionEventInit eventInitDict);
readonly attribute Promise<any> promise; readonly attribute Promise<any> promise;
readonly attribute any reason; readonly attribute any reason;
}; };
dictionary PromiseRejectionEventInit : EventInit { dictionary PromiseRejectionEventInit : EventInit {
/* required */ Promise<any> promise; required Promise<any> promise;
any reason; any reason;
}; };

View file

@ -1163,9 +1163,6 @@
[OffscreenCanvasRenderingContext2D interface: operation closePath()] [OffscreenCanvasRenderingContext2D interface: operation closePath()]
expected: FAIL expected: FAIL
[PromiseRejectionEvent interface object length]
expected: FAIL
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "textAlign" with the proper type] [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "textAlign" with the proper type]
expected: FAIL expected: FAIL

View file

@ -68,9 +68,6 @@
[OffscreenCanvasRenderingContext2D interface: operation restore()] [OffscreenCanvasRenderingContext2D interface: operation restore()]
expected: FAIL expected: FAIL
[PromiseRejectionEvent interface object length]
expected: FAIL
[WorkerGlobalScope interface: calling createImageBitmap(ImageBitmapSource, ImageBitmapOptions) on self with too few arguments must throw TypeError] [WorkerGlobalScope interface: calling createImageBitmap(ImageBitmapSource, ImageBitmapOptions) on self with too few arguments must throw TypeError]
expected: FAIL expected: FAIL