| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2  * Copyright (C) 2006, 2007, 2008, 2009 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 12 matching lines...) Expand all  Loading... | 
| 23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 
| 24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
| 25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| 26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 29  */ | 29  */ | 
| 30 | 30 | 
| 31 #include "bindings/core/v8/V8Binding.h" | 31 #include "bindings/core/v8/V8Binding.h" | 
| 32 | 32 | 
|  | 33 #include "bindings/core/v8/ConditionalFeatures.h" | 
| 33 #include "bindings/core/v8/ScriptController.h" | 34 #include "bindings/core/v8/ScriptController.h" | 
| 34 #include "bindings/core/v8/V8AbstractEventListener.h" | 35 #include "bindings/core/v8/V8AbstractEventListener.h" | 
| 35 #include "bindings/core/v8/V8ArrayBufferView.h" | 36 #include "bindings/core/v8/V8ArrayBufferView.h" | 
| 36 #include "bindings/core/v8/V8BindingMacros.h" | 37 #include "bindings/core/v8/V8BindingMacros.h" | 
|  | 38 #include "bindings/core/v8/V8Document.h" | 
| 37 #include "bindings/core/v8/V8Element.h" | 39 #include "bindings/core/v8/V8Element.h" | 
| 38 #include "bindings/core/v8/V8EventTarget.h" | 40 #include "bindings/core/v8/V8EventTarget.h" | 
| 39 #include "bindings/core/v8/V8HTMLLinkElement.h" | 41 #include "bindings/core/v8/V8HTMLLinkElement.h" | 
| 40 #include "bindings/core/v8/V8NodeFilter.h" | 42 #include "bindings/core/v8/V8NodeFilter.h" | 
| 41 #include "bindings/core/v8/V8NodeFilterCondition.h" | 43 #include "bindings/core/v8/V8NodeFilterCondition.h" | 
| 42 #include "bindings/core/v8/V8ObjectConstructor.h" | 44 #include "bindings/core/v8/V8ObjectConstructor.h" | 
| 43 #include "bindings/core/v8/V8Window.h" | 45 #include "bindings/core/v8/V8Window.h" | 
| 44 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 46 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 
| 45 #include "bindings/core/v8/V8WorkletGlobalScope.h" | 47 #include "bindings/core/v8/V8WorkletGlobalScope.h" | 
| 46 #include "bindings/core/v8/V8XPathNSResolver.h" | 48 #include "bindings/core/v8/V8XPathNSResolver.h" | 
| 47 #include "bindings/core/v8/WindowProxy.h" | 49 #include "bindings/core/v8/WindowProxy.h" | 
| 48 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 50 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 
| 49 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" | 51 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" | 
| 50 #include "core/dom/Document.h" | 52 #include "core/dom/Document.h" | 
| 51 #include "core/dom/Element.h" | 53 #include "core/dom/Element.h" | 
| 52 #include "core/dom/FlexibleArrayBufferView.h" | 54 #include "core/dom/FlexibleArrayBufferView.h" | 
| 53 #include "core/dom/NodeFilter.h" | 55 #include "core/dom/NodeFilter.h" | 
| 54 #include "core/dom/QualifiedName.h" | 56 #include "core/dom/QualifiedName.h" | 
| 55 #include "core/frame/LocalDOMWindow.h" | 57 #include "core/frame/LocalDOMWindow.h" | 
| 56 #include "core/frame/LocalFrame.h" | 58 #include "core/frame/LocalFrame.h" | 
| 57 #include "core/frame/Settings.h" | 59 #include "core/frame/Settings.h" | 
| 58 #include "core/inspector/InspectorTraceEvents.h" | 60 #include "core/inspector/InspectorTraceEvents.h" | 
| 59 #include "core/loader/FrameLoader.h" | 61 #include "core/loader/FrameLoader.h" | 
| 60 #include "core/loader/FrameLoaderClient.h" | 62 #include "core/loader/FrameLoaderClient.h" | 
| 61 #include "core/origin_trials/OriginTrialContext.h" | 63 #include "core/origin_trials/OriginTrialContext.h" | 
| 62 #include "core/workers/WorkerGlobalScope.h" | 64 #include "core/workers/WorkerGlobalScope.h" | 
| 63 #include "core/workers/WorkletGlobalScope.h" | 65 #include "core/workers/WorkletGlobalScope.h" | 
| 64 #include "core/xml/XPathNSResolver.h" | 66 #include "core/xml/XPathNSResolver.h" | 
| 65 #include "platform/TracedValue.h" | 67 #include "platform/TracedValue.h" | 
|  | 68 #include "platform/feature_policy/FeaturePolicy.h" | 
| 66 #include "wtf/MathExtras.h" | 69 #include "wtf/MathExtras.h" | 
| 67 #include "wtf/StdLibExtras.h" | 70 #include "wtf/StdLibExtras.h" | 
| 68 #include "wtf/Threading.h" | 71 #include "wtf/Threading.h" | 
| 69 #include "wtf/text/AtomicString.h" | 72 #include "wtf/text/AtomicString.h" | 
| 70 #include "wtf/text/CString.h" | 73 #include "wtf/text/CString.h" | 
| 71 #include "wtf/text/CharacterNames.h" | 74 #include "wtf/text/CharacterNames.h" | 
| 72 #include "wtf/text/StringBuffer.h" | 75 #include "wtf/text/StringBuffer.h" | 
| 73 #include "wtf/text/StringHash.h" | 76 #include "wtf/text/StringHash.h" | 
| 74 #include "wtf/text/Unicode.h" | 77 #include "wtf/text/Unicode.h" | 
| 75 #include "wtf/text/WTFString.h" | 78 #include "wtf/text/WTFString.h" | 
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 805 } | 808 } | 
| 806 | 809 | 
| 807 void installOriginTrialsCore(ScriptState* scriptState) | 810 void installOriginTrialsCore(ScriptState* scriptState) | 
| 808 { | 811 { | 
| 809     // TODO(iclelland): Generate all of this logic at compile-time, based on the | 812     // TODO(iclelland): Generate all of this logic at compile-time, based on the | 
| 810     // configuration of origin trial enabled attibutes and interfaces in IDL | 813     // configuration of origin trial enabled attibutes and interfaces in IDL | 
| 811     // files. (crbug.com/615060) | 814     // files. (crbug.com/615060) | 
| 812 | 815 | 
| 813     ExecutionContext* executionContext = scriptState->getExecutionContext(); | 816     ExecutionContext* executionContext = scriptState->getExecutionContext(); | 
| 814     OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC
      ontext, OriginTrialContext::DontCreateIfNotExists); | 817     OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC
      ontext, OriginTrialContext::DontCreateIfNotExists); | 
