Index: third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp |
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp |
index d0bb9de194cf24ec8ad2487adc5c89c2ed997404..dcc2d54cedc5ed3ac026bf101ef3468c1fa13e39 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp |
@@ -30,10 +30,12 @@ |
#include "bindings/core/v8/V8Binding.h" |
+#include "bindings/core/v8/ConditionalFeatures.h" |
#include "bindings/core/v8/ScriptController.h" |
#include "bindings/core/v8/V8AbstractEventListener.h" |
#include "bindings/core/v8/V8ArrayBufferView.h" |
#include "bindings/core/v8/V8BindingMacros.h" |
+#include "bindings/core/v8/V8Document.h" |
#include "bindings/core/v8/V8Element.h" |
#include "bindings/core/v8/V8EventTarget.h" |
#include "bindings/core/v8/V8HTMLLinkElement.h" |
@@ -63,6 +65,7 @@ |
#include "core/workers/WorkletGlobalScope.h" |
#include "core/xml/XPathNSResolver.h" |
#include "platform/TracedValue.h" |
+#include "platform/feature_policy/FeaturePolicy.h" |
#include "wtf/MathExtras.h" |
#include "wtf/StdLibExtras.h" |
#include "wtf/Threading.h" |
@@ -812,14 +815,47 @@ void installOriginTrialsCore(ScriptState* scriptState) |
ExecutionContext* executionContext = scriptState->getExecutionContext(); |
OriginTrialContext* originTrialContext = OriginTrialContext::from(executionContext, OriginTrialContext::DontCreateIfNotExists); |
- if (!originTrialContext) |
- return; |
- if (!originTrialContext->featureBindingsInstalled("LinkServiceWorker") && (RuntimeEnabledFeatures::linkServiceWorkerEnabled() || originTrialContext->isFeatureEnabled("ForeignFetch"))) { |
- if (executionContext->isDocument()) { |
- V8HTMLLinkElement::installLinkServiceWorker(scriptState); |
+ if (originTrialContext) { |
+ if (!originTrialContext->featureBindingsInstalled("LinkServiceWorker") && (RuntimeEnabledFeatures::linkServiceWorkerEnabled() || originTrialContext->isFeatureEnabled("ForeignFetch"))) { |
+ if (executionContext->isDocument()) { |
+ V8HTMLLinkElement::installLinkServiceWorker(scriptState); |
+ } |
} |
} |
+ |
+ // Install feature-policy-controlled features, if necessary |
+ LocalDOMWindow* domwindow = scriptState->domWindow(); |
+ if (!domwindow) |
+ return; |
+ LocalFrame* frame = domwindow->frame(); |
+ if (!frame) |
+ return; |
+ if (RuntimeEnabledFeatures::featurePolicyEnabled()) { |
+ // Feature policy is active, so we need to check that it isn't too early |
+ // to decide which features to install, and also abort if we've already |
+ // installed them. |
+ FeaturePolicy* policy = frame->getFeaturePolicy(); |
+ if (!policy) |
+ return; |
+ if (policy->featurePolicyBindingsInstalled()) |
+ return; |
+ } |
+ |
+ if (executionContext->isDocument()) { |
+ ScriptState::Scope scope(scriptState); |
+ v8::Local<v8::Context> context = scriptState->context(); |
+ v8::Local<v8::Object> global = context->Global(); |
+ v8::Isolate* isolate = scriptState->isolate(); |
+ v8::Local<v8::String> documentName = v8::String::NewFromOneByte(isolate, reinterpret_cast<const uint8_t*>("document"), v8::NewStringType::kNormal).ToLocalChecked(); |
+ v8::Local<v8::Object> document = global->Get(context, documentName).ToLocalChecked()->ToObject(); |
+ if (isFeatureEnabledInFrame(&blink::kDocumentCookie, frame)) |
+ V8Document::installDocumentCookie(scriptState, document); |
+ if (isFeatureEnabledInFrame(&blink::kDocumentDomain, frame)) |
+ V8Document::installDocumentDomain(scriptState, document); |
+ if (isFeatureEnabledInFrame(&blink::kDocumentWrite, frame)) |
+ V8Document::installDocumentWrite(scriptState, document); |
+ } |
} |
namespace { |
@@ -830,14 +866,13 @@ void installOriginTrials(ScriptState* scriptState) |
{ |
v8::Local<v8::Context> context = scriptState->context(); |
ExecutionContext* executionContext = toExecutionContext(context); |
- OriginTrialContext* originTrialContext = OriginTrialContext::from(executionContext, OriginTrialContext::DontCreateIfNotExists); |
- if (!originTrialContext) |
- return; |
- |
ScriptState::Scope scope(scriptState); |
(*s_installOriginTrialsFunction)(scriptState); |
+ OriginTrialContext* originTrialContext = OriginTrialContext::from(executionContext, OriginTrialContext::DontCreateIfNotExists); |
+ if (!originTrialContext) |
+ return; |
// Mark each enabled feature as having been installed. |
if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (RuntimeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnabled("DurableStorage"))) { |
originTrialContext->setFeatureBindingsInstalled("DurableStorage"); |