summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/js/Tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/chromium/src/js/Tests.js')
-rw-r--r--WebKit/chromium/src/js/Tests.js740
1 files changed, 205 insertions, 535 deletions
diff --git a/WebKit/chromium/src/js/Tests.js b/WebKit/chromium/src/js/Tests.js
index fa0c99f..41574b4 100644
--- a/WebKit/chromium/src/js/Tests.js
+++ b/WebKit/chromium/src/js/Tests.js
@@ -261,10 +261,10 @@ TestSuite.prototype.testEnableResourcesTab = function()
var test = this;
this.addSniffer(WebInspector, "updateResource",
- function(identifier, payload) {
+ function(payload) {
test.assertEquals("simple_page.html", payload.lastPathComponent);
WebInspector.panels.resources.refresh();
- WebInspector.panels.resources.revealAndSelectItem(WebInspector.resources[identifier]);
+ WebInspector.panels.resources.revealAndSelectItem(WebInspector.resources[payload.id]);
test.releaseControl();
});
@@ -289,25 +289,25 @@ TestSuite.prototype.testResourceContentLength = function()
var png = false;
var html = false;
this.addSniffer(WebInspector, "updateResource",
- function(identifier, payload) {
+ function(payload) {
if (!payload.didLengthChange)
return;
- var resource = WebInspector.resources[identifier];
+ var resource = WebInspector.resources[payload.id];
if (!resource || !resource.url)
return;
- if (resource.url.search("image.html$") !== -1) {
+ if (resource.url.search("image.html") !== -1) {
var expectedLength = 87;
test.assertTrue(
- resource.contentLength <= expectedLength,
+ resource.resourceSize <= expectedLength,
"image.html content length is greater thatn expected.");
- if (expectedLength === resource.contentLength)
+ if (expectedLength === resource.resourceSize)
html = true;
} else if (resource.url.search("image.png") !== -1) {
var expectedLength = 257796;
test.assertTrue(
- resource.contentLength <= expectedLength,
+ resource.resourceSize <= expectedLength,
"image.png content length is greater than expected.");
- if (expectedLength === resource.contentLength)
+ if (expectedLength === resource.resourceSize)
png = true;
}
if (html && png) {
@@ -346,8 +346,8 @@ TestSuite.prototype.testResourceHeaders = function()
var timingOk = false;
this.addSniffer(WebInspector, "updateResource",
- function(identifier, payload) {
- var resource = this.resources[identifier];
+ function(payload) {
+ var resource = this.resources[payload.id];
if (!resource || resource.mainResource) {
// We are only interested in secondary resources in this test.
return;
@@ -393,8 +393,8 @@ TestSuite.prototype.testCachedResourceMimeType = function()
var hasReloaded = false;
this.addSniffer(WebInspector, "updateResource",
- function(identifier, payload) {
- var resource = this.resources[identifier];
+ function(payload) {
+ var resource = this.resources[payload.id];
if (!resource || resource.mainResource) {
// We are only interested in secondary resources in this test.
return;
@@ -425,39 +425,83 @@ TestSuite.prototype.testProfilerTab = function()
{
this.showPanel("profiles");
+ var panel = WebInspector.panels.profiles;
var test = this;
- this.addSniffer(WebInspector.panels.profiles, "addProfileHeader",
- function(typeOrProfile, profile) {
- if (!profile)
- profile = typeOrProfile;
- var panel = WebInspector.panels.profiles;
- panel.showProfile(profile);
- var node = panel.visibleView.profileDataGridTree.children[0];
- // Iterate over displayed functions and search for a function
- // that is called "fib" or "eternal_fib". If found, it will mean
- // that we actually have profiled page's code.
- while (node) {
- if (node.functionName.indexOf("fib") !== -1)
- test.releaseControl();
- node = node.traverseNextNode(true, null, true);
- }
- test.fail();
- });
- var ticksCount = 0;
- var tickRecord = "\nt,";
- this.addSniffer(RemoteProfilerAgent, "didGetLogLines",
- function(posIgnored, log) {
- var pos = 0;
- while ((pos = log.indexOf(tickRecord, pos)) !== -1) {
- pos += tickRecord.length;
- ticksCount++;
+ function findDisplayedNode() {
+ var node = panel.visibleView.profileDataGridTree.children[0];
+ if (!node) {
+ // Profile hadn't been queried yet, re-schedule.
+ window.setTimeout(findDisplayedNode, 100);
+ return;
+ }
+
+ // Iterate over displayed functions and search for a function
+ // that is called "fib" or "eternal_fib". If found, this will mean
+ // that we actually have profiled page's code.
+ while (node) {
+ if (node.functionName.indexOf("fib") !== -1)
+ test.releaseControl();
+ node = node.traverseNextNode(true, null, true);
+ }
+
+ test.fail();
+ }
+
+ function findVisibleView() {
+ if (!panel.visibleView) {
+ setTimeout(findVisibleView, 0);
+ return;
+ }
+ setTimeout(findDisplayedNode, 0);
+ }
+
+ findVisibleView();
+ this.takeControl();
+};
+
+
+/**
+ * Tests that heap profiler works.
+ */
+TestSuite.prototype.testHeapProfiler = function()
+{
+ this.showPanel("profiles");
+
+ var panel = WebInspector.panels.profiles;
+ var test = this;
+
+ function findDisplayedNode() {
+ var node = panel.visibleView.dataGrid.children[0];
+ if (!node) {
+ // Profile hadn't been queried yet, re-schedule.
+ window.setTimeout(findDisplayedNode, 100);
+ return;
+ }
+
+ // Iterate over displayed functions and find node called "A"
+ // If found, this will mean that we actually have taken heap snapshot.
+ while (node) {
+ if (node.constructorName.indexOf("A") !== -1) {
+ test.releaseControl();
+ return;
}
- if (ticksCount > 100)
- InspectorBackend.stopProfiling();
- }, true);
+ node = node.traverseNextNode(false, null, true);
+ }
+
+ test.fail();
+ }
- InspectorBackend.startProfiling();
+ function findVisibleView() {
+ if (!panel.visibleView) {
+ setTimeout(findVisibleView, 0);
+ return;
+ }
+ setTimeout(findDisplayedNode, 0);
+ }
+
+ WebInspector.HeapSnapshotProfileType.prototype.buttonClicked();
+ findVisibleView();
this.takeControl();
};
@@ -470,7 +514,7 @@ TestSuite.prototype.testShowScriptsTab = function()
this.showPanel("scripts");
var test = this;
// There should be at least main page script.
- this._waitUntilScriptsAreParsed(["debugger_test_page.html$"],
+ this._waitUntilScriptsAreParsed(["debugger_test_page.html"],
function() {
test.releaseControl();
});
@@ -489,31 +533,19 @@ TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh = function()
var test = this;
this.assertEquals(WebInspector.panels.elements, WebInspector.currentPanel, "Elements panel should be current one.");
- this.addSniffer(devtools.DebuggerAgent.prototype, "reset", waitUntilScriptIsParsed);
+ this.addSniffer(WebInspector.panels.scripts, "reset", waitUntilScriptIsParsed);
// Reload inspected page. It will reset the debugger agent.
test.evaluateInConsole_(
"window.location.reload(true);",
- function(resultText) {
- test.assertEquals("undefined", resultText, "Unexpected result of reload().");
- });
+ function(resultText) {});
function waitUntilScriptIsParsed() {
- var parsed = devtools.tools.getDebuggerAgent().parsedScripts_;
- for (var id in parsed) {
- var url = parsed[id].getUrl();
- if (url && url.search("debugger_test_page.html$") !== -1) {
- checkScriptsPanel();
- return;
- }
- }
- test.addSniffer(devtools.DebuggerAgent.prototype, "addScriptInfo_", waitUntilScriptIsParsed);
- }
-
- function checkScriptsPanel() {
test.showPanel("scripts");
- test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html$"]), "Inspected script not found in the scripts list");
- test.releaseControl();
+ test._waitUntilScriptsAreParsed(["debugger_test_page.html"],
+ function() {
+ test.releaseControl();
+ });
}
// Wait until all scripts are added to the debugger.
@@ -530,7 +562,7 @@ TestSuite.prototype.testContentScriptIsPresent = function()
var test = this;
test._waitUntilScriptsAreParsed(
- ["page_with_content_script.html$", "simple_content_script.js$"],
+ ["page_with_content_script.html", "simple_content_script.js"],
function() {
test.releaseControl();
});
@@ -568,7 +600,7 @@ TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function()
function checkScriptsPanel() {
test.assertTrue(!!WebInspector.panels.scripts.visibleView, "No visible script view.");
- test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html$"]), "Some scripts are missing.");
+ test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html"]), "Some scripts are missing.");
checkNoDuplicates();
test.releaseControl();
}
@@ -584,7 +616,7 @@ TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function()
}
test._waitUntilScriptsAreParsed(
- ["debugger_test_page.html$"],
+ ["debugger_test_page.html"],
function() {
checkNoDuplicates();
setTimeout(switchToElementsTab, 0);
@@ -604,7 +636,7 @@ TestSuite.prototype.testSetBreakpoint = function()
var test = this;
this.showPanel("scripts");
- var breakpointLine = 12;
+ var breakpointLine = 16
this._waitUntilScriptsAreParsed(["debugger_test_page.html"],
function() {
@@ -612,15 +644,25 @@ TestSuite.prototype.testSetBreakpoint = function()
"debugger_test_page.html",
function(view, url) {
view._addBreakpoint(breakpointLine);
- // Force v8 execution.
- RemoteDebuggerAgent.processDebugCommands();
- test.waitForSetBreakpointResponse_(url, breakpointLine,
- function() {
- test.releaseControl();
+
+ test.evaluateInConsole_(
+ 'setTimeout("calculate()" , 0)',
+ function(resultText) {
+ test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText);
});
});
});
+ this._waitForScriptPause(
+ {
+ functionsOnStack: ["calculate", ""],
+ lineNumber: breakpointLine,
+ lineText: " result = fib(lastVal++);"
+ },
+ function() {
+ test.releaseControl();
+ });
+
this.takeControl();
};
@@ -633,21 +675,13 @@ TestSuite.prototype.testPauseOnException = function()
this.showPanel("scripts");
var test = this;
- // TODO(yurys): remove else branch once the states are supported.
- if (WebInspector.ScriptsPanel.PauseOnExceptionsState) {
- while (WebInspector.currentPanel.pauseOnExceptionButton.state !== WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnUncaughtExceptions)
- WebInspector.currentPanel.pauseOnExceptionButton.element.click();
- } else {
- // Make sure pause on exceptions is on.
- if (!WebInspector.currentPanel.pauseOnExceptionButton.toggled)
- WebInspector.currentPanel.pauseOnExceptionButton.element.click();
- }
+ InspectorBackend.setPauseOnExceptionsState(WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnUncaughtExceptions);
- this._executeCodeWhenScriptsAreParsed("handleClick()", ["pause_on_exception.html$"]);
+ this._executeCodeWhenScriptsAreParsed("handleClick()", ["pause_on_exception.html"]);
this._waitForScriptPause(
{
- functionsOnStack: ["throwAnException", "handleClick", "(anonymous function)"],
+ functionsOnStack: ["throwAnException", "handleClick", ""],
lineNumber: 6,
lineText: " return unknown_var;"
},
@@ -729,7 +763,7 @@ TestSuite.prototype.testPauseWhenScriptIsRunning = function()
test._waitForScriptPause(
{
- functionsOnStack: ["handleClick", "(anonymous function)"],
+ functionsOnStack: ["handleClick", ""],
lineNumber: 5,
lineText: " while(true) {"
},
@@ -818,7 +852,7 @@ TestSuite.prototype.showMainPageScriptSource_ = function(scriptName, callback)
*/
TestSuite.prototype.evaluateInConsole_ = function(code, callback)
{
- WebInspector.console.visible = true;
+ WebInspector.showConsole();
WebInspector.console.prompt.text = code;
WebInspector.console.promptElement.dispatchEvent( TestSuite.createKeyEvent("Enter"));
@@ -829,29 +863,6 @@ TestSuite.prototype.evaluateInConsole_ = function(code, callback)
};
-/*
- * Waits for "setbreakpoint" response, checks that corresponding breakpoint
- * was successfully set and invokes the callback if it was.
- * @param {string} scriptUrl
- * @param {number} breakpointLine
- * @param {function()} callback
- */
-TestSuite.prototype.waitForSetBreakpointResponse_ = function(scriptUrl, breakpointLine, callback)
-{
- var test = this;
- test.addSniffer(
- devtools.DebuggerAgent.prototype,
- "handleSetBreakpointResponse_",
- function(msg) {
- var bps = this.urlToBreakpoints_[scriptUrl];
- test.assertTrue(!!bps, "No breakpoints for line " + breakpointLine);
- var line = devtools.DebuggerAgent.webkitToV8LineNumber_(breakpointLine);
- test.assertTrue(!!bps[line].getV8Id(), "Breakpoint id was not assigned.");
- callback();
- });
-};
-
-
/**
* Tests eval on call frame.
*/
@@ -862,36 +873,30 @@ TestSuite.prototype.testEvalOnCallFrame = function()
var breakpointLine = 16;
var test = this;
- this.addSniffer(devtools.DebuggerAgent.prototype, "handleScriptsResponse_",
- function(msg) {
+ this._waitUntilScriptsAreParsed(["debugger_test_page.html"],
+ function() {
test.showMainPageScriptSource_(
"debugger_test_page.html",
function(view, url) {
view._addBreakpoint(breakpointLine);
- // Force v8 execution.
- RemoteDebuggerAgent.processDebugCommands();
- test.waitForSetBreakpointResponse_(url, breakpointLine, setBreakpointCallback);
+
+ // Since breakpoints are ignored in evals' calculate() function is
+ // execute after zero-timeout so that the breakpoint is hit.
+ test.evaluateInConsole_(
+ 'setTimeout("calculate(123)" , 0)',
+ function(resultText) {
+ test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText);
+ waitForBreakpointHit();
+ });
});
});
- function setBreakpointCallback() {
- // Since breakpoints are ignored in evals' calculate() function is
- // execute after zero-timeout so that the breakpoint is hit.
- test.evaluateInConsole_(
- 'setTimeout("calculate(123)" , 0)',
- function(resultText) {
- test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText);
- waitForBreakpointHit();
- });
- }
-
function waitForBreakpointHit() {
- test.addSniffer(
- devtools.DebuggerAgent.prototype,
- "handleBacktraceResponse_",
- function(msg) {
- test.assertEquals(2, this.callFrames_.length, "Unexpected stack depth on the breakpoint. " + JSON.stringify(msg));
- test.assertEquals("calculate", this.callFrames_[0].functionName, "Unexpected top frame function.");
+ test.addSniffer(WebInspector,
+ "pausedScript",
+ function(callFrames) {
+ test.assertEquals(2, callFrames.length, "Unexpected stack depth on the breakpoint. " + JSON.stringify(callFrames, null, 4));
+ test.assertEquals("calculate", callFrames[0].functionName, "Unexpected top frame function.");
// Evaluate "e+1" where "e" is an argument of "calculate" function.
test.evaluateInConsole_(
"e+1",
@@ -913,19 +918,23 @@ TestSuite.prototype.testCompletionOnPause = function()
{
this.showPanel("scripts");
var test = this;
- this._executeCodeWhenScriptsAreParsed("handleClick()", ["completion_on_pause.html$"]);
+ this._executeCodeWhenScriptsAreParsed("handleClick()", ["completion_on_pause.html"]);
this._waitForScriptPause(
{
- functionsOnStack: ["innerFunction", "handleClick", "(anonymous function)"],
+ functionsOnStack: ["innerFunction", "handleClick", ""],
lineNumber: 9,
lineText: " debugger;"
},
showConsole);
function showConsole() {
- test.addSniffer(WebInspector.console, "afterShow", testLocalsCompletion);
- WebInspector.showConsole();
+ if (WebInspector.currentFocusElement === WebInspector.console.promptElement)
+ testLocalsCompletion();
+ else {
+ test.addSniffer(WebInspector.console, "afterShow", testLocalsCompletion);
+ WebInspector.showConsole();
+ }
}
function testLocalsCompletion() {
@@ -964,56 +973,7 @@ TestSuite.prototype.testCompletionOnPause = function()
*/
TestSuite.prototype.testAutoContinueOnSyntaxError = function()
{
- this.showPanel("scripts");
- var test = this;
-
- function checkScriptsList() {
- var scriptSelect = document.getElementById("scripts-files");
- var options = scriptSelect.options;
- // There should be only console API source (see
- // InjectedScript._ensureCommandLineAPIInstalled) since the page script
- // contains a syntax error.
- for (var i = 0 ; i < options.length; i++) {
- if (options[i].text.search("script_syntax_error.html$") !== -1)
- test.fail("Script with syntax error should not be in the list of parsed scripts.");
- }
- }
-
- this.addSniffer(devtools.DebuggerAgent.prototype, "handleScriptsResponse_",
- function(msg) {
- checkScriptsList();
-
- // Reload inspected page.
- test.evaluateInConsole_(
- "window.location.reload(true);",
- function(resultText) {
- test.assertEquals("undefined", resultText, "Unexpected result of reload().");
- waitForExceptionEvent();
- });
- });
-
- function waitForExceptionEvent() {
- var exceptionCount = 0;
- test.addSniffer(
- devtools.DebuggerAgent.prototype,
- "handleExceptionEvent_",
- function(msg) {
- exceptionCount++;
- test.assertEquals(1, exceptionCount, "Too many exceptions.");
- test.assertEquals(undefined, msg.getBody().script, "Unexpected exception: " + JSON.stringify(msg));
- test.releaseControl();
- });
-
- // Check that the script is not paused on parse error.
- test.addSniffer(
- WebInspector,
- "pausedScript",
- function(callFrames) {
- test.fail("Script execution should not pause on syntax error.");
- });
- }
-
- this.takeControl();
+ // TODO(yurys): provide an implementation that works with ScriptDebugServer.
};
@@ -1109,25 +1069,6 @@ TestSuite.prototype._checkSourceFrameWhenLoaded = function(expectations, callbac
/**
- * Performs sequence of steps.
- * @param {Array.<Object|Function>} Array [expectations1,action1,expectations2,
- * action2,...,actionN].
- */
-TestSuite.prototype._performSteps = function(actions)
-{
- var test = this;
- var i = 0;
- function doNextAction() {
- if (i > 0)
- actions[i++]();
- if (i < actions.length - 1)
- test._waitForScriptPause(actions[i++], doNextAction);
- }
- doNextAction();
-};
-
-
-/**
* Waits until all the scripts are parsed and asynchronously executes the code
* in the inspected page.
*/
@@ -1141,7 +1082,7 @@ TestSuite.prototype._executeCodeWhenScriptsAreParsed = function(code, expectedSc
test.evaluateInConsole_(
'setTimeout("' + code + '" , 0)',
function(resultText) {
- test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText);
+ test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText + ". Code: " + code);
});
}
@@ -1168,131 +1109,6 @@ TestSuite.prototype._waitUntilScriptsAreParsed = function(expectedScripts, callb
/**
- * Waits until all debugger scripts are parsed and executes "a()" in the
- * inspected page.
- */
-TestSuite.prototype._executeFunctionForStepTest = function()
-{
- this._executeCodeWhenScriptsAreParsed("a()", ["debugger_step.html$", "debugger_step.js$"]);
-};
-
-
-/**
- * Tests step over in the debugger.
- */
-TestSuite.prototype.testStepOver = function()
-{
- this.showPanel("scripts");
- var test = this;
-
- this._executeFunctionForStepTest();
-
- this._performSteps([
- {
- functionsOnStack: ["d","a","(anonymous function)"],
- lineNumber: 3,
- lineText: " debugger;"
- },
- function() {
- document.getElementById("scripts-step-over").click();
- },
- {
- functionsOnStack: ["d","a","(anonymous function)"],
- lineNumber: 5,
- lineText: " var y = fact(10);"
- },
- function() {
- document.getElementById("scripts-step-over").click();
- },
- {
- functionsOnStack: ["d","a","(anonymous function)"],
- lineNumber: 6,
- lineText: " return y;"
- },
- function() {
- test.releaseControl();
- }
- ]);
-
- test.takeControl();
-};
-
-
-/**
- * Tests step out in the debugger.
- */
-TestSuite.prototype.testStepOut = function()
-{
- this.showPanel("scripts");
- var test = this;
-
- this._executeFunctionForStepTest();
-
- this._performSteps([
- {
- functionsOnStack: ["d","a","(anonymous function)"],
- lineNumber: 3,
- lineText: " debugger;"
- },
- function() {
- document.getElementById("scripts-step-out").click();
- },
- {
- functionsOnStack: ["a","(anonymous function)"],
- lineNumber: 8,
- lineText: " printResult(result);"
- },
- function() {
- test.releaseControl();
- }
- ]);
-
- test.takeControl();
-};
-
-
-/**
- * Tests step in in the debugger.
- */
-TestSuite.prototype.testStepIn = function()
-{
- this.showPanel("scripts");
- var test = this;
-
- this._executeFunctionForStepTest();
-
- this._performSteps([
- {
- functionsOnStack: ["d","a","(anonymous function)"],
- lineNumber: 3,
- lineText: " debugger;"
- },
- function() {
- document.getElementById("scripts-step-over").click();
- },
- {
- functionsOnStack: ["d","a","(anonymous function)"],
- lineNumber: 5,
- lineText: " var y = fact(10);"
- },
- function() {
- document.getElementById("scripts-step-into").click();
- },
- {
- functionsOnStack: ["fact","d","a","(anonymous function)"],
- lineNumber: 15,
- lineText: " return r;"
- },
- function() {
- test.releaseControl();
- }
- ]);
-
- test.takeControl();
-};
-
-
-/**
* Gets a XPathResult matching given xpath.
* @param {string} xpath
* @param {number} resultType
@@ -1437,11 +1253,11 @@ TestSuite.prototype.testExpandScope = function()
this.showPanel("scripts");
var test = this;
- this._executeCodeWhenScriptsAreParsed("handleClick()", ["debugger_closure.html$"]);
+ this._executeCodeWhenScriptsAreParsed("handleClick()", ["debugger_closure.html"]);
this._waitForScriptPause(
{
- functionsOnStack: ["innerFunction", "handleClick", "(anonymous function)"],
+ functionsOnStack: ["innerFunction", "handleClick", ""],
lineNumber: 8,
lineText: " debugger;"
},
@@ -1464,14 +1280,14 @@ TestSuite.prototype.testExpandScope = function()
properties: {
x:"2009",
innerFunctionLocalVar:"2011",
- "this": "global",
+ "this": "DOMWindow",
}
},
{
title: "Closure",
properties: {
- n:"TextParam",
- makeClosureLocalVar:"local.TextParam",
+ n: '"TextParam"',
+ makeClosureLocalVar: '"local.TextParam"',
}
},
{
@@ -1543,128 +1359,6 @@ TestSuite.prototype._hookGetPropertiesCallback = function(hook, code)
/**
- * Tests that all elements in prototype chain of an object have expected
- * intrinic proprties(__proto__, constructor, prototype).
- */
-TestSuite.prototype.testDebugIntrinsicProperties = function()
-{
- this.showPanel("scripts");
- var test = this;
-
- this._executeCodeWhenScriptsAreParsed("handleClick()", ["debugger_intrinsic_properties.html$"]);
-
- this._waitForScriptPause(
- {
- functionsOnStack: ["callDebugger", "handleClick", "(anonymous function)"],
- lineNumber: 29,
- lineText: " debugger;"
- },
- expandLocalScope);
-
- var localScopeSection = null;
- function expandLocalScope() {
- test._expandScopeSections(function(sections, i) {
- if (i === 0) {
- test.assertTrue(sections[i].object.isLocal, "Scope #0 is not Local.");
- localScopeSection = sections[i];
- return true;
- }
- return false;
- },
- examineLocalScope);
- }
-
- function examineLocalScope() {
- var scopeExpectations = [
- "a", "Object", [
- "constructor", "function Child()", [
- "constructor", "function Function()", null,
- "name", "Child", null,
- "prototype", "Object", [
- "childProtoField", 21, null
- ]
- ],
-
- "__proto__", "Object", [
- "__proto__", "Object", [
- "__proto__", "Object", [
- "__proto__", "null", null,
- "constructor", "function Object()", null,
- ],
- "constructor", "function Parent()", [
- "name", "Parent", null,
- "prototype", "Object", [
- "parentProtoField", 11, null,
- ]
- ],
- "parentProtoField", 11, null,
- ],
- "constructor", "function Child()", null,
- "childProtoField", 21, null,
- ],
-
- "parentField", 10, null,
- "childField", 20, null,
- ]
- ];
-
- checkProperty(localScopeSection.propertiesTreeOutline, "<Local Scope>", scopeExpectations);
- }
-
- var propQueue = [];
- var index = 0;
- var expectedFinalIndex = 8;
-
- function expandAndCheckNextProperty() {
- if (index === propQueue.length) {
- test.assertEquals(expectedFinalIndex, index, "Unexpected number of expanded objects.");
- test.releaseControl();
- return;
- }
-
- // Read next property data from the queue.
- var treeElement = propQueue[index].treeElement;
- var path = propQueue[index].path;
- var expectations = propQueue[index].expectations;
- index++;
-
- // Expand the property.
- test._hookGetPropertiesCallback(function() {
- checkProperty(treeElement, path, expectations);
- },
- function() {
- treeElement.expand();
- });
- }
-
- function checkProperty(treeElement, path, expectations) {
- for (var i = 0; i < expectations.length; i += 3) {
- var name = expectations[i];
- var description = expectations[i+1];
- var value = expectations[i+2];
-
- var propertyPath = path + "." + name;
- var propertyTreeElement = test._findChildProperty(treeElement, name, path);
- test.assertTrue(propertyTreeElement, 'Property "' + propertyPath + '" not found.');
- test.assertEquals(description, propertyTreeElement.property.value.description, 'Unexpected "' + propertyPath + '" description.');
- if (value) {
- // Schedule property content check.
- propQueue.push({
- treeElement: propertyTreeElement,
- path: propertyPath,
- expectations: value,
- });
- }
- }
- // Check next property in the queue.
- expandAndCheckNextProperty();
- }
-
- test.takeControl();
-};
-
-
-/**
* Tests "Pause" button will pause debugger when a snippet is evaluated.
*/
TestSuite.prototype.testPauseInEval = function()
@@ -1699,96 +1393,43 @@ TestSuite.createKeyEvent = function(keyIdentifier)
/**
- * Tests console eval.
+ * Tests the message loop re-entrancy.
*/
-TestSuite.prototype.testConsoleEval = function()
+TestSuite.prototype.testMessageLoopReentrant = function()
{
var test = this;
- this.evaluateInConsole_("123",
- function(resultText) {
- test.assertEquals("123", resultText);
- test.releaseControl();
- });
-
- this.takeControl();
-};
-
-
-/**
- * Tests console log.
- */
-TestSuite.prototype.testConsoleLog = function()
-{
- WebInspector.console.visible = true;
- var messages = WebInspector.console.messages;
- var index = 0;
+ this.showPanel("scripts");
- var test = this;
- var assertNext = function(line, message, opt_class, opt_count, opt_substr) {
- var elem = messages[index++].toMessageElement();
- var clazz = elem.getAttribute("class");
- var expectation = (opt_count || '') + 'console_test_page.html:' + line + message;
- if (opt_substr)
- test.assertContains(elem.textContent, expectation);
- else
- test.assertEquals(expectation, elem.textContent);
- if (opt_class)
- test.assertContains(clazz, "console-" + opt_class);
- };
+ var breakpointLine = 16;
- assertNext("5", "log", "log-level");
- assertNext("7", "debug", "log-level");
- assertNext("9", "info", "log-level");
- assertNext("11", "warn", "warning-level");
- assertNext("13", "error", "error-level");
- assertNext("15", "Message format number 1, 2 and 3.5");
- assertNext("17", "Message format for string");
- assertNext("19", "Object Object");
- assertNext("22", "repeated", "log-level", 5);
- assertNext("26", "count: 1");
- assertNext("26", "count: 2");
- assertNext("29", "group", "group-title");
- index++;
- assertNext("33", "timer:", "log-level", "", true);
- assertNext("35", "1 2 3", "log-level");
- assertNext("37", "HTMLDocument", "log-level");
- assertNext("39", "<html>", "log-level", "", true);
-};
+ WebInspector.showConsole();
+ this._waitUntilScriptsAreParsed(["debugger_test_page.html"],
+ function() {
+ test.showMainPageScriptSource_(
+ "debugger_test_page.html",
+ function(view, url) {
+ view._addBreakpoint(breakpointLine);
-/**
- * Tests eval of global objects.
- */
-TestSuite.prototype.testEvalGlobal = function()
-{
- WebInspector.console.visible = true;
+ test.evaluateInConsole_(
+ 'setTimeout("calculate()", 0)',
+ function(resultText) {
+ test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText);
+ });
- var inputs = ["foo", "foobar"];
- var expectations = ["foo", "fooValue", "foobar", "ReferenceError: foobar is not defined"];
+ });
+ });
- // Do not change code below - simply add inputs and expectations above.
- var initEval = function(input) {
- WebInspector.console.prompt.text = input;
- WebInspector.console.promptElement.dispatchEvent( TestSuite.createKeyEvent("Enter"));
- };
- var test = this;
- var messagesCount = 0;
- var inputIndex = 0;
- this.addSniffer(WebInspector.ConsoleView.prototype, "addMessage",
- function(commandResult) {
- messagesCount++;
- if (messagesCount === expectations.length) {
- var messages = WebInspector.console.messages;
- for (var i = 0; i < expectations; ++i) {
- var elem = messages[i++].toMessageElement();
- test.assertEquals(elem.textContent, expectations[i]);
- }
- test.releaseControl();
- } else if (messagesCount % 2 === 0)
- initEval(inputs[inputIndex++]);
- }, true);
+ // Wait until script is paused.
+ this.addSniffer(
+ WebInspector,
+ "pausedScript",
+ function(callFrames) {
+ test.evaluateInConsole_(
+ 'document.cookie',
+ test.releaseControl.bind(test)); // This callback will be invoked only if the test succeeds (i.e. no crash).
+ });
- initEval(inputs[inputIndex++]);
this.takeControl();
};
@@ -1855,8 +1496,37 @@ uiTests.runAllTests = function()
*/
uiTests.runTest = function(name)
{
- new TestSuite().runTest(name);
+ if (uiTests._populatedInterface)
+ new TestSuite().runTest(name);
+ else
+ uiTests._pendingTestName = name;
};
+(function() {
+
+function runTests()
+{
+ uiTests._populatedInterface = true;
+ var name = uiTests._pendingTestName;
+ delete uiTests._pendingTestName;
+ if (name)
+ new TestSuite().runTest(name);
+}
+
+var oldShowElementsPanel = WebInspector.showElementsPanel;
+WebInspector.showElementsPanel = function()
+{
+ oldShowElementsPanel.call(this);
+ runTests();
+}
+
+var oldShowPanel = WebInspector.showPanel;
+WebInspector.showPanel = function(name)
+{
+ oldShowPanel.call(this, name);
+ runTests();
+}
+
+})();
}