| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 Function(v8::Isolate* isolate, String* value) : ScriptFunction(isolate), m_v
alue(value) { } | 65 Function(v8::Isolate* isolate, String* value) : ScriptFunction(isolate), m_v
alue(value) { } |
| 66 | 66 |
| 67 String* m_value; | 67 String* m_value; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 class ScriptPromiseTest : public testing::Test { | 70 class ScriptPromiseTest : public testing::Test { |
| 71 public: | 71 public: |
| 72 ScriptPromiseTest() | 72 ScriptPromiseTest() |
| 73 : m_scope(V8TestingScope::create(v8::Isolate::GetCurrent())) | 73 : m_scope(v8::Isolate::GetCurrent()) |
| 74 { | 74 { |
| 75 } | 75 } |
| 76 | 76 |
| 77 ~ScriptPromiseTest() | 77 ~ScriptPromiseTest() |
| 78 { | 78 { |
| 79 // FIXME: We put this statement here to clear an exception from the isol
ate. | 79 // FIXME: We put this statement here to clear an exception from the isol
ate. |
| 80 createClosure(callback, v8::Undefined(m_scope->isolate()), m_scope->isol
ate()); | 80 createClosure(callback, v8::Undefined(m_scope.isolate()), m_scope.isolat
e()); |
| 81 | 81 |
| 82 // Execute all pending microtasks | 82 // Execute all pending microtasks |
| 83 isolate()->RunMicrotasks(); | 83 isolate()->RunMicrotasks(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 ScriptState* scriptState() const { return m_scope->scriptState(); } | 86 ScriptState* scriptState() const { return m_scope.scriptState(); } |
| 87 v8::Isolate* isolate() const { return m_scope->isolate(); } | 87 v8::Isolate* isolate() const { return m_scope.isolate(); } |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 OwnPtr<V8TestingScope> m_scope; | 90 V8TestingScope m_scope; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 TEST_F(ScriptPromiseTest, constructFromNonPromise) | 93 TEST_F(ScriptPromiseTest, constructFromNonPromise) |
| 94 { | 94 { |
| 95 v8::TryCatch trycatch; | 95 v8::TryCatch trycatch; |
| 96 ScriptPromise promise(scriptState(), v8::Undefined(isolate())); | 96 ScriptPromise promise(scriptState(), v8::Undefined(isolate())); |
| 97 ASSERT_TRUE(trycatch.HasCaught()); | 97 ASSERT_TRUE(trycatch.HasCaught()); |
| 98 ASSERT_TRUE(promise.isEmpty()); | 98 ASSERT_TRUE(promise.isEmpty()); |
| 99 } | 99 } |
| 100 | 100 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 isolate()->RunMicrotasks(); | 252 isolate()->RunMicrotasks(); |
| 253 | 253 |
| 254 EXPECT_EQ(String(), onFulfilled); | 254 EXPECT_EQ(String(), onFulfilled); |
| 255 EXPECT_EQ("SyntaxError: some syntax error", onRejected); | 255 EXPECT_EQ("SyntaxError: some syntax error", onRejected); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace | 258 } // namespace |
| 259 | 259 |
| 260 } // namespace WebCore | 260 } // namespace WebCore |
| OLD | NEW |