Unreviewed, rolling out r127427.

http://trac.webkit.org/changeset/127427
https://bugs.webkit.org/show_bug.cgi?id=95695

Breaks some inspector/debugger tests on JSC (Requested by
vsevik on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-09-03

Source/WebCore:

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/CompilerScriptMapping.js:
* inspector/front-end/JavaScriptSource.js:
(WebInspector.JavaScriptSource):
* inspector/front-end/NetworkUISourceCodeProvider.js: Removed.
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode):
(WebInspector.RawSourceCode.prototype.addScript):
(WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.prototype._createUISourceCode):
(WebInspector.RawSourceCode.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.prototype.uiSourceCode):
(WebInspector.RawSourceCode.prototype._finishedLoading):
* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping):
(WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
(WebInspector.ResourceScriptMapping.prototype.addScript):
(WebInspector.ResourceScriptMapping.prototype._shouldBindScriptToContentProvider):
(WebInspector.ResourceScriptMapping.prototype._handleUISourceCodeChanged):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeAdded):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeReplaced):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeRemoved):
(WebInspector.ResourceScriptMapping.prototype._bindScriptToRawSourceCode):
(WebInspector.ResourceScriptMapping.prototype._reset):
* inspector/front-end/ScriptSnippetModel.js:
(WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
(WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
(WebInspector.SnippetJavaScriptSource):
* inspector/front-end/StylesUISourceCodeProvider.js: Added.
(WebInspector.StylesUISourceCodeProvider):
(WebInspector.StylesUISourceCodeProvider.prototype._populate):
(WebInspector.StylesUISourceCodeProvider.prototype._resourceAdded):
(WebInspector.StylesUISourceCodeProvider.prototype._reset):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.uiLocationToRawLocation):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
* inspector/front-end/inspector.js:

LayoutTests:

* http/tests/inspector/network/network-request-revision-content.html:
* http/tests/inspector/workspace-test.js: Removed.
* inspector/debugger/breakpoint-manager.html:
* inspector/debugger/dynamic-script-tag-expected.txt:
* inspector/debugger/dynamic-script-tag.html:
* inspector/debugger/network-uisourcecode-provider-expected.txt: Removed.
* inspector/debugger/network-uisourcecode-provider.html: Removed.
* inspector/debugger/raw-source-code-expected.txt: Added.
* inspector/debugger/raw-source-code.html: Added.
* inspector/debugger/resource-script-mapping-expected.txt: Removed.
* inspector/debugger/resource-script-mapping.html: Removed.
* inspector/debugger/scripts-panel.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a1d1b75f
2012-09-03 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r127427.
http://trac.webkit.org/changeset/127427
https://bugs.webkit.org/show_bug.cgi?id=95695
Breaks some inspector/debugger tests on JSC (Requested by
vsevik on #webkit).
* http/tests/inspector/network/network-request-revision-content.html:
* http/tests/inspector/workspace-test.js: Removed.
* inspector/debugger/breakpoint-manager.html:
* inspector/debugger/dynamic-script-tag-expected.txt:
* inspector/debugger/dynamic-script-tag.html:
* inspector/debugger/network-uisourcecode-provider-expected.txt: Removed.
* inspector/debugger/network-uisourcecode-provider.html: Removed.
* inspector/debugger/raw-source-code-expected.txt: Added.
* inspector/debugger/raw-source-code.html: Added.
* inspector/debugger/resource-script-mapping-expected.txt: Removed.
* inspector/debugger/resource-script-mapping.html: Removed.
* inspector/debugger/scripts-panel.html:
2012-09-03 Vsevolod Vlasov <vsevik@chromium.org>
Web Inspector: Create JavaScriptSources based on network resources.
......@@ -14,7 +14,7 @@ function loadStylesheet()
function test()
{
InspectorTest.addConsoleSniffer(step2, true);
InspectorTest.addSniffer(WebInspector.NetworkUISourceCodeProvider.prototype, "_resourceAdded", true);
InspectorTest.addSniffer(WebInspector.StylesUISourceCodeProvider.prototype, "_resourceAdded", true);
InspectorTest.evaluateInPage("loadStylesheet()");
var resource;
......
var initialize_WorkspaceTest = function() {
InspectorTest.testWorkspace;
InspectorTest.createWorkspace = function()
{
InspectorTest.testWorkspace = new WebInspector.Workspace();
InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, InspectorTest._defaultUISourceCodeProviderEventHandler);
InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, InspectorTest._defaultUISourceCodeProviderEventHandler);
}
InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent = function(callback)
{
InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, InspectorTest._defaultUISourceCodeProviderEventHandler);
InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, uiSourceCodeReplaced);
function uiSourceCodeReplaced(event)
{
InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, uiSourceCodeReplaced);
InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, InspectorTest._defaultUISourceCodeProviderEventHandler);
callback(event.data.uiSourceCode, event.data.oldUISourceCode);
}
}
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback)
{
InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
function uiSourceCodeAdded(event)
{
InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
callback(event.data);
}
}
InspectorTest.addMockUISourceCodeToWorkspace = function(url, type, content)
{
var isDocument = type === WebInspector.resourceTypes.Document;
var mockContentProvider = new WebInspector.StaticContentProvider(type, content);
var uiSourceCode = new WebInspector.JavaScriptSource(url, null, mockContentProvider, !isDocument);
InspectorTest.testWorkspace.project().addUISourceCode(uiSourceCode);
}
InspectorTest._defaultUISourceCodeProviderEventHandler = function(event)
{
throw new Error("Unexpected UISourceCodeProvider event: " + event.type + ".");
}
InspectorTest.dumpUISourceCode = function(uiSourceCode, callback)
{
InspectorTest.addResult("UISourceCode: " + uiSourceCode.url);
if (uiSourceCode instanceof WebInspector.JavaScriptSource) {
InspectorTest.addResult("UISourceCode is editable: " + uiSourceCode._isEditable);
InspectorTest.addResult("UISourceCode is content script: " + uiSourceCode.isContentScript);
}
uiSourceCode.requestContent(didRequestContent);
function didRequestContent(content, contentEncoded, mimeType)
{
InspectorTest.addResult("Mime type: " + mimeType);
InspectorTest.addResult("UISourceCode content: " + content);
callback();
}
}
};
......@@ -111,8 +111,7 @@ function test()
WorkspaceMock.prototype = {
_addUISourceCode: function(url)
{
var uiSourceCode = new WebInspector.JavaScriptSource(url, null, null, false);
uiSourceCode.setSourceMapping(defaultMapping);
var uiSourceCode = new WebInspector.JavaScriptSource(url, null, null, defaultMapping, false);
uiSourceCodes[url] = uiSourceCode;
this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
return uiSourceCode;
......
Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs. Bug 87119
CONSOLE MESSAGE: line 1: 123
Tests that dynamically added script tag gets its own JavaScriptSource and is not bound to the resource. Bug 87119
Debugger was enabled.
Dumping scripts:
script1: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
Is anonymous:false
Is inline script:true
script2: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
Is anonymous:false
Is inline script:false
script3: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
Is anonymous:false
Is inline script:false
Dumping uiSourceCodes:
UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (1)
UISourceCode is editable: true
UISourceCode is content script: false
Mime type: text/javascript
UISourceCode content: function bar() { }
UI resource: null
UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (2)
UISourceCode is editable: true
UISourceCode is content script: false
Mime type: text/javascript
UISourceCode content: function foo() { }
dynamic-script-tag.html
UI name: dynamic-script-tag.html
UI resource: null
UI content: console.log(123)
Debugger was disabled.
......@@ -2,79 +2,51 @@
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script src="../../http/tests/inspector/workspace-test.js"></script>
<script>
document.write("<scrip" + "t>function foo() { }</sc" + "ript>");
var scriptElement = document.createElement("script");
scriptElement.textContent = "function bar() { }";
document.head.appendChild(scriptElement);
var test = function()
function createScriptTag()
{
var script = document.createElement("script");
script.innerHTML = "console.log(123)";
document.head.appendChild(script);
}
function test()
{
InspectorTest.startDebuggerTest(step1);
function step1()
{
var model = WebInspector.debuggerModel;
var scripts = Object.values(WebInspector.debuggerModel.scripts);
function filterOutStandaloneScripts(script)
{
return script.sourceURL.indexOf("dynamic-script-tag.html") !== -1;
}
scripts = scripts.filter(filterOutStandaloneScripts);
InspectorTest.evaluateInPage("createScriptTag()");
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, step2);
}
function compareScriptFunction(script1, script2)
function step2(event)
{
var script = event.data;
script.requestContent(callback);
function callback(content)
{
return script1.sourceURL.localeCompare(script2.sourceURL);
}
scripts.sort(compareScriptFunction);
InspectorTest.assertEquals(3, scripts.length, "Wrong scripts count.");
var uiSourceCodes = [];
InspectorTest.addResult("Dumping scripts:");
for (var i = 0; i < scripts.length; ++i) {
var script = scripts[i];
InspectorTest.addResult("script" + (i+1) + ": " + script.sourceURL);
if (content !== "console.log(123)")
return;
InspectorTest.addResult("Is anonymous:" + script.isAnonymousScript());
InspectorTest.addResult("Is inline script:" + script.isInlineScript());
if (!script.isInlineScript())
uiSourceCodes.push(script.rawLocationToUILocation(0, 0).uiSourceCode);
}
function compareUISourceCodeFunction(uiSourceCode1, uiSourceCode2)
{
return uiSourceCode1.url.localeCompare(uiSourceCode2.url);
InspectorTest.addResult(new WebInspector.ParsedURL(script.sourceURL).displayName);
// Invoke post source map install.
setTimeout(step3.bind(this, script), 0);
}
uiSourceCodes.sort(compareUISourceCodeFunction);
var seenUISourceCodes = new Map();
InspectorTest.assertEquals(2, uiSourceCodes.length, "Wrong uiSourceCodes count.");
InspectorTest.addResult("Dumping uiSourceCodes:");
var index = 0;
dumpNextUISourceCode();
function dumpNextUISourceCode()
{
if (index >= uiSourceCodes.length) {
uiSourceCodesDumped();
return;
}
var uiSourceCode = uiSourceCodes[index];
InspectorTest.dumpUISourceCode(uiSourceCode, uiSourceCodeDumped);
}
function uiSourceCodeDumped()
{
InspectorTest.addResult("UI resource: " + uiSourceCode.resource());
InspectorTest.assertTrue(!seenUISourceCodes.get(uiSourceCode), "UISourceCode matches two scripts: " + uiSourceCode.url);
seenUISourceCodes.put(uiSourceCode, uiSourceCode);
++index;
dumpNextUISourceCode();
}
}
function uiSourceCodesDumped()
function step3(script)
{
var uiLocation = script.rawLocationToUILocation(0, 0);
InspectorTest.addResult("UI name: " + uiLocation.uiSourceCode.parsedURL.displayName);
InspectorTest.addResult("UI resource: " + uiLocation.uiSourceCode.resource());
uiLocation.uiSourceCode.requestContent(callback);
function callback(content)
{
InspectorTest.addResult("UI content: " + content);
InspectorTest.completeDebuggerTest();
}
}
......@@ -82,7 +54,10 @@ var test = function()
</script>
</head>
<body onload="runTest()">
<p>Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs.
<p>
Tests that dynamically added script tag gets its own JavaScriptSource and is not bound to the resource.
<a href="https://bugs.webkit.org/show_bug.cgi?id=87119">Bug 87119</a>
</p>
</body>
</html>
Tests NetworkUISourceCodeProvider class.
Running: testDocumentResourceWithPendingRequest
Creating request.
Finishing request.
UISourceCode: http://fake.url/2
UISourceCode is editable: false
UISourceCode is content script: false
Mime type: text/html
UISourceCode content: <document request content>
Running: testDocumentResource
Creating resource.
UISourceCode: http://fake.url/3
UISourceCode is editable: false
UISourceCode is content script: false
Mime type: text/html
UISourceCode content: <document resource content>
Running: testScriptResourceWithPendingRequest
Creating request.
Finishing request.
UISourceCode: http://fake.url/4
UISourceCode is editable: true
UISourceCode is content script: false
Mime type: text/javascript
UISourceCode content: <script request content>
Running: testScriptResource
Creating resource.
UISourceCode: http://fake.url/5
UISourceCode is editable: true
UISourceCode is content script: false
Mime type: text/javascript
UISourceCode content: <script resource content>
Running: testStylesheetResourceWithPendingRequest
Creating request.
UISourceCode: http://fake.url/6
Finishing request.
Mime type: text/css
UISourceCode content: <stylesheet request content>
Running: testStylesheetResource
Creating resource.
UISourceCode: http://fake.url/7
Mime type: text/css
UISourceCode content: <stylesheet resource content>
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script src="../../http/tests/inspector/workspace-test.js"></script>
<script>
function test()
{
var mockContentsMap = {};
var lastResouceId = 1;
NetworkAgent.getResponseBody = function(requestId, callback)
{
callback(undefined, mockContentsMap[requestId], false);
}
PageAgent.getResourceContent = function(frameId, url, callback)
{
callback(undefined, mockContentsMap[url], false);
}
function createResourceMock(type, withPendingRequest, content)
{
var documentURL = "http://fake.url";
var resourceId = ++lastResouceId + "";
var url = documentURL + "/" + resourceId;
var frameId = "frame-id";
var loaderId = "loader-id";
var mimeType;
switch (type) {
case WebInspector.resourceTypes.Document:
mimeType = "text/html";
break;
case WebInspector.resourceTypes.Script:
mimeType = "text/javascript";
break;
case WebInspector.resourceTypes.Stylesheet:
mimeType = "text/css";
break;
}
if (withPendingRequest) {
var request = new WebInspector.NetworkRequest(resourceId, url, "http://fake.url", frameId, loaderId);
request.type = type;
request.mimeType = mimeType;
mockContentsMap[resourceId] = content;
}
var resource = new WebInspector.Resource(request, url, documentURL, frameId, loaderId, type, mimeType);
mockContentsMap[url] = content;
WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
return resource;
}
function finishResource(resource)
{
resource.request.finished = true;
resource.request.dispatchEventToListeners(WebInspector.NetworkRequest.Events.FinishedLoading, resource.request);
}
function createNetworkUISourceCodeProvider()
{
InspectorTest.createWorkspace();
WebInspector.resourceTreeModel = new WebInspector.Object();
var networkUISourceCodeProvider = new WebInspector.NetworkUISourceCodeProvider(InspectorTest.testWorkspace);
return networkUISourceCodeProvider;
}
InspectorTest.runTestSuite([
function testDocumentResourceWithPendingRequest(next)
{
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
InspectorTest.addResult("Creating request.");
var resource = createResourceMock(WebInspector.resourceTypes.Document, true, "<document request content>");
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
InspectorTest.addResult("Finishing request.");
finishResource(resource);
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.dumpUISourceCode(uiSourceCode, next);
}
},
function testDocumentResource(next)
{
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
InspectorTest.addResult("Creating resource.");
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
var resource = createResourceMock(WebInspector.resourceTypes.Document, false, "<document resource content>");
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.dumpUISourceCode(uiSourceCode, next);
}
},
function testScriptResourceWithPendingRequest(next)
{
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
InspectorTest.addResult("Creating request.");
var resource = createResourceMock(WebInspector.resourceTypes.Script, true, "<script request content>");
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
InspectorTest.addResult("Finishing request.");
finishResource(resource);
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.dumpUISourceCode(uiSourceCode, next);
}
},
function testScriptResource(next)
{
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
InspectorTest.addResult("Creating resource.");
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
var resource = createResourceMock(WebInspector.resourceTypes.Script, false, "<script resource content>");
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.dumpUISourceCode(uiSourceCode, next);
}
},
function testStylesheetResourceWithPendingRequest(next)
{
var endTestCallsLeft = 2;
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
InspectorTest.addResult("Creating request.");
var resource = createResourceMock(WebInspector.resourceTypes.Stylesheet, true, "<stylesheet request content>");
InspectorTest.addResult("Finishing request.");
finishResource(resource);
endTest();
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.dumpUISourceCode(uiSourceCode, endTest);
}
function endTest()
{
if (--endTestCallsLeft)
return;
next();
}
},
function testStylesheetResource(next)
{
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
InspectorTest.addResult("Creating resource.");
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
var resource = createResourceMock(WebInspector.resourceTypes.Stylesheet, false, "<stylesheet resource content>");
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.dumpUISourceCode(uiSourceCode, next);
}
},
]);
};
</script>
</head>
<body onload="runTest()">
<p>Tests NetworkUISourceCodeProvider class.</p>
</body>
</html>
Tests RawSourceCode class.
Running: testScriptWithoutResource
UISourceCode: foo.js
UISourceCode is content script: true
Mime type: text/javascript
Script source: <script source>
Running: testHTMLWithPendingResource
Adding first script for pending request.
UISourceCode: index.html
UISourceCode is content script: false
Mime type: text/html
Script source: <script><script source 1></script>
Adding second script for pending request.
UISourceCode: index.html
UISourceCode is content script: false
Mime type: text/html
Script source: <script><script source 1></script> <script><script source 2></script>
Finishing request.
UISourceCode: index.html
UISourceCode is content script: false
Mime type: text/html
Script source: <resource content>
Running: testHTMLWithFinishedResource
UISourceCode: index.html
UISourceCode is content script: false
Mime type: text/html
Script source: <resource content>
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script>
function test()
{
var mockContentsMap = {};
var lastRequestId = 1;
NetworkAgent.getResponseBody = function(requestId, callback)
{
callback(undefined, mockContentsMap[requestId], false);
}
PageAgent.getResourceContent = function(frameId, url, callback)
{
callback(undefined, mockContentsMap[url], false);
}
function createRequestMock(type, finished, content)
{
var requestId = ++lastRequestId + "";
var url = "http://fake.url/" + requestId;
WebInspector.resourceTreeModel._addFrame(new WebInspector.ResourceTreeFrame(WebInspector.resourceTreeModel, null, {id: "frame-id"}));
var request = new WebInspector.NetworkRequest(requestId, url, "http://fake.url", "frame-id", "loader-id");
request.type = type === "document" ? WebInspector.resourceTypes.Document : WebInspector.resourceTypes.Script;
request.mimeType = type === "document" ? "text/html" : "text/javascript";
WebInspector.networkManager._dispatcher._startNetworkRequest(request);
if (finished)
finishRequest(request);
mockContentsMap[requestId] = content;
mockContentsMap[url] = content;
return request;
}
function finishRequest(request) { WebInspector.networkManager._dispatcher._updateNetworkRequest(request); WebInspector.networkManager._dispatcher._finishNetworkRequest(request); }
function createPendingRequestMock(type, content) { return createRequestMock(type, false, content); }
function createFinishedRequestMock(type, content) { return createRequestMock(type, true, content); }
function createScriptFormatterMock()
{
var mapping = {
originalToFormatted: function(lineNumber, columnNumber) { return [lineNumber * 2, columnNumber * 2]; },
formattedToOriginal: function(lineNumber, columnNumber) { return [Math.floor(lineNumber / 2), Math.floor(columnNumber / 2)]; }
};
var formatter = {
formatContent: function(mimeType, content, callback) { formatter._callback = callback.bind(null, "<formatted> " + content, mapping); },
finish: function() { formatter._callback(); }
};
return formatter;
};
function createRawSourceCode(script, request, compilerSourceMapping)
{
var resource = null;
if (request && request.finished) {
resource = WebInspector.resourceForURL(request.url)
request = null;
}
var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, request, compilerSourceMapping);
rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, defaultUISourceCodeChangedHandler);
return rawSourceCode;