+2011-02-13 Pavel Feldman <pfeldman@chromium.org>
+
+ Reviewed by Yury Semikhatsky.
+
+ Web Inspector: [layout tests] get rid of elements-tests.js in favor of elements-tests2.js
+ https://bugs.webkit.org/show_bug.cgi?id=54354
+
+ * http/tests/inspector/console-resource-errors.html:
+ * http/tests/inspector/console-test.js: Renamed from LayoutTests/http/tests/inspector/console-tests2.js.
+ * http/tests/inspector/console-tests.js: Removed.
+ * http/tests/inspector/console-websocket-error.html:
+ * http/tests/inspector/console-xhr-logging-expected.txt:
+ * http/tests/inspector/console-xhr-logging.html:
+ * http/tests/inspector/debugger-test.js: Renamed from LayoutTests/http/tests/inspector/debugger-test2.js.
+ * http/tests/inspector/elements-test.js: Added.
+ * http/tests/inspector/inspector-test2.js:
+ * http/tests/inspector/resource-har-conversion-expected.txt:
+ * http/tests/inspector/resource-har-conversion.html:
+ * http/tests/inspector/resource-parameters-expected.txt:
+ * http/tests/inspector/resource-parameters.html:
+ * http/tests/inspector/resource-tests.js: Removed.
+ * http/tests/inspector/resources-test.js: Renamed from LayoutTests/http/tests/inspector/resource-test2.js.
+ * inspector/command-line-api.html:
+ * inspector/console-api-on-call-frame.html:
+ * inspector/console-assert.html:
+ * inspector/console-clear.html:
+ * inspector/console-command-clear-expected.txt:
+ * inspector/console-command-clear.html:
+ * inspector/console-dir-global.html:
+ * inspector/console-dir.html:
+ * inspector/console-dirxml.html:
+ * inspector/console-eval-global.html:
+ * inspector/console-eval.html:
+ * inspector/console-format-collections-expected.txt:
+ * inspector/console-format-collections.html:
+ * inspector/console-format-expected.txt:
+ * inspector/console-format.html:
+ * inspector/console-log-before-inspector-open.html:
+ * inspector/console-log-syntax-error.html:
+ * inspector/console-object-constructor-name.html:
+ * inspector/console-tests.html:
+ * inspector/console-trace-in-eval.html:
+ * inspector/console-trace.html:
+ * inspector/console-uncaught-exception-in-eval.html:
+ * inspector/console-uncaught-exception.html:
+ * inspector/debugger-autocontinue-on-syntax-error.html:
+ * inspector/debugger-breakpoints-not-activated-on-reload.html:
+ * inspector/debugger-cyclic-ref.html:
+ * inspector/debugger-eval-on-call-frame.html:
+ * inspector/debugger-eval-while-paused.html:
+ * inspector/debugger-expand-scope.html:
+ * inspector/debugger-no-nested-pause.html:
+ * inspector/debugger-pause-in-eval-script.html:
+ * inspector/debugger-pause-on-breakpoint.html:
+ * inspector/debugger-pause-on-debugger-statement.html:
+ * inspector/debugger-pause-on-exception.html:
+ * inspector/debugger-proto-property.html:
+ * inspector/debugger-scripts.html:
+ * inspector/debugger-step-in.html:
+ * inspector/debugger-step-out.html:
+ * inspector/debugger-step-over.html:
+ * inspector/debugger-suspend-active-dom-objects.html:
+ * inspector/dom-breakpoints.html:
+ * inspector/elements-delete-inline-style.html:
+ * inspector/elements-img-tooltip-expected.txt:
+ * inspector/elements-img-tooltip.html:
+ * inspector/elements-panel-limited-children-expected.txt:
+ * inspector/elements-panel-limited-children.html:
+ * inspector/elements-panel-rewrite-href-expected.txt:
+ * inspector/elements-panel-rewrite-href.html:
+ * inspector/elements-panel-selection-on-refresh-expected.txt:
+ * inspector/elements-panel-selection-on-refresh.html:
+ * inspector/elements-panel-structure-expected.txt:
+ * inspector/elements-panel-structure.html:
+ * inspector/elements-panel-styles.html:
+ * inspector/elements-panel-xhtml-structure-expected.txt:
+ * inspector/elements-panel-xhtml-structure.xhtml:
+ * inspector/elements-tests.js: Removed.
+ * inspector/elements-tests2.js: Removed.
+ * inspector/resources/elements-panel-styles.css:
+ * inspector/resources/styles-iframe-data.html:
+ * inspector/storage-panel-dom-storage.html:
+ * inspector/styles-add-blank-property.html:
+ * inspector/styles-computed-trace.html:
+ * inspector/styles-disable-inherited.html:
+ * inspector/styles-disable-then-change.html:
+ * inspector/styles-disable-then-delete.html:
+ * inspector/styles-disable-then-enable.html:
+ * inspector/styles-iframe-expected.txt:
+ * inspector/styles-iframe.html:
+ * inspector/styles-new-API.html:
+ * inspector/styles-source-lines-expected.txt:
+ * inspector/styles-source-lines-inline.html:
+ * inspector/styles-source-lines.html:
+ * inspector/styles-source-offsets.html:
+ * inspector/styles-url-linkify.html:
+
2011-02-14 Shinichiro Hamaji <hamaji@chromium.org>
Rebaseline chromium's test_expectations.
<html>
<head>
-<script src="console-tests2.js"></script>
+<script src="console-test.js"></script>
<script src="inspector-test2.js"></script>
<link rel="stylesheet" type="text/css" href="missing.css">
+++ /dev/null
-// Inspected Page functions.
-
-function dumpConsoleMessages(noNotifyDone) {
- function callback(result)
- {
- for (var i = 0; i < result.length; ++i)
- output(result[i].text);
- if (!noNotifyDone)
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
-}
-
-function dumpConsoleMessagesWithClasses(sortMessages) {
- function callback(result)
- {
- var messages = [];
- for (var i = 0; i < result.length; ++i)
- messages.push(result[i].text + " " + result[i].clazz);
- if (sortMessages)
- messages.sort();
- for (var i = 0; i < messages.length; ++i)
- output(messages[i]);
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
-}
-
-
-// Frontend functions.
-
-function frontend_dumpConsoleMessages()
-{
- var result = [];
- var messages = WebInspector.console.messages;
- for (var i = 0; i < messages.length; ++i) {
- var element = messages[i].toMessageElement();
- result.push({ text: element.textContent.replace(/\u200b/g, ""), clazz: element.getAttribute("class")});
- }
- return result;
-}
-
<html>
<head>
-<script src="inspector-test.js"></script>
-<script src="console-tests.js"></script>
+<script src="inspector-test2.js"></script>
+<script src="console-test.js"></script>
<script>
var testFunctions = [testDNSLookup, testSSLCertificate];
var nextTestIndex = 0;
-function doit()
+function onload()
{
+ if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
if (!window.WebSocket) {
- console.log("WebSocket is not supported.");
- dumpConsoleMessages(false);
- return;
+ console.log("WebSocket is not supported."); return;
}
doNextTest();
}
function doNextTest()
{
if (nextTestIndex == testFunctions.length) {
- dumpConsoleMessages(false);
+ runTest();
return;
}
var testFunction = testFunctions[nextTestIndex];
doNextTest();
};
}
+
+function test()
+{
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+}
+
</script>
</head>
-CONSOLE MESSAGE: line 11: enabled
-CONSOLE MESSAGE: line 40: sending a %s request to %s
-CONSOLE MESSAGE: line 40: sending a %s request to %s
-CONSOLE MESSAGE: line 40: sending a %s request to %s
-CONSOLE MESSAGE: line 21: disabled
-CONSOLE MESSAGE: line 40: sending a %s request to %s
-CONSOLE MESSAGE: line 40: sending a %s request to %s
-CONSOLE MESSAGE: line 40: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
Tests that XMLHttpRequest Logging works when Enabled and doesn't show logs when Disabled.
-console-xhr-logging.html:11enabled
-console-xhr-logging.html:40sending a GET request to resources/xhr-exists.html
+console-xhr-logging.html:10sending a GET request to resources/xhr-exists.html
XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-exists.html".
-console-xhr-logging.html:40sending a GET request to resources/xhr-does-not-exist.html
+console-xhr-logging.html:10sending a GET request to resources/xhr-does-not-exist.html
xhr-does-not-exist.htmlGET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found)
XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html".
-console-xhr-logging.html:40sending a POST request to resources/post-target.cgi
+console-xhr-logging.html:10sending a POST request to resources/post-target.cgi
XHR finished loading: "http://127.0.0.1:8000/inspector/resources/post-target.cgi".
-console-xhr-logging.html:21disabled
-console-xhr-logging.html:40sending a GET request to resources/xhr-exists.html
-console-xhr-logging.html:40sending a GET request to resources/xhr-does-not-exist.html
+console-xhr-logging.html:10sending a GET request to resources/xhr-exists.html
+console-xhr-logging.html:10sending a GET request to resources/xhr-does-not-exist.html
xhr-does-not-exist.htmlGET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found)
-console-xhr-logging.html:40sending a POST request to resources/post-target.cgi
+console-xhr-logging.html:10sending a POST request to resources/post-target.cgi
<html>
<head>
-<script src="inspector-test.js"></script>
-<script src="console-tests.js"></script>
+<script src="inspector-test2.js"></script>
+<script src="console-test.js"></script>
<script>
-function doit()
-{
- // Enable XMLHttpRequest Logging.
- evaluateInWebInspector("frontend_enableXMLHttpRequestLogging", function(result) {
- console.log(result);
- makeRequests();
- testDisabled();
- });
-}
-
-function testDisabled()
+function requestHelper(method, url)
{
- // Disable XMLHttpRequest Logging.
- evaluateInWebInspector("frontend_disableXMLHttpRequestLogging", function(result) {
- console.log(result);
- makeRequests();
- dumpConsoleMessages();
- });
+ // Make synchronous requests for simplicity.
+ console.log("sending a %s request to %s", method, url);
+ var xhr = new XMLHttpRequest();
+ xhr.open(method, url, false);
+ xhr.send();
}
function makeRequests()
requestHelper("POST", "resources/post-target.cgi");
}
-function requestHelper(method, url)
-{
- // Make synchronous requests for simplicity.
- console.log("sending a %s request to %s", method, url);
- var xhr = new XMLHttpRequest();
- xhr.open(method, url, false);
- xhr.send();
-}
-
-function frontend_enableXMLHttpRequestLogging(testController)
+function test()
{
- InspectorBackend.setMonitoringXHREnabled(true, function() {
- testController.notifyDone("enabled");
- });
+ step1();
- testController.waitUntilDone();
-}
+ function step1()
+ {
+ function callback()
+ {
+ InspectorTest.evaluateInPage("makeRequests()", step2);
+ }
+ InspectorBackend.setMonitoringXHREnabled(true, callback);
+ }
-function frontend_disableXMLHttpRequestLogging(testController)
-{
- InspectorBackend.setMonitoringXHREnabled(false, function() {
- testController.notifyDone("disabled");
- });
+ function step2()
+ {
+ function callback()
+ {
+ InspectorTest.evaluateInPage("makeRequests()", step3);
+ }
+ InspectorBackend.setMonitoringXHREnabled(false, callback);
+ }
- testController.waitUntilDone();
+ function step3()
+ {
+ function finish()
+ {
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+ }
+ InspectorTest.runAfterPendingDispatches(finish);
+ }
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that XMLHttpRequest Logging works when Enabled and doesn't show logs when Disabled.
</p>
--- /dev/null
+var initialize_ElementTest = function() {
+
+InspectorTest.pushAllDOM = function(callback)
+{
+ InspectorTest.nodeWithId(/nonstring/, callback);
+}
+
+InspectorTest.nodeWithId = function(idValue, callback)
+{
+ var result = null;
+ var topLevelChildrenRequested = false;
+ var pendingRequests = 0;
+ function processChildren(topLevel, children)
+ {
+ pendingRequests--;
+ if (result)
+ return;
+
+ for (var i = 0; children && i < children.length; ++i) {
+ var childNode = children[i];
+ if (childNode.getAttribute("id") === idValue) {
+ result = childNode;
+ if (callback)
+ callback(result);
+ return;
+ }
+ pendingRequests++;
+ WebInspector.domAgent.getChildNodesAsync(childNode, processChildren.bind(null, false));
+ }
+
+ if (topLevel)
+ topLevelChildrenRequested = true;
+ if (topLevelChildrenRequested && !result && !pendingRequests)
+ callback(null);
+ }
+ pendingRequests++;
+ WebInspector.domAgent.getChildNodesAsync(WebInspector.domAgent.document, processChildren.bind(this, true));
+};
+
+InspectorTest.selectNodeWithId = function(idValue, callback)
+{
+ function mycallback(node)
+ {
+ if (node)
+ WebInspector.updateFocusedNode(node.id);
+ if (callback)
+ InspectorTest.runAfterPendingDispatches(callback.bind(null, node));
+ }
+ InspectorTest.nodeWithId(idValue, mycallback);
+};
+
+InspectorTest.dumpSelectedElementStyles = function(excludeComputed, excludeMatched, omitLonghands)
+{
+ var styleSections = WebInspector.panels.elements.sidebarPanes.styles.sections;
+ for (var pseudoId in styleSections) {
+ var pseudoName = WebInspector.StylesSidebarPane.PseudoIdNames[pseudoId];
+ var sections = styleSections[pseudoId];
+ for (var i = 0; i < sections.length; ++i) {
+ var section = sections[i];
+ if (section.computedStyle && excludeComputed)
+ continue;
+ if (section.rule && excludeMatched)
+ continue;
+ if (section.element.previousSibling && section.element.previousSibling.className === "styles-sidebar-separator")
+ InspectorTest.addResult("======== " + section.element.previousSibling.textContent + " ========");
+ InspectorTest.addResult((section.expanded ? "[expanded] " : "[collapsed] ") + section.titleElement.textContent + " (" + section.subtitleAsTextForTest + ")");
+ section.expand();
+ InspectorTest.dumpStyleTreeOutline(section.propertiesTreeOutline, omitLonghands ? 1 : 2);
+ InspectorTest.addResult("");
+ }
+ InspectorTest.addResult("");
+ }
+};
+
+// FIXME: this returns the first tree item found (may fail for same-named properties in a style).
+InspectorTest.getElementStylePropertyTreeItem = function(propertyName)
+{
+ var styleSections = WebInspector.panels.elements.sidebarPanes.styles.sections[0];
+ var elementStyleSection = styleSections[1];
+ var outline = elementStyleSection.propertiesTreeOutline;
+ for (var i = 0; i < outline.children.length; ++i) {
+ var treeItem = outline.children[i];
+ if (treeItem.name === propertyName)
+ return treeItem;
+ }
+ return null;
+};
+
+InspectorTest.dumpStyleTreeOutline = function(treeItem, depth)
+{
+ var children = treeItem.children;
+ for (var i = 0; i < children.length; ++i)
+ InspectorTest.dumpStyleTreeItem(children[i], "", depth || 2);
+};
+
+InspectorTest.dumpStyleTreeItem = function(treeItem, prefix, depth)
+{
+ // Filter out width and height properties in order to minimize
+ // potential diffs.
+ if (!treeItem.listItemElement.textContent.indexOf("width") ||
+ !treeItem.listItemElement.textContent.indexOf("height"))
+ return;
+
+ if (treeItem.listItemElement.hasStyleClass("inherited"))
+ return;
+ var typePrefix = "";
+ if (treeItem.listItemElement.hasStyleClass("overloaded"))
+ typePrefix += "/-- overloaded --/ ";
+ if (treeItem.listItemElement.hasStyleClass("disabled"))
+ typePrefix += "/-- disabled --/ ";
+ var textContent = treeItem.listItemElement.textContent;
+
+ // Add non-selectable url text.
+ var textData = treeItem.listItemElement.querySelector("[data-uncopyable]");
+ if (textData)
+ textContent += textData.getAttribute("data-uncopyable");
+ InspectorTest.addResult(prefix + typePrefix + textContent);
+ if (--depth) {
+ treeItem.expand();
+ var children = treeItem.children;
+ for (var i = 0; children && i < children.length; ++i)
+ InspectorTest.dumpStyleTreeItem(children[i], prefix + " ", depth);
+ }
+};
+
+InspectorTest.dumpElementsTree = function()
+{
+ WebInspector.panels.elements.updateModifiedNodes();
+ InspectorTest.addResult(WebInspector.panels.elements.treeOutline.element.textContent.replace(/\u200b/g, "").replace(/\n/g, "").replace(/</g, "\n<"));
+};
+
+InspectorTest.dumpLoadedDOM = function()
+{
+ function expand(treeItem, topLevel)
+ {
+ var children = treeItem.children;
+ for (var i = 0; children && i < children.length; ++i) {
+ children[i].expand();
+ expand(children[i], false);
+ }
+ if (topLevel)
+ InspectorTest.dumpElementsTree();
+ }
+ WebInspector.panels.elements.updateModifiedNodes();
+ expand(WebInspector.panels.elements.treeOutline, true);
+};
+
+};
\ No newline at end of file
InspectorTest.evaluateInPage = function(code, callback)
{
- InspectorBackend.evaluate(code, "console", false, callback || function() {});
+ function mycallback(result)
+ {
+ if (callback)
+ callback(WebInspector.RemoteObject.fromPayload(result));
+ }
+ InspectorBackend.evaluate(code, "console", false, mycallback);
}
InspectorTest.evaluateInPageWithTimeout = function(code, callback)
InspectorBackend.reloadPage(false);
}
-InspectorTest.reloadPageIfNeeded = function(callback)
-{
- if (!InspectorTest._pageWasReloaded) {
- InspectorTest._pageWasReloaded = true;
- InspectorTest.reloadPage(callback);
- } else {
- if (callback)
- callback();
- }
-}
-
InspectorTest.pageReloaded = function()
{
resultsSynchronized = false;
var runTestCallId = 0;
var completeTestCallId = 1;
+function runAfterIframeIsLoaded()
+{
+ if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+ function step()
+ {
+ if (!window.iframeLoaded)
+ setTimeout(step, 100);
+ else
+ runTest();
+ }
+ setTimeout(step, 100);
+}
+
function runTest()
{
if (!window.layoutTestController)
time : <number>
request : {
method : "GET"
- url : "http://127.0.0.1:8000/inspector/resource-test2.js"
+ url : "http://127.0.0.1:8000/inspector/resources-test.js"
headers : <object>
headersSize : -1
bodySize : <number>
<html>
<head>
-<script src="resource-test2.js"></script>
+<script src="resources-test.js"></script>
<script src="inspector-test2.js"></script>
<script>
}
}
- InspectorTest.reloadPageIfNeeded(function() {
+ InspectorTest.reloadPage(function() {
InspectorBackend.evaluate("doXHR()", "console", false, function() {
addCookieHeadersToResource(findResourceByURL(/inspector-test2\.js$/));
var entries = (new WebInspector.HARLog()).build().entries;
{
pageref : "http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2="
- startedDateTime : <string>
+ startedDateTime : <object>
time : <number>
request : {
method : "POST"
<html>
<head>
-<script src="inspector-test.js"></script>
-<script src="resource-tests.js"></script>
+<script src="inspector-test2.js"></script>
+<script src="resources-test.js"></script>
<script>
-function doit()
+function submit()
{
- window.submitCalled = true;
document.getElementById("submit").click();
}
-function onIframeLoad()
+function test()
{
- if (!window.submitCalled)
- return;
+ InspectorTest.evaluateInPage("submit()");
+ InspectorTest._addSniffer(WebInspector.NetworkDispatcher.prototype, "didFinishLoading", dumpHAR);
- function callback(result)
+ function dumpHAR()
{
- dumpObject(result, HARNondeterministicProperties);
- notifyDone();
+ var resource = WebInspector.resourceForURL("http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2=");
+ if (resource)
+ InspectorTest.addObject(new WebInspector.HAREntry(resource).build(), InspectorTest.HARNondeterministicProperties);
+ InspectorTest.completeTest();
}
- evaluateInWebInspector("frontend_dumpFormData", callback);
-}
-
-function frontend_dumpFormData(testController)
-{
- var resource = WebInspector.resourceForURL("http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2=");
-
- if (!resource) {
- testController.notifyDone("No resource found");
- return;
- }
- testController.notifyDone(new WebInspector.HAREntry(resource).build());
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that resources panel shows form data parameters.
</p>
<input name="formParam2">
<input id="submit" type="submit">
</form>
-<iframe name="target-iframe" onload="onIframeLoad();"></iframe>
+<iframe name="target-iframe"></iframe>
</body>
</html>
+++ /dev/null
-var HARNondeterministicProperties = {
- startedDateTime: 1,
- time: 1,
- wait: 1,
- receive: 1,
- headers: 1,
- timings: 1,
-};
-
-function resourceURLComparer(r1, r2)
-{
- return r1.request.url.localeCompare(r2.request.url);
-}
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="elements-tests2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
var test = function()
{
- InspectorTest.expandDOMSubtreeAndRun(null, step1);
-
- function step1()
- {
- InspectorTest.selectElementAndRun("foo", step2);
- }
-
var expressions = [
"$0.toString()",
"keys([3,4]).toString()",
"$$('p#foo').toString()"
];
- function step2()
+ InspectorTest.selectNodeWithId("foo", step1);
+
+ function step1(node)
{
if (!expressions.length) {
InspectorTest.completeTest();
}
var expression = expressions[0];
expressions.splice(0, 1);
- InspectorTest.evaluateInConsoleAndDump(expression, step2);
+ InspectorTest.evaluateInConsoleAndDump(expression, step1);
}
}
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
window.inspect = "inspect";
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
function b()
function a()
{
b();
- evaluateInWebInspector("frontend_expandConsoleMessages");
- dumpConsoleMessages();
}
-function doit()
+function test()
{
- setTimeout(a, 0);
-}
-
-function frontend_expandConsoleMessages()
-{
- var messages = WebInspector.console.messages;
- for (var i = 0; i < messages.length; ++i) {
- var element = messages[i].toMessageElement();
- var node = element;
- while (node) {
- if (node.treeElementForTest)
- node.treeElementForTest.expand();
- node = node.traverseNextNode(element);
+ var callCount = 0;
+ function callback()
+ {
+ if (++callCount === 2) {
+ InspectorTest.expandConsoleMessages();
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
}
}
+ InspectorTest.evaluateInPage("setTimeout(a, 0)");
+ InspectorTest._addSniffer(WebInspector.ConsoleView.prototype, "addMessage", callback, true);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that console.assert() will dump a message and stack trace with source URLs and line numbers.
</p>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
-function doit()
-{
+function log() {
+ // Fill console.
console.log("one");
console.log("two");
console.log("three");
+}
+
+log();
+
+function test()
+{
+
+ InspectorTest.addResult("=== Before clear ===");
+ InspectorTest.dumpConsoleMessages();
- output("=== Before clear ===");
- dumpConsoleMessages(true);
+ WebInspector.console.requestClearMessages();
+
function callback()
{
- output("=== After clear ===");
- dumpConsoleMessages();
+ InspectorTest.addResult("=== After clear ===");
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
}
- evaluateInWebInspector("WebInspector.console.requestClearMessages()", callback);
+ InspectorTest.runAfterPendingDispatches(callback);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that console is cleared upon requestClearMessages call.
</p>
console-command-clear.html:10two
console-command-clear.html:11three
=== After clear ===
+undefined
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
-function doit()
-{
+function log() {
+ // Fill console.
console.log("one");
console.log("two");
console.log("three");
+}
+
+log();
+
+function test()
+{
+
+ InspectorTest.addResult("=== Before clear ===");
+ InspectorTest.dumpConsoleMessages();
- output("=== Before clear ===");
- dumpConsoleMessages(true);
function callback()
{
- output("=== After clear ===");
- dumpConsoleMessages();
+ InspectorTest.addResult("=== After clear ===");
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
}
- evaluateInWebInspector("InspectorBackend.evaluate('clear()', '', true, function() {})", callback);
+ InspectorTest.evaluateInConsole("clear()", callback);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
-Tests that console is cleared upon clear() eval in console.
+ Tests that console is cleared upon clear() eval in console.
</p>
</body>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
function doit()
{
console.dir(window);
-
- function callback(result)
- {
- dumpObject(result);
- notifyDone();
- }
-
- evaluateInWebInspector("frontend_expandAndDumpConsoleMessages", callback);
+ runTest();
}
-function frontend_expandAndDumpConsoleMessages(testController)
+function test()
{
- // Need test to be async to expand console objects.
- testController.waitUntilDone();
-
InspectorBackend.evaluate("window", "console", false, evalCallback);
function evalCallback(result)
function getPropertiesCallback(properties)
{
properties.sort(WebInspector.ObjectPropertiesSection.CompareProperties);
- var result = {};
var golden = { "window": 1, "document": 1, "eval": 1, "console": 1, "frames": 1, "Array": 1, "doit": 1 };
+ var result = {};
for (var i = 0; i < properties.length; ++i) {
var name = properties[i].name;
if (golden[name])
result[name] = 1;
}
- testController.notifyDone(result);
+ InspectorTest.addObject(result);
+ InspectorTest.completeTest();
}
}
</script>
</head>
-<body onload="onload()">
+<body onload="doit()">
<p>
Tests that console dumps global object with properties.
</p>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
-function doit()
+function onload()
{
console.dir(["test1", "test2"]);
console.dir(document.childNodes);
console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null));
-
- expandAndDumpConsoleMessages();
-}
-
-function expandAndDumpConsoleMessages(noNotifyDone) {
- function callback(result)
- {
- for (var i = 0; i < result.length; ++i) {
- output(result[i].title);
- var properties = result[i].properties;
- for (var j = 0; properties && j < properties.length; ++j)
- output(" " + properties[j].name + " = " + properties[j].value._description);
- }
- if (!noNotifyDone)
- notifyDone();
- }
- evaluateInWebInspector("frontend_expandAndDumpConsoleMessages", callback);
+ runTest();
}
-function frontend_expandAndDumpConsoleMessages(testController)
+function test()
{
- // Need test to be async to expand console objects.
- testController.waitUntilDone();
var messages = WebInspector.console.messages;
for (var i = 0; i < messages.length; ++i) {
var element = messages[i].toMessageElement();
}
}
- testController.runAfterPendingDispatches(function() {
+ InspectorTest.runAfterPendingDispatches(dumpConsoleMessages);
+
+ function dumpConsoleMessages()
+ {
var messages = WebInspector.console.messages;
var result = [];
for (var i = 0; i < messages.length; ++i) {
var section = messages[i].section;
- if (section)
- result.push({ title: section.titleElement.textContent, properties: section.propertiesForTest});
+ if (section) {
+ InspectorTest.addResult(section.titleElement.textContent);
+ var properties = section.propertiesForTest;
+ for (var j = 0; properties && j < properties.length; ++j)
+ InspectorTest.addResult(" " + properties[j].name + " = " + properties[j].value._description);
+ }
}
- testController.notifyDone(result);
- });
+ InspectorTest.completeTest();
+ }
}
</script>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
-function doit()
+function onload()
{
var fragment = document.createDocumentFragment();
fragment.appendChild(document.createElement("p"));
console.dirxml(fragment.firstChild);
console.log([fragment.firstChild]);
- dumpConsoleMessages();
+ runTest();
}
+function test()
+{
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+}
</script>
</head>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
var foo = 'fooValue';
a: 'b'
};
-function doit()
+function test()
{
- evaluateInWebInspector("frontend_testEvalGlobal", function() {
- dumpConsoleMessages();
- });
-}
+ InspectorTest.evaluateInConsole("foo", step1);
-function frontend_testEvalGlobal(layoutTestController)
-{
- layoutTestController.waitUntilDone();
- frontend_evaluateInConsole("foo", function() {
- frontend_evaluateInConsole("bar1", function() {
- layoutTestController.notifyDone();
- });
- });
+ function step1()
+ {
+ InspectorTest.evaluateInConsole("bar1", step2);
+ }
+
+ function step2()
+ {
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+ }
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that simple evaluations may be performed in the console on global object.
</p>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
-function doit()
+function test()
{
- evaluateInWebInspector("frontend_evaluateInConsole('1+2', function() {});", function() {
- dumpConsoleMessages();
- });
+ InspectorTest.evaluateInConsole("1+2", step2);
+
+ function step2()
+ {
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+ }
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that simple evaluations may be performed in the console.
</p>
Tests that console nicely formats HTML Collections and NodeLists.
console-format-collections.html:15[<select id="sel" name="sel">…</select>]
-console-format-collections.html:19[<script src="../http/tests/inspector/inspector-test.js"></script>, <script src="../http/tests/inspector/console-tests.js"></script>, <script>…</script>]
+console-format-collections.html:19[<script src="../http/tests/inspector/inspector-test2.js"></script>, <script src="../http/tests/inspector/console-test.js"></script>, <script>…</script>]
console-format-collections.html:23[<option value="1">one</option>, <option value="2">two</option>]
-console-format-collections.html:27[<html>…</html>, <head>…</head>, <script src="../http/tests/inspector/inspector-test.js"></script>, <script src="../http/tests/inspector/console-tests.js"></script>, <script>…</script>, <body onload="onload()">…</body>, <p>
+console-format-collections.html:27[<html>…</html>, <head>…</head>, <script src="../http/tests/inspector/inspector-test2.js"></script>, <script src="../http/tests/inspector/console-test.js"></script>, <script>…</script>, <body onload="onload()">…</body>, <p>
Tests that console nicely formats HTML Collections and NodeLists.
-</p>, <div style="display:none">…</div>, <form id="f">…</form>, <select id="sel" name="sel">…</select>, <option value="1">one</option>, <option value="2">two</option>, <input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">, <div id="output" style="white-space: pre; "></div>]
+</p>, <div style="display:none">…</div>, <form id="f">…</form>, <select id="sel" name="sel">…</select>, <option value="1">one</option>, <option value="2">two</option>, <input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">]
console-format-collections.html:31[<select id="sel" name="sel">…</select>, <input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">]
console-format-collections.html:35[<input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">]
console-format-collections.html:41[1, Array[2]]
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
-function doit()
+function onload()
{
var formElement = document.getElementById("f");
var selectElement = document.getElementById("sel");
arrayX.push(arrayY);
console.log(arrayX);
- dumpConsoleMessages();
+ runTest();
}
+function test()
+{
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+}
</script>
</head>
CONSOLE MESSAGE: line 20: test,test2,,,test4
CONSOLE MESSAGE: line 21: %o
CONSOLE MESSAGE: line 22: %O
-CONSOLE MESSAGE: line 60: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
-CONSOLE MESSAGE: line 61: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
-CONSOLE MESSAGE: line 60: /foo\\bar\sbaz/i
-CONSOLE MESSAGE: line 61: /foo\\bar\sbaz/i
-CONSOLE MESSAGE: line 60: test
-CONSOLE MESSAGE: line 61: test
-CONSOLE MESSAGE: line 60: test named "test"
-CONSOLE MESSAGE: line 61: test named "test"
-CONSOLE MESSAGE: line 60: Error:
-CONSOLE MESSAGE: line 61: Error:
-CONSOLE MESSAGE: line 60: [object HTMLBodyElement]
-CONSOLE MESSAGE: line 61: [object HTMLBodyElement]
-CONSOLE MESSAGE: line 60: function () { return 1; }
-CONSOLE MESSAGE: line 61: function () { return 1; }
-CONSOLE MESSAGE: line 60: function () {
+CONSOLE MESSAGE: line 53: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
+CONSOLE MESSAGE: line 54: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
+CONSOLE MESSAGE: line 53: /foo\\bar\sbaz/i
+CONSOLE MESSAGE: line 54: /foo\\bar\sbaz/i
+CONSOLE MESSAGE: line 53: test
+CONSOLE MESSAGE: line 54: test
+CONSOLE MESSAGE: line 53: test named "test"
+CONSOLE MESSAGE: line 54: test named "test"
+CONSOLE MESSAGE: line 53: Error:
+CONSOLE MESSAGE: line 54: Error:
+CONSOLE MESSAGE: line 53: [object HTMLBodyElement]
+CONSOLE MESSAGE: line 54: [object HTMLBodyElement]
+CONSOLE MESSAGE: line 53: function () { return 1; }
+CONSOLE MESSAGE: line 54: function () { return 1; }
+CONSOLE MESSAGE: line 53: function () {
return 2;
}
-CONSOLE MESSAGE: line 61: function () {
+CONSOLE MESSAGE: line 54: function () {
return 2;
}
-CONSOLE MESSAGE: line 60: 0.12
-CONSOLE MESSAGE: line 61: 0.12
-CONSOLE MESSAGE: line 60: http://webkit.org/
-CONSOLE MESSAGE: line 61: http://webkit.org/
-CONSOLE MESSAGE: line 60: null
-CONSOLE MESSAGE: line 61:
-CONSOLE MESSAGE: line 60: undefined
-CONSOLE MESSAGE: line 61:
-CONSOLE MESSAGE: line 60: [object Attr]
-CONSOLE MESSAGE: line 61: [object Attr]
-CONSOLE MESSAGE: line 60: [object Attr]
-CONSOLE MESSAGE: line 61: [object Attr]
-CONSOLE MESSAGE: line 60: [object Attr]
-CONSOLE MESSAGE: line 61: [object Attr]
+CONSOLE MESSAGE: line 53: 0.12
+CONSOLE MESSAGE: line 54: 0.12
+CONSOLE MESSAGE: line 53: http://webkit.org/
+CONSOLE MESSAGE: line 54: http://webkit.org/
+CONSOLE MESSAGE: line 53: null
+CONSOLE MESSAGE: line 54:
+CONSOLE MESSAGE: line 53: undefined
+CONSOLE MESSAGE: line 54:
+CONSOLE MESSAGE: line 53: [object Attr]
+CONSOLE MESSAGE: line 54: [object Attr]
+CONSOLE MESSAGE: line 53: [object Attr]
+CONSOLE MESSAGE: line 54: [object Attr]
+CONSOLE MESSAGE: line 53: [object Attr]
+CONSOLE MESSAGE: line 54: [object Attr]
Tests that console logging dumps proper messages.
console-format.html:12Message format number 1, 2 and 3.5
console-format.html:20["test", "test2", undefined, undefined, "test4"]
console-format.html:21["test", "test2", undefined, undefined, "test4"]
console-format.html:22Array[5]
-console-format.html:60/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
-console-format.html:61[/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i]
+console-format.html:53/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
+console-format.html:54[/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i]
+globals[0]
/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
-console-format.html:60/foo\\bar\sbaz/i
-console-format.html:61[/foo\\bar\sbaz/i]
+console-format.html:53/foo\\bar\sbaz/i
+console-format.html:54[/foo\\bar\sbaz/i]
+globals[1]
/foo\\bar\sbaz/i
-console-format.html:60test
-console-format.html:61["test"]
+console-format.html:53test
+console-format.html:54["test"]
+globals[2]
"test"
-console-format.html:60test named "test"
-console-format.html:61["test named "test""]
+console-format.html:53test named "test"
+console-format.html:54["test named "test""]
+globals[3]
"test named "test""
-console-format.html:60Error:
-console-format.html:61[Error: ]
+console-format.html:53Error:
+console-format.html:54[Error: ]
+globals[4]
Error:
-console-format.html:60<body onload="onload()">…</body>
-console-format.html:61[<body onload="onload()">…</body>]
+console-format.html:53<body onload="onload()">…</body>
+console-format.html:54[<body onload="onload()">…</body>]
+globals[5]
<body onload="onload()">…</body>
-console-format.html:60function () { return 1; }
-console-format.html:61[function () { return 1; }]
+console-format.html:53function () { return 1; }
+console-format.html:54[function () { return 1; }]
+globals[6]
function () { return 1; }
-console-format.html:60function () {
+console-format.html:53function () {
return 2;
}
-console-format.html:61[function () {
+console-format.html:54[function () {
return 2;
}]
+globals[7]
function () {
return 2;
}
-console-format.html:600.12
-console-format.html:61[0.12]
+console-format.html:530.12
+console-format.html:54[0.12]
+globals[8]
0.12
-console-format.html:60http://webkit.org/
-console-format.html:61["http://webkit.org/"]
+console-format.html:53http://webkit.org/
+console-format.html:54["http://webkit.org/"]
+globals[9]
"http://webkit.org/"
-console-format.html:60null
-console-format.html:61[null]
+console-format.html:53null
+console-format.html:54[null]
+globals[10]
null
-console-format.html:60undefined
-console-format.html:61[undefined]
+console-format.html:53undefined
+console-format.html:54[undefined]
+globals[11]
undefined
-console-format.html:60attr=""
-console-format.html:61[attr=""]
+console-format.html:53attr=""
+console-format.html:54[attr=""]
+globals[12]
attr=""
-console-format.html:60attr="value"
-console-format.html:61[attr="value"]
+console-format.html:53attr="value"
+console-format.html:54[attr="value"]
+globals[13]
attr="value"
-console-format.html:60id="x"
-console-format.html:61[id="x"]
+console-format.html:53id="x"
+console-format.html:54[id="x"]
+globals[14]
id="x"
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
// Global Values
var globals = [];
-function doit()
+function onload()
{
console.log('Message format number %i, %d and %f', 1, 2, 3.5);
console.log('Message %s for %s', 'format', 'string');
regex1, regex2, str, str2, error, node, func, multilinefunc, num, linkify,
null, undefined, valuelessAttribute, valuedAttribute, existingAttribute
];
- loopOverGlobals(0);
+
+ runTest();
}
-function loopOverGlobals(current)
+function log(current)
{
- function advance()
- {
- var next = current + 1;
- if (next == globals.length)
- dumpConsoleMessages();
- else
- loopOverGlobals(next);
- }
console.log(globals[current]);
console.log([globals[current]]);
- evaluateInWebInspector("frontend_evaluateGlobal", advance);
}
-// Frontend functions.
-
-function frontend_evaluateGlobal()
+function test()
{
- window.__next = window.__next || 0;
- var current = window.__next++;
- var expression = "globals[" + current + "]";
- frontend_evalExpression(expression);
-}
+ InspectorTest.evaluateInPage("globals.length", loopOverGlobals.bind(this, 0));
-function frontend_evalExpression(expression)
-{
- var self = WebInspector.console;
- function printResult(result)
+ function loopOverGlobals(current, total)
{
- self.addMessage(new WebInspector.ConsoleCommandResult(result, expression));
- }
+ function advance()
+ {
+ var next = current + 1;
+ if (next == total.description) {
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+ }
+ else
+ loopOverGlobals(next, total);
+ }
- self.evalInInspectedWindow(expression, "console", false, printResult);
+ InspectorTest.evaluateInPage("log(" + current + ")");
+ InspectorTest.runAfterPendingDispatches(evalInConsole);
+ function evalInConsole()
+ {
+ InspectorTest.evaluateInConsole("globals[" + current + "]");
+ InspectorTest.runAfterPendingDispatches(advance);
+ }
+ }
}
-
</script>
</head>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
console.log('log');
console.warn('warn');
console.error('error');
-function doit()
+function test()
{
- dumpConsoleMessages();
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that Web Inspector won't crash if some console have been logged by the time it's opening.
</p>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script src="resources/syntax-error.js"></script>
<script>
-function doit()
+function test()
{
- dumpConsoleMessages();
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that syntax errors are logged into console and doesn't cause browser crash.
</p>
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/console-tests2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
function Parent() { }
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
-function doit()
+function onload()
{
console.log('log');
console.debug('debug');
console.log(function f() { });
console.log([1, 2, 3]);
console.log(/regexp.*/);
- dumpConsoleMessagesWithClasses();
+
+ runTest();
}
+function test()
+{
+ InspectorTest.dumpConsoleMessagesWithClasses();
+ InspectorTest.completeTest();
+}
</script>
</head>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
}
a();
- dumpConsoleMessages();
}
-function doit()
+function doEvalSource()
{
setTimeout(function() {
eval("(" + evalSource + ")()//@ sourceURL=evalURL.js");
}, 0);
}
+function test()
+{
+ function callback()
+ {
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+ }
+ InspectorTest.evaluateInPage("doEvalSource()");
+ InspectorTest._addSniffer(WebInspector.ConsoleView.prototype, "addMessage", callback);
+}
+
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that when console.trace is called in eval'ed script ending
with //@ sourceURL=url it will dump a stack trace that will have
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/console-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
function b()
function a()
{
b();
- dumpConsoleMessages();
}
-function doit()
+function test()
{
- setTimeout(a, 0);
+ function callback()
+ {
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+ }
+ InspectorTest.evaluateInPage("setTimeout(a, 0)");
+ InspectorTest._addSniffer(WebInspector.ConsoleView.prototype, "addMessage", callback);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that console.trace dumps stack trace with source URLs and line numbers.
</p>
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/console-tests2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
function test()
{
InspectorTest.reloadPage(function() {
- InspectorTest.expandConsoleMessages();
InspectorTest.dumpConsoleMessages();
+ InspectorTest.expandConsoleMessages();
InspectorTest.completeTest();
});
}
-
function evalSource()
{
function b()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/console-tests2.js"></script>
+<script src="../http/tests/inspector/console-test.js"></script>
<script>
+
function test()
{
InspectorTest.reloadPage(function() {
});
}
-
window.addEventListener("load", function(e) {
function f() {
throw new Error("Exception in 'load' event listener.")
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script src="resources/syntax-error.js"></script>
<script>
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
Object.prototype.cyclicRef = Object.prototype;
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
var a = 1;
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
var globalVar = { b: 1 };
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function makeClosure(n) {
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function throwAnException()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function C()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
var test = function()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function d()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function d()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function f()
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction() {
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function appendElement(parentId, childId)
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="elements-tests2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
function test()
{
- function selectInspectedElement()
- {
- InspectorTest.selectElementAndRun("inspected", executeTest);
- }
- function executeTest()
+ InspectorTest.selectNodeWithId("inspected", step1);
+
+ function step1()
{
InspectorTest.addResult("Before style property removal:");
- InspectorTest.addResults(InspectorTest.getSelectedElementStyles(true));
+ InspectorTest.dumpSelectedElementStyles(true);
var treeElement;
var innerMapping = WebInspector.domAgent._idToDOMNode;
// Remove the "style" attribute altogether (not just clear its value).
editorElement.textContent = "";
editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
- InspectorTest.runAfterPendingDispatches(function() {
- InspectorTest.addResult("After style property removal:");
- InspectorTest.addResults(InspectorTest.getSelectedElementStyles(true));
- InspectorTest.completeTest();
- });
+ InspectorTest.runAfterPendingDispatches(step2);
}
- InspectorTest.expandDOMSubtreeAndRun(null, selectInspectedElement);
+ function step2()
+ {
+ InspectorTest.addResult("After style property removal:");
+ InspectorTest.dumpSelectedElementStyles(true);
+ InspectorTest.completeTest();
+ }
}
</script>
-Tests that the tooltip text for the image (below) is "215 × 174 pixels".
+Tests the tooltip for the image on hover.
PASSED, tooltip text is "215 × 174 pixels".
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-var EXPECTED_TOOLTIP_TEXT = "215 \xd7 174 pixels";
-function doit()
-{
- function callback(tooltipText)
- {
- if (!tooltipText)
- output("FAILED, tooltip text should have been \"" + EXPECTED_TOOLTIP_TEXT + "\". Was " + tooltipText + ".");
- else if (tooltipText == EXPECTED_TOOLTIP_TEXT)
- output("PASSED, tooltip text is \"" + EXPECTED_TOOLTIP_TEXT + "\".");
- else
- output("FAILED, tooltip text should have been \"" + EXPECTED_TOOLTIP_TEXT + "\". Was \"" + tooltipText + "\".");
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpTooltip", callback);
-}
-
-// Frontend functions.
-function frontend_dumpTooltip(testController)
+var test = function()
{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_dumpTooltipContinuation);
-}
+ InspectorTest.nodeWithId("image", step1);
-function frontend_dumpTooltipContinuation(testController)
-{
- function callback(tooltipText)
+ function step1(node)
{
- testController.notifyDone(tooltipText);
+ var treeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
+ treeElement._createTooltipForNode();
+ InspectorTest.runAfterPendingDispatches(step2.bind(this, treeElement));
}
- var innerMapping = WebInspector.domAgent._idToDOMNode;
- for (var nodeId in innerMapping) {
- if (innerMapping[nodeId].nodeName === "IMG") {
- var node = innerMapping[nodeId];
- var treeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
- treeElement._createTooltipForNode();
- testController.runAfterPendingDispatches(function() {
- testController.notifyDone(treeElement.tooltip);
- });
- break;
- }
+ function step2(treeElement)
+ {
+ const EXPECTED_TOOLTIP_TEXT = "215 \xd7 174 pixels";
+
+ var tooltipText = treeElement.tooltip;
+ if (tooltipText === EXPECTED_TOOLTIP_TEXT)
+ InspectorTest.addResult("PASSED, tooltip text is \"" + EXPECTED_TOOLTIP_TEXT + "\".");
+ else
+ InspectorTest.addResult("FAILED, tooltip text should have been \"" + EXPECTED_TOOLTIP_TEXT + "\". Was \"" + tooltipText + "\".");
+ InspectorTest.completeTest();
}
}
+
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
-Tests that the tooltip text for the image (below) is "<script>document.write(EXPECTED_TOOLTIP_TEXT)</script>".
+Tests the tooltip for the image on hover.
</p>
-<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAACuCAIAAAAqMg/rAAAAAXNSR0IArs4c6QAAAU9JREFUeNrt0jERAAAIxDDAv+dHAxNLIqHXTlLwaiTAheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSFEuBCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLoSDBZXqBFnkRyeqAAAAAElFTkSuQmCC"/>
+<img id="image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAACuCAIAAAAqMg/rAAAAAXNSR0IArs4c6QAAAU9JREFUeNrt0jERAAAIxDDAv+dHAxNLIqHXTlLwaiTAheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSFEuBCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLoSDBZXqBFnkRyeqAAAAAElFTkSuQmCC"/>
</body>
</html>
10
Tests that src and href element targets are rewritten properly.
+=========== Loaded 5 children ===========
-<div id="data">/
+<html>
+<head>…
+</head>
+<body onload="runTest()">
+<div id="data">
+<div id="id1">1
+</div>
+<div id="id2">2
+</div>
+<div id="id3">3
+</div>
+<div id="id4">4
+</div>
+<div id="id5">5
+</div>Show All Nodes (5 More)
+</div>
+<p>Tests that src and href element targets are rewritten properly.
+</p>
+</body>
+</html>
+=========== Modified children ===========
+
+<html>
+<head>…
+</head>
+<body onload="runTest()">
+<div id="data">
<a>
</a>
<div id="id1">1
<div id="id5">5
</div>Show All Nodes (6 More)
</div>
-<div id="data">/
+<p>Tests that src and href element targets are rewritten properly.
+</p>
+<div class="output" style="white-space: pre; ">…
+</div>
+<div class="output" style="white-space: pre; ">…
+</div>
+</body>
+</html>
+=========== Loaded all children ===========
+
+<html>
+<head>…
+</head>
+<body onload="runTest()">
+<div id="data">
<a>
</a>
<div id="id1">1
<a>
</a>
</div>
+<p>Tests that src and href element targets are rewritten properly.
+</p>
+<div class="output" style="white-space: pre; ">…
+</div>
+<div class="output" style="white-space: pre; ">…
+</div>
+<div class="output" style="white-space: pre; ">…
+</div>
+<div class="output" style="white-space: pre; ">…
+</div>
+</body>
+</html>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function insertNode()
{
- function preOutput(result)
- {
- var output = document.getElementById("outputPre");
- output.textContent += result.replace(/\u200b/g, "").replace(/\n/g, "").replace(/</g, "\n<");
- }
+ var dataElement = document.getElementById("data");
+ dataElement.appendChild(document.createElement("a"));
+ dataElement.removeChild(document.getElementById("id2"));
+ var aElement = document.createElement("a");
+ dataElement.insertBefore(aElement, document.getElementById("id1"));
+ dataElement.appendChild(aElement);
+ dataElement.insertBefore(aElement, document.getElementById("id1"));
+}
- function nodeDumpAfterCallback(dump)
- {
- preOutput(dump);
- notifyDone();
- }
+function test()
+{
+ var dataTreeElement;
- function showAllCallback(result)
- {
- if (result) {
- preOutput(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpNode", nodeDumpAfterCallback);
- }
+ InspectorTest.nodeWithId("data", step1);
- function nodeDumpBeforeCallback(dump)
+ function step1(node)
{
- preOutput(dump);
- evaluateInWebInspector("frontend_showAll", showAllCallback);
+ dataTreeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
+ dataTreeElement._expandedChildrenLimit = 5;
+ dataTreeElement.reveal();
+ dataTreeElement.expand();
+ InspectorTest.runAfterPendingDispatches(step2);
}
- function nodeExpandedCallback(result)
+ function step2()
{
- if (result) {
- preOutput(result);
- notifyDone();
- }
- var dataElement = document.getElementById("data");
- dataElement.appendChild(document.createElement("a"));
- dataElement.removeChild(document.getElementById("id2"));
- var aElement = document.createElement("a");
- dataElement.insertBefore(aElement, document.getElementById("id1"));
- dataElement.appendChild(aElement);
- dataElement.insertBefore(aElement, document.getElementById("id1"));
- evaluateInWebInspector("frontend_dumpNode", nodeDumpBeforeCallback);
+ InspectorTest.addResult("=========== Loaded 5 children ===========");
+ InspectorTest.dumpElementsTree();
+ InspectorTest.evaluateInPage("insertNode()", step3);
}
- function domLoadedCallback(result)
+ function step3()
{
- if (result) {
- preOutput(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_revealAndExpandDataNodeInElementsPanel", nodeExpandedCallback);
+ InspectorTest.runAfterPendingDispatches(step4);
}
- evaluateInWebInspector("frontend_loadDOM", domLoadedCallback);
-}
-
-// Frontend functions.
-
-function frontend_showAll(testController)
-{
- try {
- var dataDivTreeElement = frontend_getDataTreeElement();
- if (!dataDivTreeElement) {
- testController.notifyDone("show_All: No data div tree element found");
- return;
- }
- window.__oldUpdateChildren = WebInspector.ElementsTreeElement.prototype._updateChildren;
- window.__newUpdateChildren = function() {
- window.__oldUpdateChildren.apply(this, arguments);
- WebInspector.ElementsTreeElement.prototype._updateChildren = window.__oldUpdateChildren;
- testController.notifyDone("");
- }
- WebInspector.ElementsTreeElement.prototype._updateChildren = window.__newUpdateChildren;
-
- WebInspector.ElementsTreeElement.prototype.handleLoadAllChildren.call(dataDivTreeElement);
- testController.waitUntilDone();
- } catch(e) {
- testController.notifyDone("showAll: " + e);
+ function step4()
+ {
+ InspectorTest.addResult("=========== Modified children ===========");
+ InspectorTest.dumpElementsTree();
+ dataTreeElement.handleLoadAllChildren();
+ InspectorTest.runAfterPendingDispatches(step5);
}
-}
-function frontend_dumpNode(testController)
-{
- testController.waitUntilDone();
- function dumpFunction()
+ function step5()
{
- var dataDivTreeElement = frontend_getDataTreeElement();
- if (!dataDivTreeElement) {
- testController.notifyDone("dumpNode: No data div tree element found");
- return;
- }
-
- var liContent = dataDivTreeElement.listItemElement ? dataDivTreeElement.listItemElement.textContent : "{EMPTY}";
- var childrenContent = dataDivTreeElement.childrenListElement ? dataDivTreeElement.childrenListElement.textContent : "{EMPTY}";
- testController.notifyDone(liContent + "/" + childrenContent);
- }
- // Ensure all asynchronous updates to the Elements tree outline are processed before dumping.
- setTimeout(dumpFunction, 0);
-}
-
-function frontend_revealAndExpandDataNodeInElementsPanel(testController)
-{
- var dataDivTreeElement = frontend_getDataTreeElement();
- if (!dataDivTreeElement) {
- testController.notifyDone("No data div tree element found");
- return;
- }
-
- try {
- dataDivTreeElement._expandedChildrenLimit = 5;
- dataDivTreeElement.reveal();
- dataDivTreeElement.expand();
- testController.notifyDone("");
- } catch(e) {
- testController.notifyDone("expandNode: " + e);
- }
-}
-
-function frontend_loadDOM(testController)
-{
- testController.waitUntilDone();
- // Need test to be async to expand whole the tree first.
- try {
- frontend_expandDOMSubtreeAndRun(testController, null, testController.notifyDone.bind(testController, ""));
- } catch(e) {
- testController.notifyDone("loadDOM: " + e);
- }
-}
-
-function frontend_getDataTreeElement()
-{
- var node = frontend_getDataDOMElement();
- if (!node)
- return null;
- return WebInspector.panels.elements.treeOutline.findTreeElement(node);
-}
-
-
-function frontend_getDataDOMElement()
-{
- var innerMapping = WebInspector.domAgent._idToDOMNode;
-
- for (var nodeId in innerMapping) {
- var node = innerMapping[nodeId];
- if (node.nodeName === "DIV" && node.getAttribute("id") === "data")
- return node;
+ InspectorTest.addResult("=========== Loaded all children ===========");
+ InspectorTest.dumpElementsTree();
+ InspectorTest.completeTest();
}
- return null;
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<div id="data">
<div id="id1">1</div>
<div id="id2">2</div>
<p>
Tests that src and href element targets are rewritten properly.
</p>
-<pre id="outputPre">
-</pre>
</body>
</html>
Tests that src and href element targets are rewritten properly.
-[,bogusSheet1.css]
-[LayoutTests,inspector,bogusSheet2.css]
-[tests,inspector,inspector-test.js]
-[LayoutTests,inspector,elements-tests.js]
+,bogusSheet1.css
+LayoutTests,inspector,bogusSheet2.css
+tests,inspector,inspector-test2.js
+tests,inspector,elements-test.js
<head>
<link rel="stylesheet" src="/bogusSheet1.css">
<link rel="stylesheet" src="bogusSheet2.css">
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
- {
- for (var i = 0; i < result.length; ++i)
- output("[" + result[i] + "]");
- notifyDone();
- }
- evaluateInWebInspector("frontend_testRewriteHrefs", callback);
-}
+ InspectorTest.pushAllDOM(step1);
-
-// Frontend functions.
-
-function frontend_testRewriteHrefs(testController)
-{
- testController.waitUntilDone();
- // Need test to be async to expand whole the tree first.
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_testRewriteHrefsContinuation);
-}
-
-function frontend_testRewriteHrefsContinuation(testController)
-{
- var innerMapping = WebInspector.domAgent._idToDOMNode;
- var result = [];
-
- for (var nodeId in innerMapping) {
- var node = innerMapping[nodeId];
- if (node.nodeName === "LINK" || node.nodeName === "SCRIPT") {
- var segments = [];
- var href = WebInspector.resourceURLForRelatedNode(node, node.getAttribute("src") || node.getAttribute("href"));
- if (!href) {
- segments.push("<empty>");
- continue;
+ function step1()
+ {
+ var innerMapping = WebInspector.domAgent._idToDOMNode;
+
+ for (var nodeId in innerMapping) {
+ var node = innerMapping[nodeId];
+ if (node.nodeName === "LINK" || node.nodeName === "SCRIPT") {
+ var segments = [];
+ var href = WebInspector.resourceURLForRelatedNode(node, node.getAttribute("src") || node.getAttribute("href"));
+ if (!href) {
+ segments.push("<empty>");
+ continue;
+ }
+ var parsedURL = href.asParsedURL();
+ if (!parsedURL)
+ testController.notifyDone("FAIL: no URL match for <" + href + ">");
+ var split = parsedURL.path.split("/");
+ for (var i = split.length - 1, j = 0; j < 3 && i >= 0; --i, ++j)
+ segments.push(split[i]);
+ InspectorTest.addResult(segments.reverse());
}
- var parsedURL = href.asParsedURL();
- if (!parsedURL)
- testController.notifyDone("FAIL: no URL match for <" + href + ">");
- var split = parsedURL.path.split("/");
- for (var i = split.length - 1, j = 0; j < 3 && i >= 0; --i, ++j)
- segments.push(split[i]);
- result.push(segments.reverse());
}
+ InspectorTest.completeTest();
}
- testController.notifyDone(result);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that src and href element targets are rewritten properly.
</p>
Tests that elements panel preserves selected node on page refresh.
+Page reloaded.
Selected element should be 'P', was: 'P'
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
+ InspectorTest.selectNodeWithId("test-topic", step1);
+
+ function step1()
{
- if (result === "reload")
- window.location.reload();
- else {
- output("Selected element should be 'P', was: '" + result + "'");
- notifyDone();
- }
+ InspectorTest.reloadPage(step2);
+ }
+
+ function step2()
+ {
+ InspectorTest.runAfterPendingDispatches(step3);
}
- evaluateInWebInspector("frontend_selectElement", callback);
-}
-
-// Frontend functions.
-function frontend_selectElement(testController)
-{
- if (window.refreshCalled) {
+ function step3()
+ {
// We should have "test-topic" element selected after refresh.
var selectedElement = WebInspector.panels.elements.treeOutline.selectedTreeElement;
- return selectedElement ? selectedElement.representedObject.nodeName : "null";
- } else {
- // Select the "test-topic" element.
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectElementContinuation);
- }
-}
-
-function frontend_selectElementContinuation(testController)
-{
- var node = frontend_nodeForId("test-topic");
- if (node) {
- WebInspector.panels.elements.treeOutline.revealAndSelectNode(node);
- window.refreshCalled = true;
- testController.notifyDone("reload");
- return;
+ var nodeName = selectedElement ? selectedElement.representedObject.nodeName : "null";
+ InspectorTest.addResult("Selected element should be 'P', was: '" + nodeName + "'");
+ InspectorTest.completeTest();
}
- testController.notifyDone("FAIL");
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p id="test-topic">
Tests that elements panel preserves selected node on page refresh.
</p>
Tests that elements panel shows dom tree structure.
+Text
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
-<head>…
+<head>
+<script src="../http/tests/inspector/inspector-test2.js">
+</script>
+<script src="../http/tests/inspector/elements-test.js">
+</script>
+<script>function test(){ InspectorTest.pushAllDOM(step1); function step1() { InspectorTest.dumpLoadedDOM(); InspectorTest.completeTest(); }}
+</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>Tests that elements panel shows dom tree structure.
</p>
-<pre id="outputPre">
-</pre>
-<div id="output" style="white-space: pre; ">
+<div id="level1">
+<div id="level2">"Text "
+<div id="level3">
+</div>
+</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
+ InspectorTest.pushAllDOM(step1);
+
+ function step1()
{
- var output = document.getElementById("outputPre");
- output.textContent = result.replace(/\u200b/g, "").replace(/\n/g, "").replace(/</g, "\n<");
- notifyDone();
+ InspectorTest.dumpLoadedDOM();
+ InspectorTest.completeTest();
}
- evaluateInWebInspector("frontend_dumpAllElements", callback);
-}
-
-
-// Frontend functions.
-
-function frontend_dumpAllElements(testController)
-{
- testController.waitUntilDone();
- // Need test to be async to expand whole the tree first.
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_reportTextContent);
-}
-
-function frontend_reportTextContent(testController)
-{
- testController.notifyDone(WebInspector.panels.elements.treeOutline.element.textContent);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that elements panel shows dom tree structure.
</p>
-<pre id="outputPre">
-</pre>
+<div id="level1">
+ <div id="level2">Text
+ <div id="level3"></div>
+ </div>
+</div>
</body>
</html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="resources/elements-panel-styles.css">
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
+ InspectorTest.selectNodeWithId("foo", step1);
+
+ function step1()
{
- dumpArray(result);
- notifyDone();
+ InspectorTest.dumpSelectedElementStyles(false, false);
+ InspectorTest.completeTest();
}
- evaluateInWebInspector("frontend_dumpStyles", callback);
-}
-
-// Frontend functions.
-
-function frontend_dumpStyles(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectElementContinuation);
}
-function frontend_selectElementContinuation(testController)
-{
- frontend_selectElementAndRun(testController, "foo", frontend_dumpSelectedElementStyles);
-}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that elements panel shows proper styles in the sidebar panel.
</p>
Next line
-application/xhtml+xml
+
<HTML xmlns="http://www.w3.org/1999/xhtml">
-<Head>…
+<Head>
+<script src="../http/tests/inspector/inspector-test2.js">
+</script>
+<script src="../http/tests/inspector/elements-test.js">
+</script>
+<script>
+<![CDATA[function test(){ InspectorTest.pushAllDOM(step1); function step1() { InspectorTest.dumpLoadedDOM(); InspectorTest.completeTest(); }}]]>
+</script>
</Head>
-<body onload="onload()">
+<body onload="runTest()">
<p>"Tests that elements panel shows XML dom tree structure with closing tags for all elements."
</p>
<hr>
<![CDATA[ CData Content ]]>
<img alt="Random Image">
</img>
-<pre id="outputPre">
-</pre>
-<div id="output" style="white-space: pre; ">
-</div>
</body>
</HTML>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<Head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
<![CDATA[
-function doit()
+function test()
{
- function preOutput(result)
- {
- var output = document.getElementById("outputPre");
- output.textContent = result.replace(/\u200b/g, "").replace(/\n/g, "").replace(/</g, "\n<");
- }
-
- function nodeDumpCallback(dump)
- {
- preOutput(dump);
- notifyDone();
- }
-
- function nodeExpandedCallback(result)
- {
- if (result) {
- preOutput(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpAllElements", nodeDumpCallback);
- }
+ InspectorTest.pushAllDOM(step1);
- function domLoadedCallback(result)
+ function step1()
{
- if (result) {
- preOutput(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_expandNodes", nodeExpandedCallback);
+ InspectorTest.dumpLoadedDOM();
+ InspectorTest.completeTest();
}
-
- evaluateInWebInspector("frontend_loadDOM", domLoadedCallback);
-}
-
-
-// Frontend functions.
-
-function frontend_dumpAllElements(testController)
-{
- testController.waitUntilDone();
- // Need test to be async to expand whole the tree first.
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_reportMimeTypeAndContent);
}
-
-function frontend_reportMimeTypeAndContent(testController)
-{
- testController.notifyDone(WebInspector.mainResource.mimeType + " " + WebInspector.panels.elements.treeOutline.element.textContent);
-}
-
-function frontend_expandNodes(testController)
-{
- try {
- var innerMapping = WebInspector.domAgent._idToDOMNode;
- var treeElement = false;
- var result = "";
-
- for (var nodeId in innerMapping) {
- var node = innerMapping[nodeId];
- result += node.nodeName + " ";
- if (node.nodeName === "p") {
- treeElement = WebInspector.panels.elements.treeOutline.createTreeElementFor(node);
- if (treeElement) {
- treeElement.reveal();
- treeElement.expand();
- }
- }
- }
-
- if (!treeElement) {
- if (treeElement === false)
- testController.notifyDone("No 'p' DOM element found");
- else
- testController.notifyDone("'p' tree element could not be created");
-
- return;
- }
-
- testController.notifyDone("");
- } catch(e) {
- testController.notifyDone("expandNode: " + e);
- }
-}
-
-function frontend_loadDOM(testController)
-{
- testController.waitUntilDone();
- // Need test to be async to expand whole the tree first.
- try {
- frontend_expandDOMSubtreeAndRun(testController, null, testController.notifyDone.bind(testController, ""));
- } catch(e) {
- testController.notifyDone("loadDOM: " + e);
- }
-}
-
]]>
</script>
</Head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that elements panel shows XML dom tree structure with closing tags for all elements.
</p>
<img alt="Random Image"></img>
-<pre id="outputPre">
-</pre>
-
</body>
</HTML>
+++ /dev/null
-// Frontend functions.
-
-function frontend_expandDOMSubtree(node)
-{
- node = node || WebInspector.domAgent.document;
- function processChildren(children)
- {
- for (var i = 0; children && i < children.length; ++i)
- frontend_expandDOMSubtree(children[i]);
- }
- WebInspector.domAgent.getChildNodesAsync(node, processChildren);
-}
-
-function frontend_expandDOMSubtreeAndRun(testController, node, continuation)
-{
- frontend_expandDOMSubtree(node);
- testController.runAfterPendingDispatches(continuation.bind(this, testController));
-}
-
-function frontend_nodeForId(idValue)
-{
- var innerMapping = WebInspector.domAgent._idToDOMNode;
- for (var nodeId in innerMapping) {
- var node = innerMapping[nodeId];
- if (node.getAttribute("id") === idValue)
- return node;
- }
- return null;
-}
-
-function frontend_selectElementAndRun(testController, idValue, continuation)
-{
- var node = frontend_nodeForId(idValue);
- if (!node) {
- testController.notifyDone("No node found.");
- return;
- }
-
- WebInspector.updateFocusedNode(node.id);
- testController.runAfterPendingDispatches(continuation.bind(this, testController));
-}
-
-function frontend_dumpSelectedElementStyles(testController)
-{
- testController.notifyDone(frontend_getSelectedElementStyles(false));
-}
-
-function frontend_getSelectedElementStyles(excludeComputed, excludeMatched)
-{
- var result = [];
- var styleSections = WebInspector.panels.elements.sidebarPanes.styles.sections;
- for (var pseudoId in styleSections) {
- var pseudoName = WebInspector.StylesSidebarPane.PseudoIdNames[pseudoId];
- var sections = styleSections[pseudoId];
- for (var i = 0; i < sections.length; ++i) {
- var section = sections[i];
- if (section.computedStyle && excludeComputed)
- continue;
- if (section.rule && excludeMatched)
- continue;
- if (section.element.previousSibling && section.element.previousSibling.className === "styles-sidebar-separator")
- result.push("======== " + section.element.previousSibling.textContent + " ========");
- result.push((section.expanded ? "[expanded] " : "[collapsed] ") + section.titleElement.textContent + " (" + section.subtitleAsTextForTest + ")");
- section.expand();
- frontend_dumpStyleTreeOutline(section.propertiesTreeOutline, result);
- result.push("");
- }
- result.push("");
- }
- return result;
-}
-
-function frontend_getElementStylePropertyTreeItem(propertyName)
-{
- var styleSections = WebInspector.panels.elements.sidebarPanes.styles.sections[0];
- var elementStyleSection = styleSections[1];
- var outline = elementStyleSection.propertiesTreeOutline;
- for (var i = 0; i < outline.children.length; ++i) {
- var treeItem = outline.children[i];
- if (treeItem.name === propertyName)
- return treeItem;
- }
- return null;
-}
-
-function frontend_dumpStyleTreeOutline(treeItem, result)
-{
- var children = treeItem.children;
- for (var i = 0; i < children.length; ++i)
- frontend_dumpStyleTreeItem(children[i], result, "");
-}
-
-function frontend_dumpStyleTreeItem(treeItem, result, prefix)
-{
- // Filter out width and height properties in order to minimize
- // potential diffs.
- if (!treeItem.listItemElement.textContent.indexOf("width") ||
- !treeItem.listItemElement.textContent.indexOf("height"))
- return;
-
- if (treeItem.listItemElement.hasStyleClass("inherited"))
- return;
- var typePrefix = "";
- if (treeItem.listItemElement.hasStyleClass("overloaded"))
- typePrefix += "/-- overloaded --/ ";
- if (treeItem.listItemElement.hasStyleClass("disabled"))
- typePrefix += "/-- disabled --/ ";
- var textContent = treeItem.listItemElement.textContent;
-
- // Add non-selectable url text.
- var textData = treeItem.listItemElement.querySelector("[data-uncopyable]");
- if (textData)
- textContent += textData.getAttribute("data-uncopyable");
-
- result.push(prefix + typePrefix + textContent);
- treeItem.expand();
- var children = treeItem.children;
- for (var i = 0; children && i < children.length; ++i)
- frontend_dumpStyleTreeItem(children[i], result, prefix + " ");
-}
+++ /dev/null
-var initialize_ElementTest = function() {
-
-InspectorTest.expandDOMSubtree = function(node)
-{
- node = node || WebInspector.domAgent.document;
- function processChildren(children)
- {
- for (var i = 0; children && i < children.length; ++i)
- InspectorTest.expandDOMSubtree(children[i]);
- }
- WebInspector.domAgent.getChildNodesAsync(node, processChildren);
-};
-
-InspectorTest.expandDOMSubtreeAndRun = function(node, callback)
-{
- InspectorTest.expandDOMSubtree(node);
- InspectorTest.runAfterPendingDispatches(callback);
-};
-
-InspectorTest.nodeForId = function(idValue)
-{
- var innerMapping = WebInspector.domAgent._idToDOMNode;
- for (var nodeId in innerMapping) {
- var node = innerMapping[nodeId];
- if (node.getAttribute("id") === idValue)
- return node;
- }
- return null;
-};
-
-InspectorTest.selectElementAndRun = function(idValue, callback)
-{
- var node = InspectorTest.nodeForId(idValue);
- if (node)
- WebInspector.updateFocusedNode(node.id);
- InspectorTest.runAfterPendingDispatches(callback);
-};
-
-InspectorTest.dumpSelectedElementStyles = function()
-{
- InspectorTest.addResults(InspectorTest.getSelectedElementStyles(false));
-};
-
-InspectorTest.getSelectedElementStyles = function(excludeComputed, excludeMatched)
-{
- var result = [];
- var styleSections = WebInspector.panels.elements.sidebarPanes.styles.sections;
- for (var pseudoId in styleSections) {
- var pseudoName = WebInspector.StylesSidebarPane.PseudoIdNames[pseudoId];
- var sections = styleSections[pseudoId];
- for (var i = 0; i < sections.length; ++i) {
- var section = sections[i];
- if (section.computedStyle && excludeComputed)
- continue;
- if (section.rule && excludeMatched)
- continue;
- if (section.element.previousSibling && section.element.previousSibling.className === "styles-sidebar-separator")
- result.push("======== " + section.element.previousSibling.textContent + " ========");
- result.push((section.expanded ? "[expanded] " : "[collapsed] ") + section.titleElement.textContent + " (" + section.subtitleAsTextForTest + ")");
- section.expand();
- InspectorTest.dumpStyleTreeOutline(section.propertiesTreeOutline, result);
- result.push("");
- }
- result.push("");
- }
- return result;
-};
-
-// FIXME: this returns the first tree item found (may fail for same-named properties in a style).
-InspectorTest.getElementStylePropertyTreeItem = function(propertyName)
-{
- var styleSections = WebInspector.panels.elements.sidebarPanes.styles.sections[0];
- var elementStyleSection = styleSections[1];
- var outline = elementStyleSection.propertiesTreeOutline;
- for (var i = 0; i < outline.children.length; ++i) {
- var treeItem = outline.children[i];
- if (treeItem.name === propertyName)
- return treeItem;
- }
- return null;
-};
-
-InspectorTest.dumpStyleTreeOutline = function(treeItem, result)
-{
- var children = treeItem.children;
- for (var i = 0; i < children.length; ++i)
- InspectorTest.dumpStyleTreeItem(children[i], result, "");
-};
-
-InspectorTest.dumpStyleTreeItem = function(treeItem, result, prefix)
-{
- // Filter out width and height properties in order to minimize
- // potential diffs.
- if (!treeItem.listItemElement.textContent.indexOf("width") ||
- !treeItem.listItemElement.textContent.indexOf("height"))
- return;
-
- if (treeItem.listItemElement.hasStyleClass("inherited"))
- return;
- var typePrefix = "";
- if (treeItem.listItemElement.hasStyleClass("overloaded"))
- typePrefix += "/-- overloaded --/ ";
- if (treeItem.listItemElement.hasStyleClass("disabled"))
- typePrefix += "/-- disabled --/ ";
- var textContent = treeItem.listItemElement.textContent;
-
- // Add non-selectable url text.
- var textData = treeItem.listItemElement.querySelector("[data-uncopyable]");
- if (textData)
- textContent += textData.getAttribute("data-uncopyable");
-
- result.push(prefix + typePrefix + textContent);
- treeItem.expand();
- var children = treeItem.children;
- for (var i = 0; children && i < children.length; ++i)
- InspectorTest.dumpStyleTreeItem(children[i], result, prefix + " ");
-};
-
-};
body {
- font-size: 12px;
+ font-size: 12px;
}
#container {
- font-family: serif;
- font-size: 14px;
+ font-family: serif;
+ font-size: 14px;
}
.foo {
- color: black;
- margin: 10px 0 2px;
- border-radius: 5px;
+ color: black;
+ margin: 10px 0 2px;
+ border-radius: 5px;
}
.foo, .foo::before {
- content: "[before Foo]";
- color: blue;
+ content: "[before Foo]";
+ color: blue;
}
.foo::before {
- color: red;
+ color: red;
}
.foo::after {
- content: "[after Foo]";
- color: green;
+ content: "[after Foo]";
+ color: green;
}
.foo::after {
- font-family: courier;
- content: "[after Foo 2]";
+ font-family: courier;
+ content: "[after Foo 2]";
}
.foo {
</script>
</head>
-<body onload="iframeOnload()">
+<body onload="iframeOnload()" id="iframeBody">
</body>
</html>
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="../http/tests/inspector/debugger-test2.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
<script>
function populateDOMStorage()
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
- {
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_runTest", callback);
-}
+ InspectorTest.selectNodeWithId("inspected", step1);
-// Frontend functions.
+ var treeElement;
-function frontend_runTest(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectInspectedElement);
-}
-
-function frontend_selectInspectedElement(testController)
-{
- frontend_selectElementAndRun(testController, "inspected", frontend_dumpInspectedStyle);
-}
+ function step1()
+ {
+ InspectorTest.addResult("Before append:");
+ InspectorTest.dumpSelectedElementStyles(true);
-function frontend_dumpInspectedStyle(testController)
-{
- testController.results.push("Before append:");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(true));
+ var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1];
+ section.expand();
- var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1];
- section.expand();
- var treeElement = section.addNewBlankProperty();
- var enterKeyDown = frontend_createKeyEvent("Enter");
+ // Create and increment.
+ treeElement = section.addNewBlankProperty();
+ treeElement.startEditing();
+ treeElement.nameElement.textContent = "margin-left";
+ treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ treeElement.valueElement.textContent = "1px";
+ treeElement.valueElement.firstChild.select();
+ treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up"));
+ InspectorTest.runAfterPendingDispatches(step2);
+ }
- function removeEmpty()
+ function step2()
{
- window.getSelection().anchorNode.dispatchEvent(enterKeyDown);
- frontend_dumpResults(testController);
+ // Increment again.
+ treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up"));
+ InspectorTest.runAfterPendingDispatches(step3);
}
- function commit()
+ function step3()
{
- treeElement.valueElement.dispatchEvent(enterKeyDown);
- testController.runAfterPendingDispatches(removeEmpty.bind(this));
+ // Commit.
+ treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ InspectorTest.selectNodeWithId("other", step4);
}
- function incrementAgain()
+ function step4()
{
- treeElement.valueElement.dispatchEvent(frontend_createKeyEvent("Up"));
- testController.runAfterPendingDispatches(commit.bind(this));
+ InspectorTest.selectNodeWithId("inspected", step5);
}
- treeElement.startEditing();
- treeElement.nameElement.textContent = "margin-left";
- treeElement.nameElement.dispatchEvent(enterKeyDown);
- treeElement.valueElement.textContent = "1px";
- treeElement.valueElement.firstChild.select();
- treeElement.valueElement.dispatchEvent(frontend_createKeyEvent("Up"));
- testController.runAfterPendingDispatches(incrementAgain.bind(this));
-}
-
-function frontend_dumpResults(testController)
-{
- function reportResults()
+ function step5()
{
- testController.results.push("After append:");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(true));
- testController.notifyDone(testController.results);
+ InspectorTest.addResult("After append:");
+ InspectorTest.dumpSelectedElementStyles(true);
+ InspectorTest.completeTest();
}
- frontend_selectElementAndRun(testController, "inspected", reportResults);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that adding a new blank property works.
</p>
<div id="inspected" style="font-size: 12px">Text</div>
+<div id="other"></div>
</body>
</html>
}
</style>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
- {
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_runTest", callback);
-}
+ InspectorTest.selectNodeWithId("id1", step1);
-// Frontend functions.
-
-function frontend_runTest(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectNestedElement);
-}
-
-function frontend_selectNestedElement(testController)
-{
- frontend_selectElementAndRun(testController, "id1", frontend_dumpID1Style);
-}
+ function step1()
+ {
+ InspectorTest.addResult("==== Computed style for ID1 ====");
+ InspectorTest.dumpSelectedElementStyles(false, true);
-function frontend_dumpID1Style(testController)
-{
- testController.results.push("==== Computed style for ID1 ====");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(false, true));
- frontend_selectElementAndRun(testController, "id2", frontend_dumpID2Style);
-}
+ InspectorTest.selectNodeWithId("id2", step2);
+ }
-function frontend_dumpID2Style(testController)
-{
- testController.results.push("==== Computed style for ID2 ====");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(false, true));
- testController.notifyDone();
+ function step2()
+ {
+ InspectorTest.addResult("==== Computed style for ID2 ====");
+ InspectorTest.dumpSelectedElementStyles(false, true);
+ InspectorTest.completeTest();
+ }
}
-
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that computed styles expand and allow tracing to style rules.
</p>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
- {
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_runTest", callback);
-}
-
-// Frontend functions.
-
-function frontend_runTest(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectNestedElement);
-}
-function frontend_selectNestedElement(testController)
-{
- frontend_selectElementAndRun(testController, "nested", frontend_dumpNestedStyle);
-}
+ InspectorTest.selectNodeWithId("nested", step1);
-function frontend_dumpNestedStyle(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- testController.results.push("Before disable");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(true));
+ function step1()
+ {
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
+ InspectorTest.addResult("Before disable");
+ InspectorTest.dumpSelectedElementStyles(true);
- frontend_selectElementAndRun(testController, "container", frontend_disableContainerStyle);
-}
+ InspectorTest.selectNodeWithId("container", step2);
+ }
-function frontend_disableContainerStyle(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- treeItem.toggleEnabled({ target: { checked: false } });
- testController.runAfterPendingDispatches(frontend_dumpResults.bind(this, testController));
-}
+ function step2()
+ {
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
+ treeItem.toggleEnabled({ target: { checked: false } });
+ InspectorTest.selectNodeWithId("nested", step3);
+ }
-function frontend_dumpResults(testController)
-{
- function reportResults()
+ function step3()
{
- testController.results.push("After disable:");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(true));
- testController.notifyDone(testController.results);
+ InspectorTest.addResult("After disable:");
+ InspectorTest.dumpSelectedElementStyles(true);
+ InspectorTest.completeTest();
}
- frontend_selectElementAndRun(testController, "nested", reportResults);
}
-
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that disabling inherited style property does not break further style inspection.
</p>
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="elements-tests2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
function test()
{
- function selectContainerElementContinuation()
- {
- InspectorTest.selectElementAndRun("container", disableContainerStyle);
- }
+ InspectorTest.selectNodeWithId("container", step1);
- function disableContainerStyle()
+ function step1()
{
- var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
InspectorTest.addResult("Before disable");
- InspectorTest.addResults(InspectorTest.getSelectedElementStyles(true, true));
+ InspectorTest.dumpSelectedElementStyles(true, true);
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
treeItem.toggleEnabled({ target: { checked: false } });
- InspectorTest.runAfterPendingDispatches(changeContainerStyle);
+ InspectorTest.runAfterPendingDispatches(step2);
}
- function changeContainerStyle()
+ function step2()
{
- var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
InspectorTest.addResult("After disable");
- InspectorTest.addResults(InspectorTest.getSelectedElementStyles(true, true));
+ InspectorTest.dumpSelectedElementStyles(true, true);
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
treeItem.applyStyleText("color: green", true);
- InspectorTest.runAfterPendingDispatches(dumpResults);
+ InspectorTest.runAfterPendingDispatches(step3);
}
- function dumpResults()
+ function step3()
{
InspectorTest.addResult("After change");
- InspectorTest.addResults(InspectorTest.getSelectedElementStyles(true, true));
+ InspectorTest.dumpSelectedElementStyles(true, true);
InspectorTest.completeTest();
}
-
- InspectorTest.expandDOMSubtreeAndRun(null, selectContainerElementContinuation);
}
</script>
</head>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
- {
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_runTest", callback);
-}
+ InspectorTest.selectNodeWithId("container", step1);
-// Frontend functions.
+ function step1()
+ {
+ // Disable property
+ InspectorTest.addResult("Before disable");
+ InspectorTest.dumpSelectedElementStyles(true, true);
-function frontend_runTest(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectContainerElementContinuation);
-}
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
+ treeItem.toggleEnabled({ target: { checked: false } });
-function frontend_selectContainerElementContinuation(testController)
-{
- frontend_selectElementAndRun(testController, "container", frontend_disableContainerStyle);
-}
+ InspectorTest.runAfterPendingDispatches(step2);
+ }
-function frontend_disableContainerStyle(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- testController.results.push("Before disable");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(true, true));
+ function step2()
+ {
+ // Delete style
+ InspectorTest.addResult("After disable");
+ InspectorTest.dumpSelectedElementStyles(true, true);
- treeItem.toggleEnabled({ target: { checked: false } });
- testController.runAfterPendingDispatches(frontend_deleteContainerStyle.bind(this, testController));
-}
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
+ treeItem.applyStyleText("", true);
-function frontend_deleteContainerStyle(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- testController.results.push("After disable");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(true, true));
+ InspectorTest.runAfterPendingDispatches(step3);
+ }
- treeItem.applyStyleText("", true);
- testController.runAfterPendingDispatches(frontend_reselectNodeAndDumpResults.bind(this, testController));
-}
+ function step3()
+ {
+ InspectorTest.selectNodeWithId("other", step4);
+ }
-function frontend_reselectNodeAndDumpResults(testController)
-{
- function continuation()
+ function step4()
{
- frontend_selectElementAndRun(testController, "container", frontend_dumpResults);
+ InspectorTest.selectNodeWithId("container", step5);
}
- frontend_selectElementAndRun(testController, "other", continuation);
-}
-function frontend_dumpResults(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- testController.results.push("After delete");
- testController.results = testController.results.concat(frontend_getSelectedElementStyles(true, true));
- testController.notifyDone();
+ function step5(node)
+ {
+ InspectorTest.addResult("After delete");
+ InspectorTest.dumpSelectedElementStyles(true, true);
+ InspectorTest.completeTest();
+ }
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that removal of property following its disabling works.
</p>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
- {
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_runTest", callback);
-}
-
-// Frontend functions.
-
-function frontend_runTest(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectContainerElementContinuation);
-}
+ InspectorTest.selectNodeWithId("container", step1);
-function frontend_selectContainerElementContinuation(testController)
-{
- frontend_selectElementAndRun(testController, "container", frontend_disableContainerStyle);
-}
+ function step1()
+ {
+ InspectorTest.addResult("Before disable");
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
+ InspectorTest.dumpStyleTreeItem(treeItem, "");
-function frontend_disableContainerStyle(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- testController.results.push("Before disable");
- frontend_dumpStyleTreeItem(treeItem, testController.results, "");
+ treeItem.toggleEnabled({ target: { checked: false } });
+ InspectorTest.runAfterPendingDispatches(step2);
+ }
- treeItem.toggleEnabled({ target: { checked: false } });
- testController.runAfterPendingDispatches(frontend_enableContainerStyle.bind(this, testController));
-}
+ function step2()
+ {
+ InspectorTest.addResult("After disable");
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
+ InspectorTest.dumpStyleTreeItem(treeItem, "");
-function frontend_enableContainerStyle(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- testController.results.push("After disable");
- frontend_dumpStyleTreeItem(treeItem, testController.results, "");
+ treeItem.toggleEnabled({ target: { checked: true } });
+ InspectorTest.runAfterPendingDispatches(step3);
+ }
- treeItem.toggleEnabled({ target: { checked: true } });
- testController.runAfterPendingDispatches(frontend_dumpResults.bind(this, testController));
-}
+ function step3()
+ {
+ InspectorTest.addResult("After enable");
+ var treeItem = InspectorTest.getElementStylePropertyTreeItem("font-weight");
+ InspectorTest.dumpStyleTreeItem(treeItem, "");
-function frontend_dumpResults(testController)
-{
- var treeItem = frontend_getElementStylePropertyTreeItem("font-weight");
- testController.results.push("After enable");
- frontend_dumpStyleTreeItem(treeItem, testController.results, "");
- testController.notifyDone(testController.results);
+ InspectorTest.completeTest();
+ }
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that disabling style property works.
</p>
Tests that proper (and different) styles are returned for body elements of main document and iframe.
-Style: 0
-{"margin":"8px"}
-{"background":"blue"}
-Style: 1
-{"margin":"8px"}
-{"background":"green"}
+Main frame style:
+[expanded] element.style { ()
+
+======== Matched CSS Rules ========
+[expanded] body { (styles-iframe.html:5)
+background: blue;
+
+[expanded] body { (user agent stylesheet)
+display: block;
+margin: 8px;
+
+
+iframe style:
+[expanded] element.style { ()
+
+======== Matched CSS Rules ========
+[expanded] body { (styles-iframe-data.html:4)
+background: green;
+
+[expanded] body { (user agent stylesheet)
+display: block;
+margin: 8px;
+
+
body { background:blue; }
</style>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- runAfterIframeIsLoaded(function() {
- function callback(result)
- {
- for (var i = 0; i < result.length; ++i) {
- output("Style: " + i);
- var matchedRules = result[i].matchedCSSRules;
- for (var j = 0; matchedRules && j < matchedRules.length; ++j) {
- output(JSON.stringify(matchedRules[j].style.shorthandValues));
- }
- }
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpStyles", callback);
- });
-}
-
+ InspectorTest.selectNodeWithId("mainBody", step1);
-// Frontend functions.
-
-function frontend_dumpStyles(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_dumpStylesContinuation);
-}
-
-function frontend_dumpStylesContinuation(testController)
-{
- // 1. Get styles for body, store them in mainStyles var.
- var body = WebInspector.domAgent.document.body;
- var mainStyles = null;
- function mainFrameCallback(styles)
+ function step1()
{
- mainStyles = styles;
+ InspectorTest.addResult("Main frame style:");
+ InspectorTest.dumpSelectedElementStyles(true, false, true);
+ InspectorTest.selectNodeWithId("iframeBody", step2);
}
- InspectorBackend.getStylesForNode(body.id, mainFrameCallback);
-
- // 2. Find iframe node
- var innerMapping = WebInspector.domAgent._idToDOMNode;
- var iframeBody = null;
-
- for (var nodeId in innerMapping) {
- if (innerMapping[nodeId].nodeName === "IFRAME")
- iframeBody = innerMapping[nodeId].firstChild.lastChild;
- }
- if (!iframeBody) {
- testController.notifyDone(["No iframe node found"]);
- return;
- }
-
- // 3. Get styles for iframe's body, return them together with main styles.
- function iframeCallback(styles)
+ function step2()
{
- testController.notifyDone([mainStyles, styles]);
+ InspectorTest.addResult("iframe style:");
+ InspectorTest.dumpSelectedElementStyles(true, false, true);
+ InspectorTest.completeTest();
}
-
- InspectorBackend.getStylesForNode(iframeBody.id, iframeCallback);
}
-
</script>
</head>
-<body onload="onload()">
+<body onload="runAfterIframeIsLoaded()" id="mainBody">
<p>
Tests that proper (and different) styles are returned for body elements of main document and iframe.
</p>
<link rel="stylesheet" href="resources/styles-new-API.css">
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
- {
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_runTest", callback);
-}
-
-
-// Frontend functions.
-
-function frontend_runTest(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtree(WebInspector.domAgent.document);
- testController.runAfterPendingDispatches(function() {
-
- function tableStylesCallback(testController, styles)
- {
- testController.results.push("");
- testController.results.push("=== Attribute styles for table ===");
- for (var attr in styles.styleAttributes) {
- testController.results.push("Attribute: " + attr);
- frontend_dumpRuleOrStyle(testController, styles.styleAttributes[attr]);
- }
+ test_styles();
- frontend_testStyleSheets(testController);
- }
-
- function stylesCallback(testController, styles)
+ function test_styles(node)
+ {
+ function callback(styles)
{
- testController.results.push("");
- testController.results.push("=== Computed style property count for body ===");
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Computed style property count for body ===");
var propCount = styles.computedStyle.cssProperties.length;
- testController.results.push(propCount > 200 ? "OK" : "FAIL (" + propCount + ")");
+ InspectorTest.addResult(propCount > 200 ? "OK" : "FAIL (" + propCount + ")");
- testController.results.push("");
- testController.results.push("=== Matched rules for body ===");
- frontend_dumpRulesArray(testController, styles.matchedCSSRules);
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Matched rules for body ===");
+ dumpRulesArray(styles.matchedCSSRules);
- testController.results.push("");
- testController.results.push("=== Pseudo rules for body ===");
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Pseudo rules for body ===");
for (var i = 0; i < styles.pseudoElements.length; ++i) {
- testController.results.push("PseudoId=" + styles.pseudoElements[i].pseudoId);
- frontend_dumpRulesArray(testController, styles.pseudoElements[i].rules);
+ InspectorTest.addResult("PseudoId=" + styles.pseudoElements[i].pseudoId);
+ dumpRulesArray(styles.pseudoElements[i].rules);
}
- testController.results.push("");
- testController.results.push("=== Inherited styles for body ===");
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Inherited styles for body ===");
for (var i = 0; i < styles.inherited.length; ++i) {
- testController.results.push("Level=" + (i + 1));
- frontend_dumpRuleOrStyle(testController, styles.inherited[i].inlineStyle);
- frontend_dumpRulesArray(testController, styles.inherited[i].matchedCSSRules);
+ InspectorTest.addResult("Level=" + (i + 1));
+ dumpRuleOrStyle(styles.inherited[i].inlineStyle);
+ dumpRulesArray(styles.inherited[i].matchedCSSRules);
}
- testController.results.push("");
- testController.results.push("=== Inline style for body ===");
- frontend_dumpRuleOrStyle(testController, styles.inlineStyle);
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Inline style for body ===");
+ dumpRuleOrStyle(styles.inlineStyle);
+ test_tableStyles();
+ }
- InspectorBackend.getStylesForNode(frontend_nodeForId("thetable").id, tableStylesCallback.bind(null, testController));
+ function nodeCallback(node)
+ {
+ InspectorBackend.getStylesForNode(node.id, callback);
}
+ InspectorTest.selectNodeWithId("mainBody", nodeCallback);
+ }
- InspectorBackend.getStylesForNode(WebInspector.domAgent.document.body.id, stylesCallback.bind(null, testController));
- });
-}
+ function test_tableStyles()
+ {
+ function callback(styles)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Attribute styles for table ===");
+ for (var attr in styles.styleAttributes) {
+ InspectorTest.addResult("Attribute: " + attr);
+ dumpRuleOrStyle(styles.styleAttributes[attr]);
+ }
+ test_styleSheets();
+ }
-function frontend_testStyleSheets(testController)
-{
-var newStyleSheetText =
-"body.mainpage {\
- text-decoration: strikethrough;\
- badproperty: 2badvalue2;\
-}\
-\
-body {\
- text-align: justify;\
-}\
-";
-
- function patchStyleSheet(testController, styleSheet)
+ function nodeCallback(node)
+ {
+ InspectorBackend.getStylesForNode(node.id, callback);
+ }
+ InspectorTest.nodeWithId("thetable", nodeCallback);
+ }
+
+ function test_styleSheets()
{
- testController.results.push("");
- testController.results.push("=== Last stylesheet patched ===");
- InspectorBackend.setStyleSheetText(styleSheet.styleSheetId, newStyleSheetText,
- frontend_loadAndDumpStyleSheet.bind(null, testController, styleSheet.styleSheetId, frontend_changeSelector.bind(null, testController)));
+ var newStyleSheetText =
+ "body.mainpage {" +
+ " text-decoration: strikethrough;" +
+ " badproperty: 2badvalue2;" +
+ "}" +
+ "body {" +
+ " text-align: justify;" +
+ "}";
+
+ function patchStyleSheet(styleSheet)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Last stylesheet patched ===");
+ InspectorBackend.setStyleSheetText(styleSheet.styleSheetId, newStyleSheetText,
+ loadAndDumpStyleSheet.bind(null, styleSheet.styleSheetId, test_changeSelector));
+ }
+
+ function styleSheetIdsLoaded(ids)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== All stylesheets ===");
+ for (var i = 0; i < ids.length; ++i)
+ loadAndDumpStyleSheet(ids[i], (i < ids.length - 1) ? null : patchStyleSheet);
+ }
+ InspectorBackend.getAllStyles(styleSheetIdsLoaded);
}
- function styleSheetIdsLoaded(testController, ids)
+ function test_changeSelector(styleSheet)
{
- testController.results.push("");
- testController.results.push("=== All stylesheets ===");
- for (var i = 0; i < ids.length; ++i)
- frontend_loadAndDumpStyleSheet(testController, ids[i], (i < ids.length - 1) ? null : patchStyleSheet.bind(null, testController));
+ function didSetSelector(rule)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== After selector set ===");
+ loadAndDumpStyleSheet(rule.ruleId.styleSheetId, test_setStyleText);
+ }
+
+ InspectorBackend.setRuleSelector(styleSheet.rules[0].ruleId, "html *, body[foo=\"bar\"]", didSetSelector);
}
- InspectorBackend.getAllStyles(styleSheetIdsLoaded.bind(null, testController));
-}
-function frontend_changeSelector(testController, styleSheet)
-{
- function didSetSelector(testController, rule)
+ function test_setStyleText(styleSheet)
{
- testController.results.push("");
- testController.results.push("=== After selector set ===");
- frontend_loadAndDumpStyleSheet(testController, rule.ruleId.styleSheetId, frontend_setStyleText.bind(null, testController));
- }
+ function didSetStyleText(style)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== After style text set ===");
+ loadAndDumpStyleSheet(style.styleId.styleSheetId, test_addRule);
+ }
- InspectorBackend.setRuleSelector(styleSheet.rules[0].ruleId, "html *, body[foo=\"bar\"]", didSetSelector.bind(null, testController));
-}
+ InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "", true);
+ InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "", true);
-function frontend_setStyleText(testController, styleSheet)
-{
- function didSetStyleText(testController, style)
- {
- testController.results.push("");
- testController.results.push("=== After style text set ===");
- frontend_loadAndDumpStyleSheet(testController, style.styleId.styleSheetId, frontend_addRule.bind(null, testController));
+ // This operation should not update the style as the new property text is not parsable.
+ InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "zzz;", false);
+ InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "color: white; background: black;", false, didSetStyleText);
}
- InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "", true);
- InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "", true);
+ function test_addRule()
+ {
+ function didGetStyles(styles)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Matched rules after rule added ===");
+ dumpRulesArray(styles.matchedCSSRules);
+ test_disableProperty();
+ }
- // This operation should not update the style as the new property text is not parsable.
- InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "zzz;", false);
- InspectorBackend.setPropertyText(styleSheet.rules[0].style.styleId, 0, "color: white; background: black;", false, didSetStyleText.bind(null, testController));
-}
+ function didSetStyleText(style)
+ {
+ InspectorBackend.getStylesForNode(WebInspector.domAgent.document.body.id, didGetStyles);
+ }
-function frontend_addRule(testController)
-{
- function didGetStyles(testController, styles)
- {
- testController.results.push("");
- testController.results.push("=== Matched rules after rule added ===");
- frontend_dumpRulesArray(testController, styles.matchedCSSRules);
- frontend_disableProperty(testController);
- }
+ function ruleAdded(rule)
+ {
+ InspectorBackend.setPropertyText(rule.style.styleId, 0, "font-family: serif;", false, didSetStyleText);
+ }
- function didSetStyleText(testController, style)
- {
- InspectorBackend.getStylesForNode(WebInspector.domAgent.document.body.id, didGetStyles.bind(null, testController));
+ InspectorBackend.addRule(WebInspector.domAgent.document.body.id, "body", ruleAdded);
}
- function ruleAdded(testController, rule)
+ function test_disableProperty()
{
- InspectorBackend.setPropertyText(rule.style.styleId, 0, "font-family: serif;", false, didSetStyleText.bind(null, testController));
- }
+ function didDisableProperty(style)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== After two properties disabled, one property added, one property removed ===");
+ dumpRuleOrStyle(style);
+ test_enableProperty(style.styleId);
+ }
- InspectorBackend.addRule(WebInspector.domAgent.document.body.id, "body", ruleAdded.bind(null, testController));
-}
+ function stylesCallback(styles)
+ {
+ // height : 100% ;
+ // border: 1px solid;
+ // border-width: 2px;
+ // background-color : #33FF33;
+ // googles: abra;
+ // foo: .bar;
+ // -moz-goog: 1***;
+ // border-width: 0px;
+
+ var style = styles.matchedCSSRules[1].style;
+ InspectorBackend.toggleProperty(style.styleId, 0, true); // height: 100%
+ InspectorBackend.toggleProperty(style.styleId, 7, true); // border-width: 0px
+ InspectorBackend.setPropertyText(style.styleId, 7, "font-size: 12px;", false);
+ InspectorBackend.setPropertyText(style.styleId, 9, "font-size: 14px;", false);
+ InspectorBackend.toggleProperty(style.styleId, 9, true); // font-size: 14px
+ InspectorBackend.setPropertyText(style.styleId, 8, "border-width: 1px;", true);
+ InspectorBackend.toggleProperty(style.styleId, 8, false); // border-width: 1px
+ // height : 100% ; [d]
+ // border: 1px solid;
+ // border-width: 2px;
+ // background-color : #33FF33;
+ // googles: abra;
+ // foo: .bar;
+ // -moz-goog: 1***;
+ // font-size: 12px;
+ // border-width: 1px;
+ // font-size: 14px; [d]
+
+ InspectorBackend.setPropertyText(style.styleId, 3, "", true, didDisableProperty);
+ }
-function frontend_disableProperty(testController)
-{
- function didDisableProperty(testController, style)
- {
- testController.results.push("");
- testController.results.push("=== After two properties disabled, one property added, one property removed ===");
- frontend_dumpRuleOrStyle(testController, style);
- frontend_enableProperty(testController, style.styleId);
+ function nodeCallback(node)
+ {
+ InspectorBackend.getStylesForNode(node.id, stylesCallback);
+ }
+ InspectorTest.nodeWithId("toggle", nodeCallback);
}
- function stylesCallback(testController, styles)
+ function test_enableProperty(styleId)
{
- // height : 100% ;
- // border: 1px solid;
- // border-width: 2px;
- // background-color : #33FF33;
- // googles: abra;
- // foo: .bar;
- // -moz-goog: 1***;
- // border-width: 0px;
-
- var style = styles.matchedCSSRules[1].style;
- InspectorBackend.toggleProperty(style.styleId, 0, true); // height: 100%
- InspectorBackend.toggleProperty(style.styleId, 7, true); // border-width: 0px
- InspectorBackend.setPropertyText(style.styleId, 7, "font-size: 12px;", false);
- InspectorBackend.setPropertyText(style.styleId, 9, "font-size: 14px;", false);
- InspectorBackend.toggleProperty(style.styleId, 9, true); // font-size: 14px
- InspectorBackend.setPropertyText(style.styleId, 8, "border-width: 1px;", true);
- InspectorBackend.toggleProperty(style.styleId, 8, false); // border-width: 1px
- // height : 100% ; [d]
- // border: 1px solid;
- // border-width: 2px;
- // background-color : #33FF33;
- // googles: abra;
- // foo: .bar;
- // -moz-goog: 1***;
- // font-size: 12px;
- // border-width: 1px;
- // font-size: 14px; [d]
-
- InspectorBackend.setPropertyText(style.styleId, 3, "", true, didDisableProperty.bind(null, testController));
+ function didEnableProperty(style)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== After property enabled ===");
+ dumpRuleOrStyle(style);
+ InspectorTest.completeTest();
+ }
+
+ InspectorBackend.toggleProperty(styleId, 6, false);
+ InspectorBackend.toggleProperty(styleId, 8, false, didEnableProperty);
}
- var toggleElement = frontend_nodeForId("toggle");
- InspectorBackend.getStylesForNode(toggleElement.id, stylesCallback.bind(null, testController));
-}
+ // Data dumping
-function frontend_enableProperty(testController, styleId)
-{
- function didEnableProperty(testController, style)
+ function dumpRulesArray(rules)
{
- testController.results.push("");
- testController.results.push("=== After property enabled ===");
- frontend_dumpRuleOrStyle(testController, style);
- testController.notifyDone(testController.results);
+ if (!rules)
+ return;
+ for (var i = 0; i < rules.length; ++i)
+ dumpRuleOrStyle(rules[i]);
}
- InspectorBackend.toggleProperty(styleId, 6, false);
- InspectorBackend.toggleProperty(styleId, 8, false, didEnableProperty.bind(null, testController));
-}
-
-// Data dumping
-
-function frontend_dumpRulesArray(testController, rules)
-{
- if (!rules)
- return;
- for (var i = 0; i < rules.length; ++i)
- frontend_dumpRuleOrStyle(testController, rules[i]);
-}
-
-function frontend_dumpRuleOrStyle(testController, ruleOrStyle)
-{
- if (!ruleOrStyle)
- return;
- var isRule = !!(ruleOrStyle.style);
- var style = isRule ? ruleOrStyle.style : ruleOrStyle;
- testController.results.push("");
- testController.results.push(isRule ? "rule" : "style");
- testController.results.push((isRule ? (ruleOrStyle.selectorText + ": [" + ruleOrStyle.origin + "]") : "raw style"));
- for (var i = 0; i < style.cssProperties.length; ++i) {
- var property = style.cssProperties[i];
- if (property.status !== "disabled")
- testController.results.push("['" + property.name + "':'" + property.value + "'" + (property.priority === "important" ? " is-important" : "") + (property.parsedOk ? "" : " non-parsed") +"] @[" + property.startOffset + "-" + property.endOffset + "] " + property.status);
- else
- testController.results.push("[text='" + property.text + "'] " + property.status);
+ function dumpRuleOrStyle(ruleOrStyle)
+ {
+ if (!ruleOrStyle)
+ return;
+ var isRule = !!(ruleOrStyle.style);
+ var style = isRule ? ruleOrStyle.style : ruleOrStyle;
+ InspectorTest.addResult("");
+ InspectorTest.addResult(isRule ? "rule" : "style");
+ InspectorTest.addResult((isRule ? (ruleOrStyle.selectorText + ": [" + ruleOrStyle.origin + "]") : "raw style"));
+ for (var i = 0; i < style.cssProperties.length; ++i) {
+ var property = style.cssProperties[i];
+ if (property.status !== "disabled")
+ InspectorTest.addResult("['" + property.name + "':'" + property.value + "'" + (property.priority === "important" ? " is-important" : "") + (property.parsedOk ? "" : " non-parsed") +"] @[" + property.startOffset + "-" + property.endOffset + "] " + property.status);
+ else
+ InspectorTest.addResult("[text='" + property.text + "'] " + property.status);
+ }
}
-}
-function frontend_loadAndDumpStyleSheet(testController, styleSheetId, continuation)
-{
- function styleSheetLoaded(testController, styleSheet)
+ function loadAndDumpStyleSheet(styleSheetId, continuation)
{
- testController.results.push("");
- testController.results.push("StyleSheet: '" + styleSheet.text + "'");
- for (var i = 0; i < styleSheet.rules.length; ++i)
- frontend_dumpRuleOrStyle(testController, styleSheet.rules[i]);
- if (continuation)
- continuation(styleSheet);
- }
+ function styleSheetLoaded(styleSheet)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("StyleSheet: '" + styleSheet.text + "'");
+ for (var i = 0; i < styleSheet.rules.length; ++i)
+ dumpRuleOrStyle(styleSheet.rules[i]);
+ if (continuation)
+ continuation(styleSheet);
+ }
- InspectorBackend.getStyleSheet(styleSheetId, styleSheetLoaded.bind(null, testController));
+ InspectorBackend.getStyleSheet(styleSheetId, styleSheetLoaded);
+ }
}
/*
</style>
</head>
-<body class="main1 main2 mainpage" onload="onload()" style="font-weight: normal; width: 85%">
+<body id="mainBody" class="main1 main2 mainpage" onload="runTest()" style="font-weight: normal; width: 85%">
<p>
Tests that InspectorCSSAgent API methods work as expected.
</p>
Tests that proper source lines are reported for the parsed styles.
-Line:15 body, .at_line_15::before
-Line:29 body, .at_line_29
-Line:43 body, .at_line_43
-Line:50 body, .at_line_50
+[expanded] element.style { ()
+
+======== Matched CSS Rules ========
+[expanded] body, .at_line_50 { (styles-source-lines.html:50)
+border: 1px solid
+ red;
+
+[expanded] body, .at_line_43 { (styles-source-lines.html:43)
+font-size: 10px;
+
+[expanded] body, .at_line_29 { (styles-source-lines.html:29)
+font-family: /* Comment in
+ value */courier;
+
+[expanded] body, .at_line_15::before { (styles-source-lines.html:15)
+color: red;
+content: "Before";
+
+[expanded] body { (user agent stylesheet)
+display: block;
+margin: 8px;
+
+
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<style>
.foo {
<script>
-function doit()
+function test()
{
- runAfterIframeIsLoaded(function() {
- function callback(result)
- {
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpStyles", callback);
- });
-}
-
-// Frontend functions.
-
-function frontend_dumpStyles(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_selectElementContinuation);
-}
+ InspectorTest.selectNodeWithId("foo", step1);
-function frontend_selectElementContinuation(testController)
-{
- frontend_selectElementAndRun(testController, "foo", frontend_selectElementContinuation2);
-}
-
-function frontend_selectElementContinuation2(testController)
-{
- var result = frontend_getSelectedElementStyles(true);
- testController.notifyDone(result);
+ function step1()
+ {
+ InspectorTest.dumpSelectedElementStyles(true, false, true);
+ InspectorTest.completeTest();
+ }
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()">
<p>
Tests that elements panel shows proper inline style locations in the sidebar panel.
</p>
}
</style>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(styles)
- {
- var matchedCSSRules = styles.matchedCSSRules;
- for (var i = 0; i < matchedCSSRules.length; ++i) {
- if (matchedCSSRules[i].origin !== "")
- continue;
- output("Line:" + (matchedCSSRules[i].sourceLine + 1) + "\t" + matchedCSSRules[i].selectorText);
- }
- notifyDone();
- }
- evaluateInWebInspector("frontend_dumpSourceLines", callback);
-}
-
-
-// Frontend functions.
+ InspectorTest.selectNodeWithId("mainBody", step1);
-function frontend_dumpSourceLines(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtreeAndRun(testController, null, frontend_getRawStyles);
-}
-
-function frontend_getRawStyles(testController)
-{
- function callback(styles)
+ function step1()
{
- testController.notifyDone(styles);
+ InspectorTest.dumpSelectedElementStyles(true, false, true);
+ InspectorTest.completeTest();
}
- InspectorBackend.getStylesForNode(WebInspector.domAgent.document.body.id, callback);
}
</script>
</head>
-<body onload="onload()">
+<body onload="runTest()" id="mainBody">
<p>
Tests that proper source lines are reported for the parsed styles.
</p>
<link rel="stylesheet" href="resources/styles-source-offsets.css" -->
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="elements-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function doit()
+function test()
{
- function callback(result)
+ function dumpStyleData(ruleOrStyle)
{
- if (result === "refreshing")
- return;
- dumpArray(result);
- notifyDone();
- }
- evaluateInWebInspector("frontend_runTest", callback);
-}
-
-
-// Frontend functions.
-
-function frontend_runTest(testController)
-{
- testController.waitUntilDone();
- frontend_expandDOMSubtree(WebInspector.domAgent.document);
-
- testController.runAfterPendingDispatches(function() {
- function stylesCallback(testController, styles)
- {
- var matchedCSSRules = styles.matchedCSSRules;
- for (var i = 0; i < matchedCSSRules.length; ++i) {
- var rule = matchedCSSRules[i];
- frontend_dumpStyleData(testController, rule, false);
- }
- frontend_dumpStyleData(testController, styles.inlineStyle, true);
+ var isRule = !!(ruleOrStyle.style);
+ var style;
+ var header = "";
+ if (isRule) {
+ if (ruleOrStyle.origin !== "")
+ return;
+ style = ruleOrStyle.style;
+ header = ruleOrStyle.selectorText + ": [" + (ruleOrStyle.selectorRange ? ruleOrStyle.selectorRange.start + "-" + ruleOrStyle.selectorRange.end : "") + "]";
+ } else {
+ style = ruleOrStyle;
+ header = "element.style:";
}
- InspectorBackend.getStylesForNode(WebInspector.domAgent.document.body.id, stylesCallback.bind(null, testController));
- });
-}
-
-function frontend_dumpStyleData(testController, ruleOrStyle, shouldBail)
-{
- var isRule = !!(ruleOrStyle.style);
- var style;
- var header = "";
- if (isRule) {
- if (ruleOrStyle.origin !== "") {
- if (shouldBail)
- testController.notifyDone(testController.results);
- return;
+ InspectorTest.addResult(header + " [" + style.properties.startOffset + "-" + style.properties.endOffset + "]");
+ var allProperties = style.cssProperties;
+ for (var i = 0; i < allProperties.length; ++i) {
+ var property = allProperties[i];
+ if (property.status === "style")
+ continue;
+ InspectorTest.addResult("['" + property.name + "':'" + property.value + "'" + (property.priority ? " !important" : "") + (property.parsedOk ? "" : " non-parsed") +"] @[" + property.startOffset + "-" + property.endOffset + "]");
}
- style = ruleOrStyle.style;
- header = ruleOrStyle.selectorText + ": [" + (ruleOrStyle.selectorRange ? ruleOrStyle.selectorRange.start + "-" + ruleOrStyle.selectorRange.end : "") + "]";
- } else {
- style = ruleOrStyle;
- header = "element.style:";
}
- testController.results.push(header + " [" + style.properties.startOffset + "-" + style.properties.endOffset + "]");
- var allProperties = style.cssProperties;
- for (var i = 0; i < allProperties.length; ++i) {
- var property = allProperties[i];
- if (property.status === "style")
- continue;
- testController.results.push("['" + property.name + "':'" + property.value + "'" + (property.priority ? " !important" : "") + (property.parsedOk ? "" : " non-parsed") +"] @[" + property.startOffset + "-" + property.endOffset + "]");
+
+ InspectorTest.selectNodeWithId("mainBody", step1);
+
+ function step1(node)
+ {
+ InspectorBackend.getStylesForNode(node.id, step2);
+ }
+
+ function step2(styles)
+ {
+ var matchedCSSRules = styles.matchedCSSRules;
+ for (var i = 0; i < matchedCSSRules.length; ++i)
+ dumpStyleData(matchedCSSRules[i]);
+ dumpStyleData(styles.inlineStyle);
+ InspectorTest.completeTest();
}
- if (shouldBail)
- testController.notifyDone(testController.results);
}
</script>
</style>
</head>
-<body class="main1 main2 mainpage" onload="onload()" style="font-weight: normal; width: 80%">
+<body id="mainBody" class="main1 main2 mainpage" onload="runTest()" style="font-weight: normal; width: 80%">
<p>
Tests that proper data and start/end offset positions are reported for CSS style declarations and properties.
</p>
<html>
<head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/inspector-test2.js"></script>
-<script src="elements-tests2.js"></script>
<link rel="stylesheet" href="resources/styles-url-linkify.css">
+
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="../http/tests/inspector/elements-test.js"></script>
<script>
-function runAfterIframeLoaded()
+function test()
{
- function step()
+ function completeURL(baseURL, href)
{
- if (!window.iframeLoaded)
- setTimeout(step, 100);
- else
- runTest();
+ InspectorTest.addResult(WebInspector.completeURL(baseURL, href));
}
- setTimeout(step, 100);
-}
-function test()
-{
+ InspectorTest.addResult("Partial URLs completed:");
+ completeURL("http://example.com", "/");
+ completeURL("http://example.com", "moo");
+ completeURL("http://example.com/", "https://secure.com/moo");
+ completeURL("https://example.com/foo", "//secure.com/moo");
+ completeURL("http://example.com/foo/zoo", "/moo");
+ completeURL("http://example.com/foo/zoo/", "moo");
+ completeURL("http://example.com/foo/zoo", "boo/moo");
+ completeURL("http://example.com/foo", "moo");
+ completeURL("http://example.com/foo", "?a=b");
+ completeURL("http://example.com/foo?c=d", "?a=b");
+
function dumpHref()
{
var href;
InspectorTest.addResult(output.join("/"));
}
- function selectLocalElement()
- {
- InspectorTest.selectElementAndRun("local", executeLocalTest);
- }
-
- function completeURL(baseURL, href)
- {
- InspectorTest.addResult(WebInspector.completeURL(baseURL, href));
- }
+ InspectorTest.selectNodeWithId("local", step1);
- function completeURLTest()
+ function step1()
{
- InspectorTest.addResult("Partial URLs completed:");
- completeURL("http://example.com", "/");
- completeURL("http://example.com", "moo");
- completeURL("http://example.com/", "https://secure.com/moo");
- completeURL("https://example.com/foo", "//secure.com/moo");
- completeURL("http://example.com/foo/zoo", "/moo");
- completeURL("http://example.com/foo/zoo/", "moo");
- completeURL("http://example.com/foo/zoo", "boo/moo");
- completeURL("http://example.com/foo", "moo");
- completeURL("http://example.com/foo", "?a=b");
- completeURL("http://example.com/foo?c=d", "?a=b");
- }
-
- function executeLocalTest()
- {
- completeURLTest();
InspectorTest.addResult("Link for a URI from CSS document:");
dumpHref();
- InspectorTest.selectElementAndRun("iframed", executeIframedTest);
+ InspectorTest.selectNodeWithId("iframed", step2);
}
- function executeIframedTest()
+ function step2()
{
InspectorTest.addResult("Link for a URI from iframe inline stylesheet:");
dumpHref();
InspectorTest.completeTest();
}
-
- InspectorTest.expandDOMSubtreeAndRun(null, selectLocalElement);
}
</script>
</head>
-<body onload="runAfterIframeLoaded()">
+<body onload="runAfterIframeIsLoaded()">
<p>
Tests that URLs are linked to and completed correctly. Bugs <a href="http://bugs.webkit.org/show_bug.cgi?id=51663">51663</a>, <a href="http://bugs.webkit.org/show_bug.cgi?id=53171">53171</a>
</p>
WebSocket's network errors should be logged to console.
console-websocket-error.html:32testDNSLookup: Test started.
-ws://nonexistent.domain.invalid/WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)
+ws://nonexistent.domain.invalid:80/WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)
console-websocket-error.html:43testDNSLookup: onclose is called.
console-websocket-error.html:50testSSLCertificate: Test started.
wss://127.0.0.1:8443/WebSocket network error: OSStatus Error -9812: valid cert chain, untrusted root