| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "bindings/core/v8/ScriptPromiseProperty.h" | 6 #include "bindings/core/v8/ScriptPromiseProperty.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 9 #include "bindings/core/v8/ScriptFunction.h" | 9 #include "bindings/core/v8/ScriptFunction.h" |
| 10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 NotReached* self = new NotReached(scriptState); | 37 NotReached* self = new NotReached(scriptState); |
| 38 return self->bindToV8Function(); | 38 return self->bindToV8Function(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 explicit NotReached(ScriptState* scriptState) | 42 explicit NotReached(ScriptState* scriptState) |
| 43 : ScriptFunction(scriptState) | 43 : ScriptFunction(scriptState) |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 virtual ScriptValue call(ScriptValue) override; | 47 ScriptValue call(ScriptValue) override; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 ScriptValue NotReached::call(ScriptValue) | 50 ScriptValue NotReached::call(ScriptValue) |
| 51 { | 51 { |
| 52 EXPECT_TRUE(false) << "'Unreachable' code was reached"; | 52 EXPECT_TRUE(false) << "'Unreachable' code was reached"; |
| 53 return ScriptValue(); | 53 return ScriptValue(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 class StubFunction : public ScriptFunction { | 56 class StubFunction : public ScriptFunction { |
| 57 public: | 57 public: |
| 58 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Scri
ptValue& value, size_t& callCount) | 58 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Scri
ptValue& value, size_t& callCount) |
| 59 { | 59 { |
| 60 StubFunction* self = new StubFunction(scriptState, value, callCount); | 60 StubFunction* self = new StubFunction(scriptState, value, callCount); |
| 61 return self->bindToV8Function(); | 61 return self->bindToV8Function(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 StubFunction(ScriptState* scriptState, ScriptValue& value, size_t& callCount
) | 65 StubFunction(ScriptState* scriptState, ScriptValue& value, size_t& callCount
) |
| 66 : ScriptFunction(scriptState) | 66 : ScriptFunction(scriptState) |
| 67 , m_value(value) | 67 , m_value(value) |
| 68 , m_callCount(callCount) | 68 , m_callCount(callCount) |
| 69 { | 69 { |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual ScriptValue call(ScriptValue arg) override | 72 ScriptValue call(ScriptValue arg) override |
| 73 { | 73 { |
| 74 m_value = arg; | 74 m_value = arg; |
| 75 m_callCount++; | 75 m_callCount++; |
| 76 return ScriptValue(); | 76 return ScriptValue(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 ScriptValue& m_value; | 79 ScriptValue& m_value; |
| 80 size_t& m_callCount; | 80 size_t& m_callCount; |
| 81 }; | 81 }; |
| 82 | 82 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 ScriptPromisePropertyGarbageCollectedTest() | 181 ScriptPromisePropertyGarbageCollectedTest() |
| 182 : m_holder(new GarbageCollectedHolder(&document())) | 182 : m_holder(new GarbageCollectedHolder(&document())) |
| 183 { | 183 { |
| 184 } | 184 } |
| 185 | 185 |
| 186 GarbageCollectedHolder* holder() { return m_holder; } | 186 GarbageCollectedHolder* holder() { return m_holder; } |
| 187 Property* property() { return m_holder->property(); } | 187 Property* property() { return m_holder->property(); } |
| 188 ScriptPromise promise(DOMWrapperWorld& world) { return property()->promise(w
orld); } | 188 ScriptPromise promise(DOMWrapperWorld& world) { return property()->promise(w
orld); } |
| 189 | 189 |
| 190 virtual void destroyContext() override | 190 void destroyContext() override |
| 191 { | 191 { |
| 192 m_holder = nullptr; | 192 m_holder = nullptr; |
| 193 ScriptPromisePropertyTestBase::destroyContext(); | 193 ScriptPromisePropertyTestBase::destroyContext(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 private: | 196 private: |
| 197 Persistent<GarbageCollectedHolder> m_holder; | 197 Persistent<GarbageCollectedHolder> m_holder; |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 TEST_F(ScriptPromisePropertyGarbageCollectedTest, Promise_IsStableObjectInMainWo
rld) | 200 TEST_F(ScriptPromisePropertyGarbageCollectedTest, Promise_IsStableObjectInMainWo
rld) |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 { | 546 { |
| 547 test(String("hello"), "hello", __FILE__, __LINE__); | 547 test(String("hello"), "hello", __FILE__, __LINE__); |
| 548 } | 548 } |
| 549 | 549 |
| 550 TEST_F(ScriptPromisePropertyNonScriptWrappableResolutionTargetTest, ResolveWithI
nteger) | 550 TEST_F(ScriptPromisePropertyNonScriptWrappableResolutionTargetTest, ResolveWithI
nteger) |
| 551 { | 551 { |
| 552 test(-1, "-1", __FILE__, __LINE__); | 552 test(-1, "-1", __FILE__, __LINE__); |
| 553 } | 553 } |
| 554 | 554 |
| 555 } // namespace | 555 } // namespace |
| OLD | NEW |