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 (created_by_script_) { |
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 DCHECK(observer_); |
| 63 observer_->WaitUntil(script_state, script_promise, exception_state); |
57 } | 64 } |
58 | 65 |
59 ExtendableEvent::ExtendableEvent(const AtomicString& type, | 66 ExtendableEvent::ExtendableEvent(const AtomicString& type, |
60 const ExtendableEventInit& initializer) | 67 const ExtendableEventInit& initializer) |
61 : Event(type, initializer) {} | 68 : Event(type, initializer), created_by_script_(true) {} |
62 | 69 |
63 ExtendableEvent::ExtendableEvent(const AtomicString& type, | 70 ExtendableEvent::ExtendableEvent(const AtomicString& type, |
64 const ExtendableEventInit& initializer, | 71 const ExtendableEventInit& initializer, |
65 WaitUntilObserver* observer) | 72 WaitUntilObserver* observer) |
66 : Event(type, initializer), observer_(observer) {} | 73 : Event(type, initializer), |
| 74 created_by_script_(false), |
| 75 observer_(observer) {} |
67 | 76 |
68 const AtomicString& ExtendableEvent::InterfaceName() const { | 77 const AtomicString& ExtendableEvent::InterfaceName() const { |
69 return EventNames::ExtendableEvent; | 78 return EventNames::ExtendableEvent; |
70 } | 79 } |
71 | 80 |
72 DEFINE_TRACE(ExtendableEvent) { | 81 DEFINE_TRACE(ExtendableEvent) { |
73 visitor->Trace(observer_); | 82 visitor->Trace(observer_); |
74 Event::Trace(visitor); | 83 Event::Trace(visitor); |
75 } | 84 } |
76 | 85 |
77 } // namespace blink | 86 } // namespace blink |
OLD | NEW |