Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequestTestBase.cpp

Issue 2048823004: PaymentRequest.abort() should return a promise. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include what you use Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/payments/PaymentRequestTestBase.h"
6
7 #include "bindings/core/v8/ScriptState.h"
8 #include "core/dom/Document.h"
9 #include "core/frame/LocalDOMWindow.h"
10 #include "platform/weborigin/KURL.h"
11 #include "platform/weborigin/SecurityOrigin.h"
12
13 namespace blink {
14
15 PaymentRequestTestBase::PaymentRequestTestBase()
16 {
17 DCHECK(getScriptState()->getExecutionContext());
18 DCHECK(getScriptState()->domWindow());
19 DCHECK(getScriptState()->domWindow()->document());
20 DCHECK(getScriptState()->domWindow()->frame());
21 setSecurityOrigin("https://www.example.com/");
22 }
23
24 PaymentRequestTestBase::~PaymentRequestTestBase()
25 {
26 firePromiseCallbacks();
27 for (MockFunction* mockFunction : m_mockFunctions) {
28 testing::Mock::VerifyAndClearExpectations(mockFunction);
29 }
30 }
31
32 ScriptState* PaymentRequestTestBase::getScriptState()
33 {
34 return m_scriptState.getScriptState();
35 }
36
37 ExceptionState& PaymentRequestTestBase::getExceptionState()
38 {
39 return m_exceptionState;
40 }
41
42 void PaymentRequestTestBase::setSecurityOrigin(const String& securityOrigin)
43 {
44 getScriptState()->domWindow()->document()->updateSecurityOrigin(SecurityOrig in::create(KURL(KURL(), securityOrigin)));
45 }
46
47 v8::Local<v8::Function> PaymentRequestTestBase::expectCall()
48 {
49 m_mockFunctions.append(new MockFunction(getScriptState()));
50 EXPECT_CALL(*m_mockFunctions.last(), call(testing::_));
51 return m_mockFunctions.last()->bind();
52 }
53
54 v8::Local<v8::Function> PaymentRequestTestBase::expectNoCall()
55 {
56 m_mockFunctions.append(new MockFunction(getScriptState()));
57 EXPECT_CALL(*m_mockFunctions.last(), call(testing::_)).Times(0);
58 return m_mockFunctions.last()->bind();
59 }
60
61 void PaymentRequestTestBase::firePromiseCallbacks()
62 {
63 v8::MicrotasksScope::PerformCheckpoint(getScriptState()->isolate());
64 }
65
66 PaymentRequestTestBase::MockFunction::MockFunction(ScriptState* scriptState)
67 : ScriptFunction(scriptState)
68 {
69 ON_CALL(*this, call(testing::_)).WillByDefault(testing::ReturnArg<0>());
70 }
71
72 v8::Local<v8::Function> PaymentRequestTestBase::MockFunction::bind()
73 {
74 return bindToV8Function();
75 }
76
77 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698