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 @@
test(function() {
var p = new Promise(function(resolve, reject) {});
// No initializer is passed.
assert_equals(new PromiseRejectionEvent('eventType').bubbles, false);
assert_equals(new PromiseRejectionEvent('eventType').cancelable, false);
assert_equals(new PromiseRejectionEvent('eventType').promise, null);
assert_equals(new PromiseRejectionEvent('eventType').reason, null);
// No custom options are passed (besides required promise).
assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).bubbles, false);
assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).cancelable, false);
assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).promise, p);
assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).reason, undefined);
// No promise is passed.
assert_throws(new TypeError(),
function() {
new PromiseRejectionEvent('eventType', { bubbles: false });
},
},
'Cannot construct PromiseRejectionEventInit without promise');
// bubbles is passed.
......@@ -29,9 +29,6 @@ test(function() {
assert_equals(new PromiseRejectionEvent('eventType', { cancelable: false, promise: p }).cancelable, false);
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.
var r = new Error();
assert_equals(new PromiseRejectionEvent('eventType', { promise: p, reason: r }).reason, r);
......
......@@ -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.
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()));
}
......
......@@ -7,10 +7,10 @@
[
RuntimeEnabled=PromiseRejectionEvent,
Custom=VisitDOMWrapper,
Constructor(DOMString type, optional PromiseRejectionEventInit eventInitDict),
Constructor(DOMString type, PromiseRejectionEventInit eventInitDict),
ConstructorCallWith=ScriptState,
Exposed=(Window,Worker,ServiceWorker),
] interface PromiseRejectionEvent : Event {
[Custom=Getter] readonly attribute Promise<any>? promise;
[Custom=Getter] readonly attribute Promise<any> promise;
[CallWith=ScriptState] readonly attribute any reason;
};
......@@ -7,6 +7,6 @@
[
RuntimeEnabled=PromiseRejectionEvent,
] dictionary PromiseRejectionEventInit : EventInit {
required Promise<any>? promise;
any reason = null;
required Promise<any> promise;
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