Index: third_party/WebKit/LayoutTests/inspector-protocol/css/pseudo-element-matching-selectors.html |
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/css/pseudo-element-matching-selectors.html b/third_party/WebKit/LayoutTests/inspector-protocol/css/pseudo-element-matching-selectors.html |
index b658c98f37bf10de40a0f7b1ed7924c2ef9ef599..980b0285ceada38591759621220a0374c0d9afeb 100644 |
--- a/third_party/WebKit/LayoutTests/inspector-protocol/css/pseudo-element-matching-selectors.html |
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/css/pseudo-element-matching-selectors.html |
@@ -8,37 +8,61 @@ |
document.getElementById("style").textContent = "#for-pseudo:before { content: \"BEFORE\" }"; |
} |
-async function test() |
+function test() |
{ |
var nodeInfo = {}; |
var childrenCallback; |
InspectorTest.eventHandler["DOM.setChildNodes"] = setChildNodes; |
- await InspectorTest.sendCommandOrDie("DOM.enable", {}); |
- await InspectorTest.sendCommandOrDie("CSS.enable", {}); |
+ getDocument(); |
- InspectorTest.log("\n=== Get the Document ===\n"); |
- var result = await InspectorTest.sendCommandOrDie("DOM.getDocument", {}); |
- var bodyId = result.root.children[0].children[1].nodeId; |
+ function getDocument() |
+ { |
+ step({ |
+ name: "Get the Document", |
+ command: "DOM.getDocument", |
+ parameters: {}, |
+ callback: getImmediateChildren |
+ }); |
+ }; |
- InspectorTest.log("\n=== Get immediate children of the body ===\n"); |
- result = await InspectorTest.sendCommandOrDie("DOM.requestChildNodes", {"nodeId": bodyId}); |
- var node = findNodeById("for-pseudo"); |
- var beforeNode = node.pseudoElements[0]; |
+ function getImmediateChildren(result) |
+ { |
+ var bodyId = result.root.children[0].children[1].nodeId; |
+ childrenCallback = onChildrenRequested; |
+ step({ |
+ name: "Get immediate children of the body", |
+ command: "DOM.requestChildNodes", |
+ parameters: {"nodeId": bodyId} |
+ }); |
+ }; |
- InspectorTest.log("\n=== Request matching styles for #for-pseudo::before ===\n"); |
- result = await InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", {nodeId: beforeNode.nodeId}); |
- var matchedRules = result.matchedCSSRules; |
- for (var i = 0; i < matchedRules.length; ++i) { |
- var match = matchedRules[i]; |
- if (match.rule.selectorList.text === "#for-pseudo::before") { |
- InspectorTest.log("#for-pseudo::before matching the :before element: " + (match.matchingSelectors[0] === 0)); |
- InspectorTest.completeTest(); |
- return; |
+ function onChildrenRequested() |
+ { |
+ var node = findNodeById("for-pseudo"); |
+ var beforeNode = node.pseudoElements[0]; |
+ step({ |
+ name: "Request matching styles for #for-pseudo::before", |
+ command: "CSS.getMatchedStylesForNode", |
+ parameters: {nodeId: beforeNode.nodeId}, |
+ callback: stylesReceived |
+ }); |
+ } |
+ |
+ function stylesReceived(result) |
+ { |
+ var matchedRules = result.matchedCSSRules; |
+ for (var i = 0; i < matchedRules.length; ++i) { |
+ var match = matchedRules[i]; |
+ if (match.rule.selectorList.text === "#for-pseudo::before") { |
+ InspectorTest.log("#for-pseudo::before matching the :before element: " + (match.matchingSelectors[0] === 0)); |
+ InspectorTest.completeTest(); |
+ return; |
+ } |
} |
+ InspectorTest.log("#for-pseudo::before rule not received"); |
+ InspectorTest.completeTest(); |
} |
- InspectorTest.log("#for-pseudo::before rule not received"); |
- InspectorTest.completeTest(); |
function setChildNodes(message) |
{ |
@@ -49,6 +73,18 @@ |
childrenCallback = null; |
if (callback) |
callback(); |
+ } |
+ |
+ function step(test) |
+ { |
+ InspectorTest.log("\n=== " + test.name + " ===\n"); |
+ InspectorTest.sendCommand(test.command, test.parameters, function(messageObject) { |
+ if (messageObject.hasOwnProperty("error")) |
+ InspectorTest.log("Backend error: " + messageObject.error.message + " (" + messageObject.error.code + ")\n"); |
+ |
+ if (test.callback) |
+ test.callback(messageObject.result); |
+ }); |
} |
function findNodeById(id) |
@@ -69,10 +105,18 @@ |
return null; |
} |
- function addNodesRecursive(node) |
+ function addNodesRecursive(root) |
+ { |
+ addNode(root); |
+ if (!root.children) |
+ return; |
+ for (var i = 0; i < root.children.length; ++i) |
+ addNodesRecursive(root.children[i]); |
+ } |
+ |
+ function addNode(node) |
{ |
nodeInfo[node.nodeId] = node; |
- (node.children || []).forEach(addNodesRecursive); |
} |
} |