blob: 9318cc07315ccbbb624c9ae02edc42a573e30e6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/testing/null_execution_context.h"
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/execution_context/security_context_init.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/dom_timer.h"
#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"
#include "third_party/blink/renderer/platform/scheduler/public/dummy_schedulers.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
namespace blink {
NullExecutionContext::NullExecutionContext(
OriginTrialContext* origin_trial_context)
: ExecutionContext(v8::Isolate::GetCurrent()),
security_context_(
SecurityContextInit(
nullptr /* origin */,
origin_trial_context,
MakeGarbageCollected<Agent>(v8::Isolate::GetCurrent(),
base::UnguessableToken::Null())),
SecurityContext::kWindow),
scheduler_(scheduler::CreateDummyFrameScheduler()) {
if (origin_trial_context)
origin_trial_context->BindExecutionContext(this);
}
NullExecutionContext::~NullExecutionContext() {}
void NullExecutionContext::SetUpSecurityContextForTesting() {
auto* policy = MakeGarbageCollected<ContentSecurityPolicy>();
GetSecurityContext().SetSecurityOriginForTesting(
SecurityOrigin::Create(url_));
policy->BindToDelegate(GetContentSecurityPolicyDelegate());
GetSecurityContext().SetContentSecurityPolicy(policy);
}
FrameOrWorkerScheduler* NullExecutionContext::GetScheduler() {
return scheduler_.get();
}
scoped_refptr<base::SingleThreadTaskRunner> NullExecutionContext::GetTaskRunner(
TaskType) {
return Thread::Current()->GetTaskRunner();
}
BrowserInterfaceBrokerProxy& NullExecutionContext::GetBrowserInterfaceBroker() {
return GetEmptyBrowserInterfaceBroker();
}
void NullExecutionContext::Trace(Visitor* visitor) {
visitor->Trace(security_context_);
ExecutionContext::Trace(visitor);
}
} // namespace blink
|