| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const ExtendableEventInit& event_init, | 45 const ExtendableEventInit& event_init, |
| 46 WaitUntilObserver* observer) { | 46 WaitUntilObserver* observer) { |
| 47 return new ExtendableEvent(type, event_init, observer); | 47 return new ExtendableEvent(type, event_init, observer); |
| 48 } | 48 } |
| 49 | 49 |
| 50 ExtendableEvent::~ExtendableEvent() {} | 50 ExtendableEvent::~ExtendableEvent() {} |
| 51 | 51 |
| 52 void ExtendableEvent::waitUntil(ScriptState* script_state, | 52 void ExtendableEvent::waitUntil(ScriptState* script_state, |
| 53 ScriptPromise script_promise, | 53 ScriptPromise script_promise, |
| 54 ExceptionState& exception_state) { | 54 ExceptionState& exception_state) { |
| 55 if (observer_) | 55 if (!observer_) { |
| 56 observer_->WaitUntil(script_state, script_promise, exception_state); | 56 exception_state.ThrowDOMException( |
| 57 kInvalidStateError, |
| 58 "Can not call waitUntil on a script constructed ExtendableEvent."); |
| 59 return; |
| 60 } |
| 61 |
| 62 observer_->WaitUntil(script_state, script_promise, exception_state); |
| 57 } | 63 } |
| 58 | 64 |
| 59 ExtendableEvent::ExtendableEvent(const AtomicString& type, | 65 ExtendableEvent::ExtendableEvent(const AtomicString& type, |
| 60 const ExtendableEventInit& initializer) | 66 const ExtendableEventInit& initializer) |
| 61 : Event(type, initializer) {} | 67 : Event(type, initializer) {} |
| 62 | 68 |
| 63 ExtendableEvent::ExtendableEvent(const AtomicString& type, | 69 ExtendableEvent::ExtendableEvent(const AtomicString& type, |
| 64 const ExtendableEventInit& initializer, | 70 const ExtendableEventInit& initializer, |
| 65 WaitUntilObserver* observer) | 71 WaitUntilObserver* observer) |
| 66 : Event(type, initializer), observer_(observer) {} | 72 : Event(type, initializer), observer_(observer) {} |
| 67 | 73 |
| 68 const AtomicString& ExtendableEvent::InterfaceName() const { | 74 const AtomicString& ExtendableEvent::InterfaceName() const { |
| 69 return EventNames::ExtendableEvent; | 75 return EventNames::ExtendableEvent; |
| 70 } | 76 } |
| 71 | 77 |
| 72 DEFINE_TRACE(ExtendableEvent) { | 78 DEFINE_TRACE(ExtendableEvent) { |
| 73 visitor->Trace(observer_); | 79 visitor->Trace(observer_); |
| 74 Event::Trace(visitor); | 80 Event::Trace(visitor); |
| 75 } | 81 } |
| 76 | 82 |
| 77 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |