| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "bindings/core/v8/ScriptPromise.h" | 31 #include "bindings/core/v8/ScriptPromise.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptFunction.h" | 33 #include "bindings/core/v8/ScriptFunction.h" |
| 34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
| 35 #include "bindings/core/v8/V8Binding.h" | 35 #include "bindings/core/v8/V8Binding.h" |
| 36 #include "bindings/core/v8/V8BindingForTesting.h" | 36 #include "bindings/core/v8/V8BindingForTesting.h" |
| 37 #include "core/dom/DOMException.h" | 37 #include "core/dom/DOMException.h" |
| 38 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 39 #include "core/testing/NullExecutionContext.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include <v8.h> | 41 #include <v8.h> |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 void callback(const v8::FunctionCallbackInfo<v8::Value>& info) { } | 47 void callback(const v8::FunctionCallbackInfo<v8::Value>& info) { } |
| 47 | 48 |
| 48 class Function : public ScriptFunction { | 49 class Function : public ScriptFunction { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 68 } | 69 } |
| 69 | 70 |
| 70 ScriptValue* m_output; | 71 ScriptValue* m_output; |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 class ScriptPromiseTest : public testing::Test { | 74 class ScriptPromiseTest : public testing::Test { |
| 74 public: | 75 public: |
| 75 ScriptPromiseTest() | 76 ScriptPromiseTest() |
| 76 : m_scope(v8::Isolate::GetCurrent()) | 77 : m_scope(v8::Isolate::GetCurrent()) |
| 77 { | 78 { |
| 79 m_scope.getScriptState()->setExecutionContext(new NullExecutionContext()
); |
| 78 } | 80 } |
| 79 | 81 |
| 80 ~ScriptPromiseTest() | 82 ~ScriptPromiseTest() |
| 81 { | 83 { |
| 82 // FIXME: We put this statement here to clear an exception from the isol
ate. | 84 // FIXME: We put this statement here to clear an exception from the isol
ate. |
| 83 createClosure(callback, v8::Undefined(m_scope.isolate()), m_scope.isolat
e()); | 85 createClosure(callback, v8::Undefined(m_scope.isolate()), m_scope.isolat
e()); |
| 84 | 86 |
| 85 // Execute all pending microtasks | 87 // Execute all pending microtasks |
| 86 v8::MicrotasksScope::PerformCheckpoint(isolate()); | 88 v8::MicrotasksScope::PerformCheckpoint(isolate()); |
| 87 } | 89 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 v8::MicrotasksScope::PerformCheckpoint(isolate()); | 334 v8::MicrotasksScope::PerformCheckpoint(isolate()); |
| 333 | 335 |
| 334 EXPECT_TRUE(onFulfilled.isEmpty()); | 336 EXPECT_TRUE(onFulfilled.isEmpty()); |
| 335 EXPECT_FALSE(onRejected.isEmpty()); | 337 EXPECT_FALSE(onRejected.isEmpty()); |
| 336 EXPECT_EQ("world", toString(onRejected)); | 338 EXPECT_EQ("world", toString(onRejected)); |
| 337 } | 339 } |
| 338 | 340 |
| 339 } // namespace | 341 } // namespace |
| 340 | 342 |
| 341 } // namespace blink | 343 } // namespace blink |
| OLD | NEW |