3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/elements-test.js"></script>
7 function pseudoVisibility(resolve
, reject
, pseudo
)
9 var parentNode
= document
.getElementById("parent-node");
10 resolve(getComputedStyle(parentNode
, ":" + pseudo
).visibility
);
13 function pseudoIframeVisibility(resolve
, reject
)
15 var parentNode
= frames
[0].document
.getElementById("frame-node");
16 resolve(getComputedStyle(parentNode
).visibility
);
26 InspectorTest
.runTestSuite([
27 function testSetUp(next
)
29 treeOutline
= InspectorTest
.firstElementsTreeOutline();
31 InspectorTest
.nodeWithId("parent-node", callback
);
33 function callback(node
)
36 InspectorTest
.nodeWithId("child-node", callback2
);
39 function callback2(node
)
42 InspectorTest
.nodeWithId("frame-node", callback3
);
45 function callback3(node
)
52 function testToggleHideShortcutOn(next
)
54 treeOutline
.toggleHideElement(parentNode
, callback
);
58 InspectorTest
.addResult("=== Added hide shortcut ===");
59 InspectorTest
.cssModel
.computedStylePromise(parentNode
.id
).then(callback2
);
62 function callback2(style
)
64 InspectorTest
.addResult("=== Parent node is hidden ===");
65 InspectorTest
.addResult(getPropertyText(style
, "visibility"));
66 InspectorTest
.cssModel
.computedStylePromise(childNode
.id
).then(callback3
);
69 function callback3(style
)
71 InspectorTest
.addResult("=== Child node is hidden ===");
72 InspectorTest
.addResult(getPropertyText(style
, "visibility"));
77 function testToggleHideShortcutOff(next
)
79 treeOutline
.toggleHideElement(parentNode
, callback
);
83 InspectorTest
.addResult("=== Removed hide shortcut ===");
84 InspectorTest
.cssModel
.computedStylePromise(parentNode
.id
).then(callback2
);
87 function callback2(style
)
89 InspectorTest
.addResult("=== Parent node is visible ===");
90 InspectorTest
.addResult(getPropertyText(style
, "visibility"));
91 InspectorTest
.cssModel
.computedStylePromise(childNode
.id
).then(callback3
);
94 function callback3(style
)
96 InspectorTest
.addResult("=== Child node is visible ===");
97 InspectorTest
.addResult(getPropertyText(style
, "visibility"));
102 function testToggleHideBeforePseudoShortcutOn(next
)
104 testPseudoToggle(parentNode
.beforePseudoElement(), next
);
107 function testToggleHideAfterPseudoShortcutOn(next
)
109 testPseudoToggle(parentNode
.afterPseudoElement(), next
);
112 function testToggleHideBeforePseudoShortcutOff(next
)
114 testPseudoToggle(parentNode
.beforePseudoElement(), next
);
117 function testToggleHideAfterPseudoShortcutOff(next
)
119 testPseudoToggle(parentNode
.afterPseudoElement(), next
);
122 function testToggleHideShortcutOnInFrame(next
)
124 treeOutline
.toggleHideElement(frameNode
, callback
);
128 InspectorTest
.invokePageFunctionPromise("pseudoIframeVisibility", []).then(function(result
) {
129 InspectorTest
.addResult("=== Added hide shortcut in frame ===");
130 InspectorTest
.addResult("=== Frame node is hidden ===");
131 InspectorTest
.addResult("visibility: " + result
+ ";");
138 function getPropertyText(computedStyle
, propertyName
)
140 return String
.sprintf("%s: %s;", propertyName
, computedStyle
.get(propertyName
));
143 function testPseudoToggle(pseudoNode
, next
)
145 treeOutline
.toggleHideElement(pseudoNode
, callback
);
148 InspectorTest
.invokePageFunctionPromise("pseudoVisibility", [pseudoNode
.pseudoType()]).then(function(result
) {
149 InspectorTest
.addResult("::" + pseudoNode
.pseudoType() + " node visibility: '" + result
+ "'");
157 #parent-node::before {
161 #parent-node::after {
169 Tests the hide shortcut, which toggles visibility:hidden on the node and it's ancestors.
170 <a href=
"https://bugs.webkit.org/show_bug.cgi?id=110641">Bug
110641</a>
173 <div id=
"parent-node">parent
174 <div style=
"visibility:hidden">hidden
175 <div id=
"child-node" style=
"visibility:visible">child
</div>
179 <iframe src=
"resources/hide-shortcut-iframe.html" onload=
"runTest()">