Commit e1c54ad2 authored by jochen's avatar jochen Committed by Commit bot

Update PromiseRejectionEvent IDL to match latest spec

https://github.com/whatwg/html/pull/224

R=domenic@chromium.org
BUG=495801

Review URL: https://codereview.chromium.org/1471283002

Cr-Commit-Position: refs/heads/master@{#361412}
parent 96415575
...@@ -8,17 +8,17 @@ ...@@ -8,17 +8,17 @@
test(function() { test(function() {
var p = new Promise(function(resolve, reject) {}); var p = new Promise(function(resolve, reject) {});
// No initializer is passed. // No custom options are passed (besides required promise).
assert_equals(new PromiseRejectionEvent('eventType').bubbles, false); assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).bubbles, false);
assert_equals(new PromiseRejectionEvent('eventType').cancelable, false); assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).cancelable, false);
assert_equals(new PromiseRejectionEvent('eventType').promise, null); assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).promise, p);
assert_equals(new PromiseRejectionEvent('eventType').reason, null); assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).reason, undefined);
// No promise is passed. // No promise is passed.
assert_throws(new TypeError(), assert_throws(new TypeError(),
function() { function() {
new PromiseRejectionEvent('eventType', { bubbles: false }); new PromiseRejectionEvent('eventType', { bubbles: false });
}, },
'Cannot construct PromiseRejectionEventInit without promise'); 'Cannot construct PromiseRejectionEventInit without promise');
// bubbles is passed. // bubbles is passed.
...@@ -29,9 +29,6 @@ test(function() { ...@@ -29,9 +29,6 @@ test(function() {
assert_equals(new PromiseRejectionEvent('eventType', { cancelable: false, promise: p }).cancelable, false); assert_equals(new PromiseRejectionEvent('eventType', { cancelable: false, promise: p }).cancelable, false);
assert_equals(new PromiseRejectionEvent('eventType', { cancelable: true, promise: p }).cancelable, true); assert_equals(new PromiseRejectionEvent('eventType', { cancelable: true, promise: p }).cancelable, true);
// promise is passed.
assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).promise, p);
// reason is passed. // reason is passed.
var r = new Error(); var r = new Error();
assert_equals(new PromiseRejectionEvent('eventType', { promise: p, reason: r }).reason, r); assert_equals(new PromiseRejectionEvent('eventType', { promise: p, reason: r }).reason, r);
......
...@@ -44,7 +44,7 @@ ScriptValue PromiseRejectionEvent::reason(ScriptState* state) const ...@@ -44,7 +44,7 @@ ScriptValue PromiseRejectionEvent::reason(ScriptState* state) const
{ {
// Return null when the value is accessed by a different world than the world that created the value. // Return null when the value is accessed by a different world than the world that created the value.
if (m_reason.isEmpty() || !m_scriptState || !m_scriptState->contextIsValid() || m_scriptState->world().worldId() != state->world().worldId()) if (m_reason.isEmpty() || !m_scriptState || !m_scriptState->contextIsValid() || m_scriptState->world().worldId() != state->world().worldId())
return ScriptValue(state, v8::Null(state->isolate())); return ScriptValue(state, v8::Undefined(state->isolate()));
return ScriptValue(m_scriptState.get(), m_reason.newLocal(m_scriptState->isolate())); return ScriptValue(m_scriptState.get(), m_reason.newLocal(m_scriptState->isolate()));
} }
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
[ [
RuntimeEnabled=PromiseRejectionEvent, RuntimeEnabled=PromiseRejectionEvent,
Custom=VisitDOMWrapper, Custom=VisitDOMWrapper,
Constructor(DOMString type, optional PromiseRejectionEventInit eventInitDict), Constructor(DOMString type, PromiseRejectionEventInit eventInitDict),
ConstructorCallWith=ScriptState, ConstructorCallWith=ScriptState,
Exposed=(Window,Worker,ServiceWorker), Exposed=(Window,Worker,ServiceWorker),
] interface PromiseRejectionEvent : Event { ] interface PromiseRejectionEvent : Event {
[Custom=Getter] readonly attribute Promise<any>? promise; [Custom=Getter] readonly attribute Promise<any> promise;
[CallWith=ScriptState] readonly attribute any reason; [CallWith=ScriptState] readonly attribute any reason;
}; };
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
[ [
RuntimeEnabled=PromiseRejectionEvent, RuntimeEnabled=PromiseRejectionEvent,
] dictionary PromiseRejectionEventInit : EventInit { ] dictionary PromiseRejectionEventInit : EventInit {
required Promise<any>? promise; required Promise<any> promise;
any reason = null; any reason;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment