Title: [166367] trunk/Source/_javascript_Core
Revision
166367
Author
commit-qu...@webkit.org
Date
2014-03-27 13:01:34 -0700 (Thu, 27 Mar 2014)

Log Message

Web Inspector: Provide SPI to disallow remote inspection of a JSContext
https://bugs.webkit.org/show_bug.cgi?id=130853

Patch by Joseph Pecoraro <pecor...@apple.com> on 2014-03-27
Reviewed by Timothy Hatcher.

* API/JSContextPrivate.h: Added.
* API/JSContext.mm:
(-[JSContext _remoteInspectionEnabled]):
(-[JSContext _setRemoteInspectionEnabled:]):
ObjC SPI to enable/disable remote inspection.

* API/JSContextRefPrivate.h:
* API/JSContextRef.cpp:
(JSGlobalContextGetRemoteInspectionEnabled):
(JSGlobalContextSetRemoteInspectionEnabled):
C SPI to enable/disable remote inspection.

* _javascript_Core.xcodeproj/project.pbxproj:
Add new private header, and export as a private header.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSContext.mm (166366 => 166367)


--- trunk/Source/_javascript_Core/API/JSContext.mm	2014-03-27 19:19:28 UTC (rev 166366)
+++ trunk/Source/_javascript_Core/API/JSContext.mm	2014-03-27 20:01:34 UTC (rev 166367)
@@ -26,14 +26,16 @@
 #include "config.h"
 
 #import "APICast.h"
+#import "JSCInlines.h"
 #import "JSContextInternal.h"
+#import "JSContextPrivate.h"
+#import "JSContextRefPrivate.h"
 #import "JSGlobalObject.h"
 #import "JSValueInternal.h"
 #import "JSVirtualMachineInternal.h"
 #import "JSWrapperMap.h"
 #import "_javascript_Core.h"
 #import "ObjcRuntimeExtras.h"
-#import "JSCInlines.h"
 #import "StrongInlines.h"
 #import <wtf/HashSet.h>
 
@@ -201,6 +203,16 @@
         JSStringRelease(nameJS);
 }
 
+- (BOOL)_remoteInspectionEnabled
+{
+    return JSGlobalContextGetRemoteInspectionEnabled(m_context);
+}
+
+- (void)_setRemoteInspectionEnabled:(BOOL)enabled
+{
+    JSGlobalContextSetRemoteInspectionEnabled(m_context, enabled);
+}
+
 @end
 
 @implementation JSContext(SubscriptSupport)

Added: trunk/Source/_javascript_Core/API/JSContextPrivate.h (0 => 166367)


--- trunk/Source/_javascript_Core/API/JSContextPrivate.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/API/JSContextPrivate.h	2014-03-27 20:01:34 UTC (rev 166367)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSContextPrivate_h
+#define JSContextPrivate_h
+
+#if JSC_OBJC_API_ENABLED
+
+#import <_javascript_Core/JSContext.h>
+
+@interface JSContext(Private)
+
+/*!
+@property
+@discussion Remote inspection setting of the JSContext. Default value is YES.
+*/
+@property (setter=_setRemoteInspectionEnabled:) BOOL _remoteInspectionEnabled NS_AVAILABLE(10_10, 8_0);
+
+@end
+
+#endif
+
+#endif // JSContextInternal_h

Modified: trunk/Source/_javascript_Core/API/JSContextRef.cpp (166366 => 166367)


--- trunk/Source/_javascript_Core/API/JSContextRef.cpp	2014-03-27 19:19:28 UTC (rev 166366)
+++ trunk/Source/_javascript_Core/API/JSContextRef.cpp	2014-03-27 20:01:34 UTC (rev 166367)
@@ -20,7 +20,7 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -296,4 +296,28 @@
     return OpaqueJSString::create(builder.toString()).leakRef();
 }
 
+bool JSGlobalContextGetRemoteInspectionEnabled(JSGlobalContextRef ctx)
+{
+    if (!ctx) {
+        ASSERT_NOT_REACHED();
+        return false;
+    }
 
+    ExecState* exec = toJS(ctx);
+    JSLockHolder lock(exec);
+
+    return exec->vmEntryGlobalObject()->remoteDebuggingEnabled();
+}
+
+void JSGlobalContextSetRemoteInspectionEnabled(JSGlobalContextRef ctx, bool enabled)
+{
+    if (!ctx) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
+    ExecState* exec = toJS(ctx);
+    JSLockHolder lock(exec);
+
+    exec->vmEntryGlobalObject()->setRemoteDebuggingEnabled(enabled);
+}

Modified: trunk/Source/_javascript_Core/API/JSContextRefPrivate.h (166366 => 166367)


--- trunk/Source/_javascript_Core/API/JSContextRefPrivate.h	2014-03-27 19:19:28 UTC (rev 166366)
+++ trunk/Source/_javascript_Core/API/JSContextRefPrivate.h	2014-03-27 20:01:34 UTC (rev 166367)
@@ -20,7 +20,7 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef JSContextRefPrivate_h
@@ -94,6 +94,23 @@
 */
 JS_EXPORT void JSContextGroupClearExecutionTimeLimit(JSContextGroupRef) CF_AVAILABLE(10_6, 7_0);
 
