Diff
Modified: trunk/Source/WebCore/ChangeLog (218026 => 218027)
--- trunk/Source/WebCore/ChangeLog 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/ChangeLog 2017-06-09 23:38:05 UTC (rev 218027)
@@ -1,3 +1,70 @@
+2017-06-09 Daniel Bates <[email protected]>
+
+ Implement W3C Secure Contexts Draft Specification
+ https://bugs.webkit.org/show_bug.cgi?id=158121
+ <rdar://problem/26012994>
+
+ Reviewed by Chris Dumez.
+
+ Part 1
+
+ Teach the bindings code generator to generate a runtime check for an interface, attribute or
+ function annotated with the extended attribute [SecureContext]. For now, the runtime check
+ (ScriptExecutionContext::isSecureContext()) always returns true. We will flesh out the
+ implementation of this runtime check in a subsequent commit.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (NeedsRuntimeCheck):
+ (GenerateRuntimeEnableConditionalString):
+ Generate a runtime check for an interface, attribute, or function that is annotated with
+ the extended attribute [SecureContext].
+
+ * bindings/scripts/IDLAttributes.json: Update JSON now that we support SecureContext.
+ * bindings/scripts/preprocess-idls.pl:
+ (GenerateConstructorAttributes): Add the SecureContext extended attribute to a constructor,
+ if applicable.
+
+ * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
+ (WebCore::JSTestGenerateIsReachablePrototype::finishCreation):
+ (WebCore::IDLAttribute<JSTestGenerateIsReachable>::cast):
+ (WebCore::jsTestGenerateIsReachableASecretAttributeGetter):
+ (WebCore::jsTestGenerateIsReachableASecretAttribute):
+ * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
+ (WebCore::JSTestGlobalObject::finishCreation):
+ (WebCore::jsTestGlobalObjectInstanceFunctionCalculateSecretResultBody):
+ (WebCore::jsTestGlobalObjectInstanceFunctionCalculateSecretResult):
+ (WebCore::jsTestGlobalObjectInstanceFunctionGetSecretBooleanBody):
+ (WebCore::jsTestGlobalObjectInstanceFunctionGetSecretBoolean):
+ (WebCore::jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBooleanBody):
+ (WebCore::jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBoolean):
+ * bindings/scripts/test/JS/JSTestNode.cpp:
+ (WebCore::JSTestNodePrototype::finishCreation):
+ (WebCore::jsTestNodePrototypeFunctionCalculateSecretResultBody):
+ (WebCore::jsTestNodePrototypeFunctionCalculateSecretResult):
+ (WebCore::jsTestNodePrototypeFunctionGetSecretBooleanBody):
+ (WebCore::jsTestNodePrototypeFunctionGetSecretBoolean):
+ (WebCore::jsTestNodePrototypeFunctionTestFeatureGetSecretBooleanBody):
+ (WebCore::jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::JSTestObjPrototype::finishCreation):
+ (WebCore::jsTestObjPrototypeFunctionCalculateSecretResultBody):
+ (WebCore::jsTestObjPrototypeFunctionCalculateSecretResult):
+ (WebCore::jsTestObjPrototypeFunctionGetSecretBooleanBody):
+ (WebCore::jsTestObjPrototypeFunctionGetSecretBoolean):
+ (WebCore::jsTestObjPrototypeFunctionTestFeatureGetSecretBooleanBody):
+ (WebCore::jsTestObjPrototypeFunctionTestFeatureGetSecretBoolean):
+ Update expected results.
+
+ * bindings/scripts/test/TestGenerateIsReachable.idl:
+ * bindings/scripts/test/TestGlobalObject.idl:
+ * bindings/scripts/test/TestNode.idl:
+ * bindings/scripts/test/TestObj.idl:
+ Add test cases.
+
+ * dom/ScriptExecutionContext.h:
+ (WebCore::ScriptExecutionContext::isSecureContext): Added. For now, always returns true.
+ We will implement this function in a subsequent commit.
+
2017-06-09 Jer Noble <[email protected]>
Media elements are allowed to continue to load media data after navigation
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-06-09 23:38:05 UTC (rev 218027)
@@ -1400,7 +1400,8 @@
{
my $interface = shift;
return $interface->extendedAttributes->{EnabledAtRuntime}
- || $interface->extendedAttributes->{EnabledForWorld};
+ || $interface->extendedAttributes->{EnabledForWorld}
+ || $interface->extendedAttributes->{SecureContext};
}
sub NeedsSettingsCheckForPrototypeProperty
@@ -3350,8 +3351,11 @@
my $context = shift;
AddToImplIncludes("RuntimeEnabledFeatures.h");
+ AddToImplIncludes("ScriptExecutionContext.h");
my @conjuncts;
+ push @conjuncts, "jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()" if $context->extendedAttributes->{SecureContext};
+
if ($context->extendedAttributes->{EnabledForWorld}) {
assert("Must specify value for EnabledForWorld.") if $context->extendedAttributes->{EnabledForWorld} eq "VALUE_IS_MISSING";
push @conjuncts, "worldForDOMObject(this)." . ToMethodName($context->extendedAttributes->{EnabledForWorld}) . "()";
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json 2017-06-09 23:38:05 UTC (rev 218027)
@@ -396,8 +396,7 @@
"contextsAllowed": ["interface", "dictionary", "enum", "attribute", "operation", "constant"],
"standard": {
"url": "https://heycam.github.io/webidl/#SecureContext"
- },
- "unsupported": true
+ }
},
"SetterCallWith": {
"contextsAllowed": ["attribute"],
Modified: trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl 2017-06-09 23:38:05 UTC (rev 218027)
@@ -247,7 +247,9 @@
my $code = " ";
my @extendedAttributesList;
foreach my $attributeName (sort keys %{$extendedAttributes}) {
- next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledForWorld" || $attributeName eq "EnabledBySetting" || $attributeName eq "PrivateIdentifier" || $attributeName eq "PublicIdentifier");
+ next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledForWorld"
+ || $attributeName eq "EnabledBySetting" || $attributeName eq "SecureContext" || $attributeName eq "PrivateIdentifier"
+ || $attributeName eq "PublicIdentifier");
my $extendedAttribute = $attributeName;
$extendedAttribute .= "=" . $extendedAttributes->{$attributeName} unless $extendedAttributes->{$attributeName} eq "VALUE_IS_MISSING";
push(@extendedAttributesList, $extendedAttribute);
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp 2017-06-09 23:38:05 UTC (rev 218027)
@@ -21,10 +21,14 @@
#include "config.h"
#include "JSTestGenerateIsReachable.h"
+#include "JSDOMAttribute.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructorNotConstructable.h"
+#include "JSDOMConvert.h"
#include "JSDOMExceptionHandling.h"
#include "JSDOMWrapperCache.h"
+#include "RuntimeEnabledFeatures.h"
+#include "ScriptExecutionContext.h"
#include <runtime/FunctionPrototype.h>
#include <wtf/GetPtr.h>
@@ -36,6 +40,7 @@
JSC::EncodedJSValue jsTestGenerateIsReachableConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSTestGenerateIsReachableConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestGenerateIsReachableASecretAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
class JSTestGenerateIsReachablePrototype : public JSC::JSNonFinalObject {
public:
@@ -84,6 +89,7 @@
static const HashTableValue JSTestGenerateIsReachablePrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGenerateIsReachableConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGenerateIsReachableConstructor) } },
+ { "aSecretAttribute", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGenerateIsReachableASecretAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
const ClassInfo JSTestGenerateIsReachablePrototype::s_info = { "TestGenerateIsReachablePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestGenerateIsReachablePrototype) };
@@ -92,6 +98,11 @@
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTestGenerateIsReachablePrototypeTableValues, *this);
+ if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
+ Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("aSecretAttribute"), strlen("aSecretAttribute"));
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
+ }
}
const ClassInfo JSTestGenerateIsReachable::s_info = { "TestGenerateIsReachable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestGenerateIsReachable) };
@@ -129,6 +140,11 @@
thisObject->JSTestGenerateIsReachable::~JSTestGenerateIsReachable();
}
+template<> inline JSTestGenerateIsReachable* IDLAttribute<JSTestGenerateIsReachable>::cast(ExecState& state, EncodedJSValue thisValue)
+{
+ return jsDynamicDowncast<JSTestGenerateIsReachable*>(state.vm(), JSValue::decode(thisValue));
+}
+
EncodedJSValue jsTestGenerateIsReachableConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
@@ -152,6 +168,20 @@
return prototype->putDirect(state->vm(), state->propertyNames().constructor, JSValue::decode(encodedValue));
}
+static inline JSValue jsTestGenerateIsReachableASecretAttributeGetter(ExecState& state, JSTestGenerateIsReachable& thisObject, ThrowScope& throwScope)
+{
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(state);
+ auto& impl = thisObject.wrapped();
+ JSValue result = toJS<IDLDOMString>(state, impl.aSecretAttribute());
+ return result;
+}
+
+EncodedJSValue jsTestGenerateIsReachableASecretAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+ return IDLAttribute<JSTestGenerateIsReachable>::get<jsTestGenerateIsReachableASecretAttributeGetter>(*state, thisValue, "aSecretAttribute");
+}
+
bool JSTestGenerateIsReachableOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsTestGenerateIsReachable = jsCast<JSTestGenerateIsReachable*>(handle.slot()->asCell());
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp 2017-06-09 23:38:05 UTC (rev 218027)
@@ -27,8 +27,10 @@
#include "JSDOMConvert.h"
#include "JSDOMExceptionHandling.h"
#include "JSDOMOperation.h"
+#include "JSDOMOperationReturningPromise.h"
#include "JSDOMWrapperCache.h"
#include "RuntimeEnabledFeatures.h"
+#include "ScriptExecutionContext.h"
#include "WebCoreJSClientData.h"
#include <runtime/FunctionPrototype.h>
#include <wtf/GetPtr.h>
@@ -53,6 +55,11 @@
#if ENABLE(TEST_FEATURE)
JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(JSC::ExecState*);
#endif
+JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionCalculateSecretResult(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionGetSecretBoolean(JSC::ExecState*);
+#if ENABLE(TEST_FEATURE)
+JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBoolean(JSC::ExecState*);
+#endif
// Attributes
@@ -179,6 +186,14 @@
if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
putDirectBuiltinFunction(vm, this, vm.propertyNames->testJSBuiltinFunction, testGlobalObjectTestJSBuiltinFunctionCodeGenerator(vm), attributesForStructure(JSC::Builtin));
#endif
+ if (jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext())
+ putDirectNativeFunction(vm, this, vm.propertyNames->calculateSecretResult, 0, jsTestGlobalObjectInstanceFunctionCalculateSecretResult, NoIntrinsic, attributesForStructure(JSC::Function));
+ if (jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext())
+ putDirectNativeFunction(vm, this, vm.propertyNames->getSecretBoolean, 0, jsTestGlobalObjectInstanceFunctionGetSecretBoolean, NoIntrinsic, attributesForStructure(JSC::Function));
+#if ENABLE(TEST_FEATURE)
+ if ((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()))
+ putDirectNativeFunction(vm, this, vm.propertyNames->testFeatureGetSecretBoolean, 0, jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBoolean, NoIntrinsic, attributesForStructure(JSC::Function));
+#endif
}
JSValue JSTestGlobalObject::getConstructor(VM& vm, const JSGlobalObject* globalObject)
@@ -503,6 +518,49 @@
#endif
+static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionCalculateSecretResultBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSTestGlobalObject>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ impl.calculateSecretResult(WTFMove(promise));
+ return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionCalculateSecretResult(ExecState* state)
+{
+ return IDLOperationReturningPromise<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionCalculateSecretResultBody, PromiseExecutionScope::WindowOnly>(*state, "calculateSecretResult");
+}
+
+static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ return JSValue::encode(toJS<IDLBoolean>(impl.getSecretBoolean()));
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionGetSecretBoolean(ExecState* state)
+{
+ return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionGetSecretBooleanBody>(*state, "getSecretBoolean");
+}
+
+#if ENABLE(TEST_FEATURE)
+static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ return JSValue::encode(toJS<IDLBoolean>(impl.testFeatureGetSecretBoolean()));
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBoolean(ExecState* state)
+{
+ return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBooleanBody>(*state, "testFeatureGetSecretBoolean");
+}
+
+#endif
+
bool JSTestGlobalObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp 2017-06-09 23:38:05 UTC (rev 218027)
@@ -31,6 +31,7 @@
#include "JSDOMOperationReturningPromise.h"
#include "JSDOMWrapperCache.h"
#include "RuntimeEnabledFeatures.h"
+#include "ScriptExecutionContext.h"
#include <builtins/BuiltinNames.h>
#include <runtime/Error.h>
#include <runtime/ObjectConstructor.h>
@@ -43,6 +44,11 @@
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionCalculateSecretResult(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionGetSecretBoolean(JSC::ExecState*);
+#if ENABLE(TEST_FEATURE)
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean(JSC::ExecState*);
+#endif
JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState*);
@@ -116,6 +122,13 @@
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } },
{ "name", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeName) } },
{ "testWorkerPromise", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionTestWorkerPromise), (intptr_t) (0) } },
+ { "calculateSecretResult", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionCalculateSecretResult), (intptr_t) (0) } },
+ { "getSecretBoolean", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionGetSecretBoolean), (intptr_t) (0) } },
+#if ENABLE(TEST_FEATURE)
+ { "testFeatureGetSecretBoolean", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean), (intptr_t) (0) } },
+#else
+ { 0, 0, NoIntrinsic, { 0, 0 } },
+#endif
{ "entries", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionEntries), (intptr_t) (0) } },
{ "keys", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionKeys), (intptr_t) (0) } },
{ "values", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionValues), (intptr_t) (0) } },
@@ -129,6 +142,23 @@
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTestNodePrototypeTableValues, *this);
+ if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
+ Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("calculateSecretResult"), strlen("calculateSecretResult"));
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
+ }
+ if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
+ Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getSecretBoolean"), strlen("getSecretBoolean"));
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
+ }
+#if ENABLE(TEST_FEATURE)
+ if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())) {
+ Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("testFeatureGetSecretBoolean"), strlen("testFeatureGetSecretBoolean"));
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
+ }
+#endif
if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("entries"), strlen("entries"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
@@ -258,6 +288,49 @@
return IDLOperationReturningPromise<JSTestNode>::call<jsTestNodePrototypeFunctionTestWorkerPromiseBody, PromiseExecutionScope::WindowOrWorker>(*state, "testWorkerPromise");
}
+static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionCalculateSecretResultBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSTestNode>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ impl.calculateSecretResult(WTFMove(promise));
+ return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionCalculateSecretResult(ExecState* state)
+{
+ return IDLOperationReturningPromise<JSTestNode>::call<jsTestNodePrototypeFunctionCalculateSecretResultBody, PromiseExecutionScope::WindowOrWorker>(*state, "calculateSecretResult");
+}
+
+static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ return JSValue::encode(toJS<IDLBoolean>(impl.getSecretBoolean()));
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionGetSecretBoolean(ExecState* state)
+{
+ return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionGetSecretBooleanBody>(*state, "getSecretBoolean");
+}
+
+#if ENABLE(TEST_FEATURE)
+static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionTestFeatureGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ return JSValue::encode(toJS<IDLBoolean>(impl.testFeatureGetSecretBoolean()));
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean(ExecState* state)
+{
+ return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionTestFeatureGetSecretBooleanBody>(*state, "testFeatureGetSecretBoolean");
+}
+
+#endif
+
struct TestNodeIteratorTraits {
static constexpr JSDOMIteratorType type = JSDOMIteratorType::Set;
using KeyType = void;
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2017-06-09 23:38:05 UTC (rev 218027)
@@ -57,6 +57,7 @@
#include "JSTestSubObj.h"
#include "JSXPathNSResolver.h"
#include "RuntimeEnabledFeatures.h"
+#include "ScriptExecutionContext.h"
#include "SerializedScriptValue.h"
#include "Settings.h"
#include "URL.h"
@@ -1006,6 +1007,11 @@
#if ENABLE(TEST_FEATURE)
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionEnabledBySettingOperation(JSC::ExecState*);
#endif
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCalculateSecretResult(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSecretBoolean(JSC::ExecState*);
+#if ENABLE(TEST_FEATURE)
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestFeatureGetSecretBoolean(JSC::ExecState*);
+#endif
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionByteMethod(JSC::ExecState*);
@@ -1669,6 +1675,13 @@
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
+ { "calculateSecretResult", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCalculateSecretResult), (intptr_t) (0) } },
+ { "getSecretBoolean", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionGetSecretBoolean), (intptr_t) (0) } },
+#if ENABLE(TEST_FEATURE)
+ { "testFeatureGetSecretBoolean", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestFeatureGetSecretBoolean), (intptr_t) (0) } },
+#else
+ { 0, 0, NoIntrinsic, { 0, 0 } },
+#endif
{ "voidMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t) (0) } },
{ "voidMethodWithArgs", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t) (3) } },
{ "byteMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionByteMethod), (intptr_t) (0) } },
@@ -1869,7 +1882,24 @@
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
+ if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
+ Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("calculateSecretResult"), strlen("calculateSecretResult"));
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
+ }
+ if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
+ Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getSecretBoolean"), strlen("getSecretBoolean"));
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
+ }
#if ENABLE(TEST_FEATURE)
+ if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())) {
+ Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("testFeatureGetSecretBoolean"), strlen("testFeatureGetSecretBoolean"));
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
+ }
+#endif
+#if ENABLE(TEST_FEATURE)
if (!(RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled() && RuntimeEnabledFeatures::sharedFeatures().testFeature1Enabled())) {
Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledAtRuntimeAttribute"), strlen("enabledAtRuntimeAttribute"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
@@ -4965,6 +4995,49 @@
#endif
+static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionCalculateSecretResultBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSTestObj>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ impl.calculateSecretResult(WTFMove(promise));
+ return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCalculateSecretResult(ExecState* state)
+{
+ return IDLOperationReturningPromise<JSTestObj>::call<jsTestObjPrototypeFunctionCalculateSecretResultBody, PromiseExecutionScope::WindowOnly>(*state, "calculateSecretResult");
+}
+
+static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestObj>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ return JSValue::encode(toJS<IDLBoolean>(impl.getSecretBoolean()));
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSecretBoolean(ExecState* state)
+{
+ return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionGetSecretBooleanBody>(*state, "getSecretBoolean");
+}
+
+#if ENABLE(TEST_FEATURE)
+static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionTestFeatureGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestObj>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
+{
+ UNUSED_PARAM(state);
+ UNUSED_PARAM(throwScope);
+ auto& impl = castedThis->wrapped();
+ return JSValue::encode(toJS<IDLBoolean>(impl.testFeatureGetSecretBoolean()));
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestFeatureGetSecretBoolean(ExecState* state)
+{
+ return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionTestFeatureGetSecretBooleanBody>(*state, "testFeatureGetSecretBoolean");
+}
+
+#endif
+
static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionVoidMethodBody(JSC::ExecState* state, typename IDLOperation<JSTestObj>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
{
UNUSED_PARAM(state);
Modified: trunk/Source/WebCore/bindings/scripts/test/TestGenerateIsReachable.idl (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/TestGenerateIsReachable.idl 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/TestGenerateIsReachable.idl 2017-06-09 23:38:05 UTC (rev 218027)
@@ -26,5 +26,6 @@
[
GenerateIsReachable=Impl,
] interface TestGenerateIsReachable {
+ [SecureContext] readonly attribute DOMString aSecretAttribute;
};
Modified: trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl 2017-06-09 23:38:05 UTC (rev 218027)
@@ -42,4 +42,10 @@
[PrivateIdentifier, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testPrivateFunction();
[JSBuiltin, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testJSBuiltinFunction();
+
+ // [SecureContext] attributes and operations; will not be exposed to a non-secure context.
+ // From <https://w3c.github.io/webappsec-secure-contexts/#integration-idl> (Editor's Draft, 17 November 2016)
+ [SecureContext] Promise<double> calculateSecretResult();
+ [SecureContext] boolean getSecretBoolean();
+ [Conditional=TEST_FEATURE, SecureContext, EnabledAtRuntime=TestFeature] boolean testFeatureGetSecretBoolean();
};
Modified: trunk/Source/WebCore/bindings/scripts/test/TestNode.idl (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/TestNode.idl 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/TestNode.idl 2017-06-09 23:38:05 UTC (rev 218027)
@@ -28,5 +28,11 @@
[EnabledAtRuntime=DOMIterator] iterable<TestNode>;
Promise<void> testWorkerPromise();
+ // [SecureContext] attributes and operations; will not be exposed to a non-secure context.
+ // From <https://w3c.github.io/webappsec-secure-contexts/#integration-idl> (Editor's Draft, 17 November 2016)
+ [SecureContext] Promise<double> calculateSecretResult();
+ [SecureContext] boolean getSecretBoolean();
+ [Conditional=TEST_FEATURE, SecureContext, EnabledAtRuntime=TestFeature] boolean testFeatureGetSecretBoolean();
+
serializer;
};
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (218026 => 218027)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2017-06-09 23:38:05 UTC (rev 218027)
@@ -119,6 +119,12 @@
[Conditional=TEST_FEATURE, EnabledBySetting=TestSetting] attribute DOMString enabledBySettingAttribute;
[Conditional=TEST_FEATURE, EnabledBySetting=TestSetting] void enabledBySettingOperation(DOMString testParam);
+ // [SecureContext] attributes and operations; will not be exposed to a non-secure context.
+ // From <https://w3c.github.io/webappsec-secure-contexts/#integration-idl> (Editor's Draft, 17 November 2016)
+ [SecureContext] Promise<double> calculateSecretResult();
+ [SecureContext] boolean getSecretBoolean();
+ [Conditional=TEST_FEATURE, SecureContext, EnabledAtRuntime=TestFeature] boolean testFeatureGetSecretBoolean();
+
// TypedArray attribute
attribute Float32Array typedArrayAttr;
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (218026 => 218027)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.h 2017-06-09 23:13:41 UTC (rev 218026)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h 2017-06-09 23:38:05 UTC (rev 218027)
@@ -221,6 +221,8 @@
JSC::ExecState* execState();
+ virtual bool isSecureContext() const { return true; }
+
protected:
class AddConsoleMessageTask : public Task {
public: