1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/webconsole/test/test_reflow.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html lang="en"> 1.6 +<head> 1.7 + <meta charset="utf8"> 1.8 + <title>Test for the Reflow Activity</title> 1.9 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.10 + <script type="text/javascript;version=1.8" src="common.js"></script> 1.11 + <!-- Any copyright is dedicated to the Public Domain. 1.12 + - http://creativecommons.org/publicdomain/zero/1.0/ --> 1.13 +</head> 1.14 +<body> 1.15 +<p>Test for reflow events</p> 1.16 + 1.17 +<script class="testbody" type="text/javascript;version=1.8"> 1.18 +SimpleTest.waitForExplicitFinish(); 1.19 + 1.20 +let client; 1.21 + 1.22 +function generateReflow() 1.23 +{ 1.24 + top.document.documentElement.style.display = "none"; 1.25 + top.document.documentElement.getBoundingClientRect(); 1.26 + top.document.documentElement.style.display = "block"; 1.27 +} 1.28 + 1.29 +function startTest() 1.30 +{ 1.31 + removeEventListener("load", startTest); 1.32 + attachConsole(["ReflowActivity"], onAttach, true); 1.33 +} 1.34 + 1.35 +function onAttach(aState, aResponse) 1.36 +{ 1.37 + client = aState.dbgClient; 1.38 + 1.39 + onReflowActivity = onReflowActivity.bind(null, aState); 1.40 + client.addListener("reflowActivity", onReflowActivity); 1.41 + generateReflow(); 1.42 +} 1.43 + 1.44 +// We are expecting 3 reflow events. 1.45 +let expectedEvents = [ 1.46 + { 1.47 + interruptible: false, 1.48 + sourceURL: "chrome://mochitests/content/chrome/toolkit/devtools/webconsole/test/test_reflow.html", 1.49 + functionName: "generateReflow" 1.50 + }, 1.51 + { 1.52 + interruptible: true, 1.53 + sourceURL: null, 1.54 + functionName: null 1.55 + }, 1.56 + { 1.57 + interruptible: true, 1.58 + sourceURL: null, 1.59 + functionName: null 1.60 + }, 1.61 +]; 1.62 + 1.63 +let receivedEvents = []; 1.64 + 1.65 + 1.66 +function onReflowActivity(aState, aType, aPacket) 1.67 +{ 1.68 + info("packet: " + aPacket.message); 1.69 + receivedEvents.push(aPacket); 1.70 + if (receivedEvents.length == expectedEvents.length) { 1.71 + checkEvents(); 1.72 + finish(aState); 1.73 + } 1.74 +} 1.75 + 1.76 +function checkEvents() { 1.77 + for (let i = 0; i < expectedEvents.length; i++) { 1.78 + let a = expectedEvents[i]; 1.79 + let b = receivedEvents[i]; 1.80 + for (let key in a) { 1.81 + is(a[key], b[key], "field " + key + " is valid"); 1.82 + } 1.83 + } 1.84 +} 1.85 + 1.86 +function finish(aState) { 1.87 + client.removeListener("reflowActivity", onReflowActivity); 1.88 + closeDebugger(aState, function() { 1.89 + SimpleTest.finish(); 1.90 + }); 1.91 +} 1.92 + 1.93 +addEventListener("load", startTest); 1.94 + 1.95 +</script> 1.96 +</body> 1.97 +</html>