Changeset 181064 in webkit
- Timestamp:
- Mar 4, 2015 8:25:49 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
r172176 r181064 63 63 } 64 64 65 extern const GlobalObjectMethodTable javaScriptCoreAPIGlobalObjectMethodTable; 66 65 67 // Global object constructor. 66 68 // FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one. 67 69 template <class Parent> 68 70 JSCallbackObject<Parent>::JSCallbackObject(VM& vm, JSClassRef jsClass, Structure* structure) 69 : Parent(vm, structure )71 : Parent(vm, structure, &javaScriptCoreAPIGlobalObjectMethodTable) 70 72 , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(0, jsClass))) 71 73 { -
trunk/Source/JavaScriptCore/API/JSContextRef.cpp
r179609 r181064 36 36 #include "JSObject.h" 37 37 #include "JSCInlines.h" 38 #include "RuntimeFlags.h" 38 39 #include "SourceProvider.h" 39 40 #include "StackVisitor.h" … … 57 58 58 59 using namespace JSC; 60 61 static RuntimeFlags javaScriptRuntimeFlags(const JSGlobalObject* globalObject) 62 { 63 RuntimeFlags runtimeFlags = JSGlobalObject::javaScriptRuntimeFlags(globalObject); 64 runtimeFlags.setPromiseDisabled(true); 65 return runtimeFlags; 66 } 67 68 const GlobalObjectMethodTable JSC::javaScriptCoreAPIGlobalObjectMethodTable = { &JSGlobalObject::allowsAccessFrom, &JSGlobalObject::supportsProfiling, &JSGlobalObject::supportsRichSourceInfo, &JSGlobalObject::shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &JSGlobalObject::shouldInterruptScriptBeforeTimeout }; 59 69 60 70 // From the API's perspective, a context group remains alive iff … … 141 151 142 152 if (!globalObjectClass) { 143 JSGlobalObject* globalObject = JSGlobalObject::create(*vm, JSGlobalObject::createStructure(*vm, jsNull()) );153 JSGlobalObject* globalObject = JSGlobalObject::create(*vm, JSGlobalObject::createStructure(*vm, jsNull()), &javaScriptCoreAPIGlobalObjectMethodTable); 144 154 #if ENABLE(REMOTE_INSPECTOR) 145 155 globalObject->setRemoteDebuggingEnabled(true); -
trunk/Source/JavaScriptCore/API/tests/testapi.c
r179993 r181064 1892 1892 } 1893 1893 1894 // Check Promise is not exposed. 1895 { 1896 JSObjectRef globalObject = JSContextGetGlobalObject(context); 1897 { 1898 JSStringRef promiseProperty = JSStringCreateWithUTF8CString("Promise"); 1899 ASSERT(!JSObjectHasProperty(context, globalObject, promiseProperty)); 1900 JSStringRelease(promiseProperty); 1901 } 1902 { 1903 JSStringRef script = JSStringCreateWithUTF8CString("typeof Promise"); 1904 JSStringRef undefined = JSStringCreateWithUTF8CString("undefined"); 1905 JSValueRef value = JSEvaluateScript(context, script, NULL, NULL, 1, NULL); 1906 ASSERT(JSValueIsString(context, value)); 1907 JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL); 1908 ASSERT(JSStringIsEqual(valueAsString, undefined)); 1909 JSStringRelease(valueAsString); 1910 JSStringRelease(undefined); 1911 JSStringRelease(script); 1912 } 1913 printf("PASS: Promise is not exposed under JSContext API.\n"); 1914 } 1915 1894 1916 #if OS(DARWIN) 1895 1917 JSStringRef currentCPUTimeStr = JSStringCreateWithUTF8CString("currentCPUTime"); -
trunk/Source/JavaScriptCore/API/tests/testapi.mm
r180992 r181064 515 515 @autoreleasepool { 516 516 JSContext *context = [[JSContext alloc] init]; 517 checkResult(@"Promise is not exposed", [context[@"Promise"] isUndefined]); 518 JSValue *result = [context evaluateScript:@"typeof Promise"]; 519 checkResult(@"typeof Promise is 'undefined'", [result isString] && [result isEqualToObject:@"undefined"]); 520 } 521 522 @autoreleasepool { 523 JSContext *context = [[JSContext alloc] init]; 517 524 JSValue *result = [context evaluateScript:@"({ x:42 })"]; 518 525 checkResult(@"({ x:42 })", [result isObject] && [result[@"x"] isEqualToObject:@42]); -
trunk/Source/JavaScriptCore/ChangeLog
r181061 r181064 1 2015-03-04 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Hide Promise with runtime flags under Cocoa JSContext API 4 https://bugs.webkit.org/show_bug.cgi?id=141965 5 6 Reviewed by Filip Pizlo. 7 8 Since there's no run loop in JavaScriptCore APIs, Promises don't work currently. 9 So until they work, we hide Promise from a global object. 10 Introduce new JSC runtime flag, PromiseDisabled. When `isPromiseDisabled` is true, 11 Promise constructor is not attached to JSGlobalObject. 12 13 To make 0 as default runtime flags, we choose PromiseDisabled flag 14 instead of PromiseEnabled flag. So by default, Promise is enabled. 15 16 * API/JSCallbackObjectFunctions.h: 17 (JSC::JSCallbackObject<Parent>::JSCallbackObject): 18 * API/JSContextRef.cpp: 19 (javaScriptRuntimeFlags): 20 (JSGlobalContextCreateInGroup): 21 * API/tests/testapi.c: 22 (main): 23 * API/tests/testapi.mm: 24 (testObjectiveCAPI): 25 * runtime/JSGlobalObject.cpp: 26 (JSC::JSGlobalObject::init): 27 * runtime/JSGlobalObject.h: 28 (JSC::JSGlobalObject::create): 29 * runtime/RuntimeFlags.h: 30 (JSC::RuntimeFlags::createAllEnabled): 31 1 32 2015-03-04 Joseph Pecoraro <pecoraro@apple.com> 2 33 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r181010 r181064 367 367 putDirectWithoutTransition(vm, vm.propertyNames->URIError, m_URIErrorConstructor.get(), DontEnum); 368 368 #if ENABLE(PROMISES) 369 putDirectWithoutTransition(vm, vm.propertyNames->Promise, m_promiseConstructor.get(), DontEnum); 369 if (!m_runtimeFlags.isPromiseDisabled()) 370 putDirectWithoutTransition(vm, vm.propertyNames->Promise, m_promiseConstructor.get(), DontEnum); 370 371 #endif 371 372 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r180570 r181064 294 294 typedef JSSegmentedVariableObject Base; 295 295 296 static JSGlobalObject* create(VM& vm, Structure* structure )297 { 298 JSGlobalObject* globalObject = new (NotNull, allocateCell<JSGlobalObject>(vm.heap)) JSGlobalObject(vm, structure );296 static JSGlobalObject* create(VM& vm, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable = nullptr) 297 { 298 JSGlobalObject* globalObject = new (NotNull, allocateCell<JSGlobalObject>(vm.heap)) JSGlobalObject(vm, structure, globalObjectMethodTable); 299 299 globalObject->finishCreation(vm); 300 300 vm.heap.addFinalizer(globalObject, destroy); -
trunk/Source/JavaScriptCore/runtime/RuntimeFlags.h
r180570 r181064 31 31 namespace JSC { 32 32 33 // macro(name, isEnabledFlag) 33 34 #define JSC_RUNTIME_FLAG(macro) \ 34 macro(SymbolEnabled) 35 macro(SymbolEnabled, true)\ 36 macro(PromiseDisabled, false) 35 37 36 38 … … 38 40 private: 39 41 enum RuntimeFlagShiftValue : unsigned { 40 #define JSC_DECLARE_RUNTIME_FLAG_SHIFT_VALUE(name ) shiftValueFor##name,42 #define JSC_DECLARE_RUNTIME_FLAG_SHIFT_VALUE(name, isEnabledFlag) shiftValueFor##name, 41 43 JSC_RUNTIME_FLAG(JSC_DECLARE_RUNTIME_FLAG_SHIFT_VALUE) 42 44 #undef JSC_DECLARE_RUNTIME_FLAG_SHIFT_VALUE … … 45 47 public: 46 48 enum RuntimeFlag : unsigned { 47 #define JSC_DECLARE_RUNTIME_FLAG(name ) name = 1u << (shiftValueFor##name),49 #define JSC_DECLARE_RUNTIME_FLAG(name, isEnabledFlag) name = 1u << (shiftValueFor##name), 48 50 JSC_RUNTIME_FLAG(JSC_DECLARE_RUNTIME_FLAG) 49 51 #undef JSC_DECLARE_RUNTIME_FLAG 50 52 }; 51 53 52 #define JSC_DECLARE_RUNTIME_FLAG_ACCESSOR(name ) \54 #define JSC_DECLARE_RUNTIME_FLAG_ACCESSOR(name, isEnabledFlag) \ 53 55 void set##name(bool value)\ 54 56 {\ … … 84 86 static RuntimeFlags createAllEnabled() 85 87 { 86 return {87 #define JSC_USE_RUNTIME_FLAG(name ) name,88 return RuntimeFlags( 89 #define JSC_USE_RUNTIME_FLAG(name, isEnabledFlag) ((isEnabledFlag) ? name : 0u) | 88 90 JSC_RUNTIME_FLAG(JSC_USE_RUNTIME_FLAG) 89 91 #undef JSC_USE_RUNTIME_FLAG 90 }; 92 0u 93 ); 91 94 } 92 95 -
trunk/Source/WebKit/mac/ChangeLog
r180985 r181064 1 2015-03-04 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Hide Promise with runtime flags under Cocoa JSContext API 4 https://bugs.webkit.org/show_bug.cgi?id=141965 5 6 Reviewed by Filip Pizlo. 7 8 Add new JSC runtime flag, PromiseDisabled. 9 10 * WebView/WebPreferencesPrivate.h: 11 1 12 2015-03-03 Andy Estes <aestes@apple.com> 2 13 -
trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h
r180570 r181064 55 55 typedef enum { 56 56 WebKitJavaScriptRuntimeFlagsSymbolEnabled = 1u << 0, 57 WebKitJavaScriptRuntimeFlagsPromiseDisabled = 1u << 1, 57 58 WebKitJavaScriptRuntimeFlagsAllEnabled = WebKitJavaScriptRuntimeFlagsSymbolEnabled 58 59 } WebKitJavaScriptRuntimeFlags; -
trunk/Source/WebKit/win/ChangeLog
r180963 r181064 1 2015-03-04 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Hide Promise with runtime flags under Cocoa JSContext API 4 https://bugs.webkit.org/show_bug.cgi?id=141965 5 6 Reviewed by Filip Pizlo. 7 8 Add new JSC runtime flag, PromiseDisabled. 9 10 * Interfaces/IWebPreferences.idl: 11 * Interfaces/IWebPreferencesPrivate.idl: 12 1 13 2015-03-03 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Source/WebKit/win/Interfaces/IWebPreferences.idl
r180570 r181064 60 60 } WebCacheModel; 61 61 62 typedef enum WebKitJavaScriptRuntimeFlags {63 WebKitJavaScriptRuntimeFlagsSymbolEnabled = 1, // 1u << 064 WebKitJavaScriptRuntimeFlagsAllEnabled = WebKitJavaScriptRuntimeFlagsSymbolEnabled65 } WebKitJavaScriptRuntimeFlags;66 67 62 [ 68 63 object, -
trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl
r180765 r181064 31 31 import "ocidl.idl"; 32 32 #endif 33 34 typedef enum WebKitJavaScriptRuntimeFlags { 35 WebKitJavaScriptRuntimeFlagsSymbolEnabled = 1, // 1u << 0 36 WebKitJavaScriptRuntimeFlagsPromiseDisabled = 2, // 1u << 1 37 WebKitJavaScriptRuntimeFlagsAllEnabled = WebKitJavaScriptRuntimeFlagsSymbolEnabled 38 } WebKitJavaScriptRuntimeFlags; 33 39 34 40 [ -
trunk/Source/WebKit2/ChangeLog
r181039 r181064 1 2015-03-04 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Hide Promise with runtime flags under Cocoa JSContext API 4 https://bugs.webkit.org/show_bug.cgi?id=141965 5 6 Reviewed by Filip Pizlo. 7 8 Add new JSC runtime flag, PromiseDisabled. 9 10 * UIProcess/API/C/WKPreferencesRefPrivate.h: 11 * UIProcess/API/Cocoa/WKPreferencesPrivate.h: 12 1 13 2015-03-04 Beth Dakin <bdakin@apple.com> 2 14 -
trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
r180570 r181064 52 52 enum WKJavaScriptRuntimeFlags { 53 53 kWKJavaScriptRuntimeFlagsSymbolEnabled = 1 << 0, 54 kWKJavaScriptRuntimeFlagsPromiseDisabled = 1 << 1, 54 55 kWKJavaScriptRuntimeFlagsAllEnabled = kWKJavaScriptRuntimeFlagsSymbolEnabled 55 56 }; -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h
r180570 r181064 45 45 typedef NS_OPTIONS(NSUInteger, _WKJavaScriptRuntimeFlags) { 46 46 _WKJavaScriptRuntimeFlagsSymbolEnabled = 1 << 0, 47 _WKJavaScriptRuntimeFlagsPromiseDisabled = 1 << 1, 47 48 _WKJavaScriptRuntimeFlagsAllEnabled = _WKJavaScriptRuntimeFlagsSymbolEnabled 48 49 } WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
Note: See TracChangeset
for help on using the changeset viewer.