blob: abd16cd41811a9f949dfd39bba7acea81246f607 [file] [log] [blame]
<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/search/search-test.js"></script>
<script>
var test = function()
{
var scriptSource;
var shouldRequestContent = false;
InspectorTest.startDebuggerTest(started);
function started()
{
InspectorTest.showScriptSource("script-formatter-search.html", didShowScriptSource);
}
function didShowScriptSource(frame)
{
scriptSource = frame._uiSourceCode;
InspectorTest.addSniffer(scriptSource._project, "requestFileContent", requestContentSniffer);
scriptSource.searchInContent("magic-string", true, false, dump1);
}
function dump1(matches)
{
InspectorTest.addResult("Pre-format search results:");
InspectorTest.dumpSearchMatches(matches);
shouldRequestContent = true;
scriptSource.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormat, this);
scriptSource.setFormatted(true);
}
function didFormat()
{
scriptSource.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormat, this);
scriptSource.searchInContent("magic-string", true, false, dump2);
}
function dump2(matches)
{
InspectorTest.addResult("Post-format search results:");
InspectorTest.dumpSearchMatches(matches);
InspectorTest.completeTest();
}
function requestContentSniffer()
{
if (shouldRequestContent)
InspectorTest.addResult("Original content was requested.");
else
InspectorTest.addResult("Failure: original content should not be requested.");
}
}
</script>
</head>
<body onload="runTest()">
<p>Tests that search across files works with formatted scripts.
</p>
</body>
</html>