OLD | NEW |
1 | 1 |
2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 6 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 virtual ~ScriptValueTest() { } | 85 virtual ~ScriptValueTest() { } |
86 virtual void operator()(ScriptValue) const = 0; | 86 virtual void operator()(ScriptValue) const = 0; |
87 }; | 87 }; |
88 | 88 |
89 // Runs microtasks and expects |promise| to be rejected. Calls | 89 // Runs microtasks and expects |promise| to be rejected. Calls |
90 // |valueTest| with the value passed to |reject|, if any. | 90 // |valueTest| with the value passed to |reject|, if any. |
91 void expectRejected(ScriptState* scriptState, ScriptPromise& promise, const Scri
ptValueTest& valueTest) | 91 void expectRejected(ScriptState* scriptState, ScriptPromise& promise, const Scri
ptValueTest& valueTest) |
92 { | 92 { |
93 StubScriptFunction resolved, rejected; | 93 StubScriptFunction resolved, rejected; |
94 promise.then(resolved.function(scriptState), rejected.function(scriptState))
; | 94 promise.then(resolved.function(scriptState), rejected.function(scriptState))
; |
95 promise.isolate()->RunMicrotasks(); | 95 v8::MicrotasksScope::PerformCheckpoint(promise.isolate()); |
96 EXPECT_EQ(0ul, resolved.callCount()); | 96 EXPECT_EQ(0ul, resolved.callCount()); |
97 EXPECT_EQ(1ul, rejected.callCount()); | 97 EXPECT_EQ(1ul, rejected.callCount()); |
98 if (rejected.callCount()) | 98 if (rejected.callCount()) |
99 valueTest(rejected.arg()); | 99 valueTest(rejected.arg()); |
100 } | 100 } |
101 | 101 |
102 // DOM-related test support. | 102 // DOM-related test support. |
103 | 103 |
104 // Matches a ScriptValue and a DOMException with a specific name and message. | 104 // Matches a ScriptValue and a DOMException with a specific name and message. |
105 class ExpectDOMException : public ScriptValueTest { | 105 class ExpectDOMException : public ScriptValueTest { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 container->getRegistration(getScriptState(), ""); | 356 container->getRegistration(getScriptState(), ""); |
357 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 357 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
358 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); | 358 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); |
359 } | 359 } |
360 | 360 |
361 container->willBeDetachedFromFrame(); | 361 container->willBeDetachedFromFrame(); |
362 } | 362 } |
363 | 363 |
364 } // namespace | 364 } // namespace |
365 } // namespace blink | 365 } // namespace blink |
OLD | NEW |