| 815     if (!originTrialContext) | 818 | 
|  | 819     if (originTrialContext) { | 
|  | 820         if (!originTrialContext->featureBindingsInstalled("LinkServiceWorker") &
      & (RuntimeEnabledFeatures::linkServiceWorkerEnabled() || originTrialContext->isF
      eatureEnabled("ForeignFetch"))) { | 
|  | 821             if (executionContext->isDocument()) { | 
|  | 822                 V8HTMLLinkElement::installLinkServiceWorker(scriptState); | 
|  | 823             } | 
|  | 824         } | 
|  | 825     } | 
|  | 826 | 
|  | 827     // Install feature-policy-controlled features, if necessary | 
|  | 828     LocalDOMWindow* domwindow = scriptState->domWindow(); | 
|  | 829     if (!domwindow) | 
| 816         return; | 830         return; | 
|  | 831     LocalFrame* frame = domwindow->frame(); | 
|  | 832     if (!frame) | 
|  | 833         return; | 
|  | 834     if (RuntimeEnabledFeatures::featurePolicyEnabled()) { | 
|  | 835         // Feature policy is active, so we need to check that it isn't too early | 
|  | 836         // to decide which features to install, and also abort if we've already | 
|  | 837         // installed them. | 
|  | 838         FeaturePolicy* policy = frame->getFeaturePolicy(); | 
|  | 839         if (!policy) | 
|  | 840             return; | 
|  | 841         if (policy->featurePolicyBindingsInstalled()) | 
|  | 842             return; | 
|  | 843     } | 
| 817 | 844 | 
| 818     if (!originTrialContext->featureBindingsInstalled("LinkServiceWorker") && (R
      untimeEnabledFeatures::linkServiceWorkerEnabled() || originTrialContext->isFeatu
      reEnabled("ForeignFetch"))) { | 845     if (executionContext->isDocument()) { | 
| 819         if (executionContext->isDocument()) { | 846         ScriptState::Scope scope(scriptState); | 
| 820             V8HTMLLinkElement::installLinkServiceWorker(scriptState); | 847         v8::Local<v8::Context> context = scriptState->context(); | 
| 821         } | 848         v8::Local<v8::Object> global = context->Global(); | 
|  | 849         v8::Isolate* isolate = scriptState->isolate(); | 
|  | 850         v8::Local<v8::String> documentName = v8::String::NewFromOneByte(isolate,
       reinterpret_cast<const uint8_t*>("document"), v8::NewStringType::kNormal).ToLoc
      alChecked(); | 
|  | 851         v8::Local<v8::Object> document = global->Get(context, documentName).ToLo
      calChecked()->ToObject(); | 
|  | 852         if (isFeatureEnabledInFrame(&blink::kDocumentCookie, frame)) | 
|  | 853             V8Document::installDocumentCookie(scriptState, document); | 
|  | 854         if (isFeatureEnabledInFrame(&blink::kDocumentDomain, frame)) | 
|  | 855             V8Document::installDocumentDomain(scriptState, document); | 
|  | 856         if (isFeatureEnabledInFrame(&blink::kDocumentWrite, frame)) | 
|  | 857             V8Document::installDocumentWrite(scriptState, document); | 
| 822     } | 858     } | 
| 823 } | 859 } | 
| 824 | 860 | 
| 825 namespace { | 861 namespace { | 
| 826 InstallOriginTrialsFunction s_installOriginTrialsFunction = &installOriginTrials
      Core; | 862 InstallOriginTrialsFunction s_installOriginTrialsFunction = &installOriginTrials
      Core; | 
| 827 } | 863 } | 
| 828 | 864 | 
| 829 void installOriginTrials(ScriptState* scriptState) | 865 void installOriginTrials(ScriptState* scriptState) | 
| 830 { | 866 { | 
| 831     v8::Local<v8::Context> context = scriptState->context(); | 867     v8::Local<v8::Context> context = scriptState->context(); | 
| 832     ExecutionContext* executionContext = toExecutionContext(context); | 868     ExecutionContext* executionContext = toExecutionContext(context); | 
| 833     OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC
      ontext, OriginTrialContext::DontCreateIfNotExists); |  | 
| 834     if (!originTrialContext) |  | 
| 835         return; |  | 
| 836 |  | 
| 837     ScriptState::Scope scope(scriptState); | 869     ScriptState::Scope scope(scriptState); | 
| 838 | 870 | 
| 839     (*s_installOriginTrialsFunction)(scriptState); | 871     (*s_installOriginTrialsFunction)(scriptState); | 
| 840 | 872 | 
|  | 873     OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC
      ontext, OriginTrialContext::DontCreateIfNotExists); | 
