Chromium Code Reviews| Index: third_party/WebKit/Source/modules/serviceworkers/ExtendableEvent.cpp |
| diff --git a/third_party/WebKit/Source/modules/serviceworkers/ExtendableEvent.cpp b/third_party/WebKit/Source/modules/serviceworkers/ExtendableEvent.cpp |
| index b3aa4da5d83590e6461c62480be5fd65ebe31d13..eecfaa8f6553a77867654ecf396d3fcbd02bc150 100644 |
| --- a/third_party/WebKit/Source/modules/serviceworkers/ExtendableEvent.cpp |
| +++ b/third_party/WebKit/Source/modules/serviceworkers/ExtendableEvent.cpp |
| @@ -52,18 +52,27 @@ ExtendableEvent::~ExtendableEvent() {} |
| void ExtendableEvent::waitUntil(ScriptState* script_state, |
| ScriptPromise script_promise, |
| ExceptionState& exception_state) { |
| - if (observer_) |
| - observer_->WaitUntil(script_state, script_promise, exception_state); |
| + if (created_by_script_) { |
| + exception_state.ThrowDOMException( |
| + kInvalidStateError, |
| + "Can not call waitUntil on a script constructed ExtendableEvent."); |
| + return; |
|
falken
2017/05/24 08:24:18
Is this part of the spec? Can you link to it and h
leonhsl(Using Gerrit)
2017/05/25 00:16:40
Done. Linked to an existing WPT test.
|
| + } |
| + |
| + DCHECK(observer_); |
| + observer_->WaitUntil(script_state, script_promise, exception_state); |
| } |
| ExtendableEvent::ExtendableEvent(const AtomicString& type, |
| const ExtendableEventInit& initializer) |
| - : Event(type, initializer) {} |
| + : Event(type, initializer), created_by_script_(true) {} |
| ExtendableEvent::ExtendableEvent(const AtomicString& type, |
| const ExtendableEventInit& initializer, |
| WaitUntilObserver* observer) |
| - : Event(type, initializer), observer_(observer) {} |
| + : Event(type, initializer), |
| + created_by_script_(false), |
|
falken
2017/05/24 08:24:18
I feel there is a more idiomatic way to do this in
leonhsl(Using Gerrit)
2017/05/25 00:16:40
Done.
|
| + observer_(observer) {} |
| const AtomicString& ExtendableEvent::InterfaceName() const { |
| return EventNames::ExtendableEvent; |