Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / styles-1 / cached-sync-computed-styles.html
blobbd8233c35d61d31b6842e71e11df1d91881dd347
1 <html>
2 <head>
3 <style id="style">
4 #inspected {
5 background-color: green;
7 </style>
8 <script src="../../../http/tests/inspector/inspector-test.js"></script>
9 <script src="../../../http/tests/inspector/elements-test.js"></script>
10 <script>
12 function updateStyle()
14 document.getElementById("style").textContent = "#inspected { color: red }";
17 function test()
19 InspectorTest.nodeWithId("inspected", step1);
20 var backendCallCount = 0;
21 var nodeId;
23 function onBackendCall(domain, method, params)
25 if (method === "CSS.getComputedStyleForNode" && params.nodeId === nodeId)
26 ++backendCallCount;
29 function step1(node)
31 var callsLeft = 2;
32 nodeId = node.id;
33 InspectorTest.addSniffer(InspectorBackend.connection(), "_wrapCallbackAndSendMessageObject", onBackendCall, true);
34 InspectorTest.cssModel.computedStylePromise(nodeId).then(styleCallback);
35 InspectorTest.cssModel.computedStylePromise(nodeId).then(styleCallback);
36 function styleCallback()
38 if (--callsLeft)
39 return;
40 InspectorTest.addResult("# of backend calls sent [2 requests]: " + backendCallCount);
41 InspectorTest.evaluateInPage("updateStyle()", step2);
45 function step2()
47 InspectorTest.cssModel.computedStylePromise(nodeId).then(callback);
48 function callback()
50 InspectorTest.addResult("# of backend calls sent [style update + another request]: " + backendCallCount);
51 InspectorTest.completeTest();
55 </script>
56 </head>
58 <body onload="runTest()">
59 <p>
60 Tests that computed styles are cached across synchronous requests.
61 </p>
63 <div>
64 <div id="inspected">Test</div>
65 </div>
67 </body>
68 </html>