+/*!
+@function
+@abstract Gets a whether or not remote inspection is enabled on the context.
+@param ctx The JSGlobalContext whose setting you want to get.
+@result The value of the setting, true if remote inspection is enabled, otherwise false.
+@discussion Remote inspection is true by default.
+*/
+JS_EXPORT bool JSGlobalContextGetRemoteInspectionEnabled(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);
+
+/*!
+@function
+@abstract Sets the remote inspection setting for a context.
+@param ctx The JSGlobalContext that you want to change.
+@param enabled The new remote inspection enabled setting for the context.
+*/
+JS_EXPORT void JSGlobalContextSetRemoteInspectionEnabled(JSGlobalContextRef ctx, bool enabled) CF_AVAILABLE(10_10, 8_0);    
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/_javascript_Core/ChangeLog (166366 => 166367)


--- trunk/Source/_javascript_Core/ChangeLog	2014-03-27 19:19:28 UTC (rev 166366)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-03-27 20:01:34 UTC (rev 166367)
@@ -1,3 +1,25 @@
+2014-03-27  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Provide SPI to disallow remote inspection of a JSContext
+        https://bugs.webkit.org/show_bug.cgi?id=130853
+
+        Reviewed by Timothy Hatcher.
+
+        * API/JSContextPrivate.h: Added.
+        * API/JSContext.mm:
+        (-[JSContext _remoteInspectionEnabled]):
+        (-[JSContext _setRemoteInspectionEnabled:]):
+        ObjC SPI to enable/disable remote inspection.
+
+        * API/JSContextRefPrivate.h:
+        * API/JSContextRef.cpp:
+        (JSGlobalContextGetRemoteInspectionEnabled):
+        (JSGlobalContextSetRemoteInspectionEnabled):
+        C SPI to enable/disable remote inspection.
+
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        Add new private header, and export as a private header.
+
 2014-03-27  Mark Hahnenberg  <mhahnenb...@apple.com>
 
         Clean up questionable style in ScriptExecutable::prepareForExecutionImpl

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (166366 => 166367)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2014-03-27 19:19:28 UTC (rev 166366)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2014-03-27 20:01:34 UTC (rev 166367)
@@ -1058,6 +1058,7 @@
 		A5840E29187CA5E600843B10 /* inline-and-minify-stylesheets-and-scripts.py in Headers */ = {isa = PBXBuildFile; fileRef = A5840E28187CA5B800843B10 /* inline-and-minify-stylesheets-and-scripts.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		A5840E2A187CA75900843B10 /* xxd.pl in Headers */ = {isa = PBXBuildFile; fileRef = A513E5C5185F92F0007E95AD /* xxd.pl */; settings = {ATTRIBUTES = (Private, ); }; };
 		A5840E2B187CA75B00843B10 /* jsmin.py in Headers */ = {isa = PBXBuildFile; fileRef = A513E5C4185F92DC007E95AD /* jsmin.py */; settings = {ATTRIBUTES = (Private, ); }; };
+		A58C024218E4A41A00032BC5 /* JSContextPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A58C024118E4A41A00032BC5 /* JSContextPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A58E35911860DECF001F24FE /* InjectedScriptHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A58E35901860DEC7001F24FE /* InjectedScriptHost.cpp */; };
 		A593CF7C1840360300BFCE27 /* InspectorBackendDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A593CF7A1840360300BFCE27 /* InspectorBackendDispatcher.cpp */; };
 		A593CF7D1840360300BFCE27 /* InspectorBackendDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = A593CF7B1840360300BFCE27 /* InspectorBackendDispatcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2608,6 +2609,7 @@
 		A5840E1F187B7B8600843B10 /* InjectedScriptModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScriptModule.h; sourceTree = "<group>"; };
 		A5840E26187C980700843B10 /* cssmin.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = cssmin.py; sourceTree = "<group>"; };
 		A5840E28187CA5B800843B10 /* inline-and-minify-stylesheets-and-scripts.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "inline-and-minify-stylesheets-and-scripts.py"; sourceTree = "<group>"; };
+		A58C024118E4A41A00032BC5 /* JSContextPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSContextPrivate.h; sourceTree = "<group>"; };
 		A58E35901860DEC7001F24FE /* InjectedScriptHost.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScriptHost.cpp; sourceTree = "<group>"; };
 		A593CF7A1840360300BFCE27 /* InspectorBackendDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorBackendDispatcher.cpp; sourceTree = "<group>"; };
 		A593CF7B1840360300BFCE27 /* InspectorBackendDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorBackendDispatcher.h; sourceTree = "<group>"; };
@@ -3659,6 +3661,7 @@
 				1440FCE10A51E46B0005F061 /* JSClassRef.h */,
 				86E3C607167BAB87006D760A /* JSContext.h */,
 				86E3C608167BAB87006D760A /* JSContext.mm */,
+				A58C024118E4A41A00032BC5 /* JSContextPrivate.h */,
 				86E3C609167BAB87006D760A /* JSContextInternal.h */,
 				14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */,
 				14BD5A2A0A3E91F600BAF59C /* JSContextRef.h */,
@@ -5644,6 +5647,7 @@
 				A503FA21188EFF6800110F14 /* ScriptBreakpoint.h in Headers */,
 				A5FD006E189B00AA00633231 /* ScriptCallFrame.h in Headers */,
 				A5FD0070189B00AA00633231 /* ScriptCallStack.h in Headers */,
+				A58C024218E4A41A00032BC5 /* JSContextPrivate.h in Headers */,
 				A5FD007E189B0B4C00633231 /* ScriptCallStackFactory.h in Headers */,
 				A503FA22188EFF6800110F14 /* ScriptDebugListener.h in Headers */,
 				A503FA26188EFFFD00110F14 /* ScriptDebugServer.h in Headers */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to