Bug 150810

Summary: [Win] Minibrowser unable to use WebInspector (CRASH)
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: Web InspectorAssignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, bburg, bfulgham, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch timothy: review+

Description Brent Fulgham 2015-11-02 11:26:52 PST
I'm encountering the following crash when attempting to use the WebInspector in MiniBrowser:

'MiniBrowser.exe' (Win32): Loaded 'C:\Windows\System32\rasadhlp.dll'. Symbols loaded.
Failed to parse/execute InjectedScriptSource.js!
"//# sourceURL=__WebInspectorInjectedScript__"  ?(function(InjectedScriptHost,inspectedGlobalObject,injectedScriptId){var Object={}.constructor;function toString(obj)?{return String(obj);}?function toStringDescription(obj)?{if(obj===0&&1/obj<0)?return"-0";return toString(obj);}?function isUInt32(obj)?{if(typeof obj==="number")?return obj>>>0===obj&&(obj>0||1/obj>0);return""+(obj>>>0)===obj;}?function isSymbol(obj)?{return typeof obj==="symbol";}?var InjectedScript=function()?{this._lastBoundObjectId=1;this._idToWrappedObject={};this._idToObjectGroupName={};this._objectGroups={};this._modules={};this._nextSavedResultIndex=1;this._savedResults=[];}?InjectedScript.primitiveTypes={undefined:true,boolean:true,number:true,string:true,}?InjectedScript.CollectionMode={OwnProperties:1<<0,NativeGetterProperties:1<<1,AllProperties:1<<2,}?InjectedScript.prototype={isPrimitiveValue:function(object)?{return InjectedScript.primitiveTypes[typeof object]&&!this._isHTMLAllCollection(object);},wrapObject:function(object,groupN1   00007FFC2880B2EF
Comment 1 Radar WebKit Bug Importer 2015-11-02 11:27:43 PST
<rdar://problem/23358514>
Comment 2 Joseph Pecoraro 2015-11-02 13:10:44 PST
This is emitted by InjectedScriptManager::injectedScriptFor normally when InjectedScriptSource.js has a parse error.

Here is one possible issue:

JavaScriptCore's DerivedSource.make / CMakeLists.txt attempts to minify the InjectedScriptSource and in the process injects the sourceURL comment that would have been stripped:

    COMMAND echo "//# sourceURL=__WebInspectorInjectedScript__" > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js

Perhaps that is not doing what we expect on Windows? Did Windows just move to CMake?
Comment 3 Brent Fulgham 2015-11-02 13:32:34 PST
(In reply to comment #2)
> This is emitted by InjectedScriptManager::injectedScriptFor normally when
> InjectedScriptSource.js has a parse error.
> 
> Here is one possible issue:
> 
> JavaScriptCore's DerivedSource.make / CMakeLists.txt attempts to minify the
> InjectedScriptSource and in the process injects the sourceURL comment that
> would have been stripped:
> 
>     COMMAND echo "//# sourceURL=__WebInspectorInjectedScript__" >
> ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js
> 
> Perhaps that is not doing what we expect on Windows? Did Windows just move
> to CMake?

Yes it did! That may very well be the problem.
Comment 4 Brent Fulgham 2015-11-02 13:54:33 PST
It looks like this problem was introduced right around the time we switched Windows over to CMake.
Comment 5 Brent Fulgham 2015-11-02 15:20:52 PST
It looks like this command:

COMMAND echo "//# sourceURL=__WebInspectorInjectedScript__"

... is inserting quotes into the JS file, which is causing a parse error.
Comment 6 Brent Fulgham 2015-11-02 15:25:21 PST
Created attachment 264637 [details]
Patch
Comment 7 Joseph Pecoraro 2015-11-02 15:38:36 PST
Comment on attachment 264637 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=264637&action=review

> Source/JavaScriptCore/CMakeLists.txt:1277
> -    COMMAND echo "//# sourceURL=__WebInspectorInjectedScript__" > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js
> +    COMMAND ${CMAKE_COMMAND} -E echo "//# sourceURL=__WebInspectorInjectedScript__" > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js

We should therefore do the same to WebCore:

    COMMAND echo "//# sourceURL=__WebInspectorCommandLineAPIModuleSource__" > ${DERIVED_SOURCES_WEBCORE_DIR}/CommandLineAPIModuleSource.min.js
Comment 8 Brent Fulgham 2015-11-02 15:52:41 PST
Committed r191917: <http://trac.webkit.org/changeset/191917>