|  | 874     if (!originTrialContext) | 
|  | 875         return; | 
| 841     // Mark each enabled feature as having been installed. | 876     // Mark each enabled feature as having been installed. | 
| 842     if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt
      imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab
      led("DurableStorage"))) { | 877     if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt
      imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab
      led("DurableStorage"))) { | 
| 843         originTrialContext->setFeatureBindingsInstalled("DurableStorage"); | 878         originTrialContext->setFeatureBindingsInstalled("DurableStorage"); | 
| 844     } | 879     } | 
| 845 | 880 | 
| 846     if (!originTrialContext->featureBindingsInstalled("WebBluetooth") && (Runtim
      eEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEnabled(
      "WebBluetooth"))) { | 881     if (!originTrialContext->featureBindingsInstalled("WebBluetooth") && (Runtim
      eEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEnabled(
      "WebBluetooth"))) { | 
| 847         originTrialContext->setFeatureBindingsInstalled("WebBluetooth"); | 882         originTrialContext->setFeatureBindingsInstalled("WebBluetooth"); | 
| 848     } | 883     } | 
| 849 | 884 | 
| 850     if (!originTrialContext->featureBindingsInstalled("WebShare") && (RuntimeEna
      bledFeatures::webShareEnabled() || originTrialContext->isFeatureEnabled("WebShar
      e"))) { | 885     if (!originTrialContext->featureBindingsInstalled("WebShare") && (RuntimeEna
      bledFeatures::webShareEnabled() || originTrialContext->isFeatureEnabled("WebShar
      e"))) { | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 963     return frame->script().isolate(); | 998     return frame->script().isolate(); | 
| 964 } | 999 } | 
| 965 | 1000 | 
| 966 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso
      late) | 1001 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso
      late) | 
| 967 { | 1002 { | 
| 968     value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentContext(), v8::
      IntegrityLevel::kFrozen).ToChecked(); | 1003     value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentContext(), v8::
      IntegrityLevel::kFrozen).ToChecked(); | 
| 969     return value; | 1004     return value; | 
| 970 } | 1005 } | 
| 971 | 1006 | 
| 972 } // namespace blink | 1007 } // namespace blink | 
| OLD | NEW | 
|---|