| 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 28 matching lines...) Expand all Loading... |
| 39 #include "core/testing/NullExecutionContext.h" | 39 #include "core/testing/NullExecutionContext.h" |
| 40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| 41 #include <v8.h> | 41 #include <v8.h> |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 typedef ScriptPromise::InternalResolver Resolver; | 47 typedef ScriptPromise::InternalResolver Resolver; |
| 48 | 48 |
| 49 void callback(const v8::FunctionCallbackInfo<v8::Value>& info) { } | |
| 50 | |
| 51 class Function : public ScriptFunction { | 49 class Function : public ScriptFunction { |
| 52 public: | 50 public: |
| 53 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Scri
ptValue* output) | 51 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Scri
ptValue* output) |
| 54 { | 52 { |
| 55 Function* self = new Function(scriptState, output); | 53 Function* self = new Function(scriptState, output); |
| 56 return self->bindToV8Function(); | 54 return self->bindToV8Function(); |
| 57 } | 55 } |
| 58 | 56 |
| 59 private: | 57 private: |
| 60 Function(ScriptState* scriptState, ScriptValue* output) | 58 Function(ScriptState* scriptState, ScriptValue* output) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 class TryCatchScope { | 74 class TryCatchScope { |
| 77 public: | 75 public: |
| 78 explicit TryCatchScope(v8::Isolate* isolate) | 76 explicit TryCatchScope(v8::Isolate* isolate) |
| 79 : m_isolate(isolate) | 77 : m_isolate(isolate) |
| 80 , m_trycatch(isolate) | 78 , m_trycatch(isolate) |
| 81 { | 79 { |
| 82 } | 80 } |
| 83 | 81 |
| 84 ~TryCatchScope() | 82 ~TryCatchScope() |
| 85 { | 83 { |
| 86 // FIXME: We put this statement here to clear an exception from the isol
ate. | |
| 87 createClosure(callback, v8::Undefined(m_isolate), m_isolate); | |
| 88 | |
| 89 // Execute all pending microtasks | 84 // Execute all pending microtasks |
| 90 v8::MicrotasksScope::PerformCheckpoint(m_isolate); | 85 v8::MicrotasksScope::PerformCheckpoint(m_isolate); |
| 91 } | 86 } |
| 92 | 87 |
| 93 bool hasCaught() const { return m_trycatch.HasCaught(); } | 88 bool hasCaught() const { return m_trycatch.HasCaught(); } |
| 94 | 89 |
| 95 private: | 90 private: |
| 96 v8::Isolate* m_isolate; | 91 v8::Isolate* m_isolate; |
| 97 v8::TryCatch m_trycatch; | 92 v8::TryCatch m_trycatch; |
| 98 }; | 93 }; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | 354 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); |
| 360 | 355 |
| 361 EXPECT_TRUE(onFulfilled.isEmpty()); | 356 EXPECT_TRUE(onFulfilled.isEmpty()); |
| 362 EXPECT_FALSE(onRejected.isEmpty()); | 357 EXPECT_FALSE(onRejected.isEmpty()); |
| 363 EXPECT_EQ("world", toString(scope.context(), onRejected)); | 358 EXPECT_EQ("world", toString(scope.context(), onRejected)); |
| 364 } | 359 } |
| 365 | 360 |
| 366 } // namespace | 361 } // namespace |
| 367 | 362 |
| 368 } // namespace blink | 363 } // namespace blink |
| OLD | NEW |