Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / debugger / debugger-pause-in-tight-loop.html
bloba420eb16e2199c094e649198a93f33a5e2540c04
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
6 function testFunction()
8 setTimeout(hotFunction, 0);
11 var terminated = false;
12 function hotFunction() {
13 evaluateInFrontend("InspectorTest.didFireTimer()");
15 var message_id = 1;
16 var ts = Date.now();
17 while (!terminated) {
18 // Without this try/catch v8 will optimize the function and break will not work.
19 try {
20 if (Date.now() - ts > 1000) {
21 ts = Date.now();
22 console.error("Message #" + message_id++);
24 } catch (e) {
29 function test()
31 InspectorTest.sendCommand("Inspector.enable", {});
32 InspectorTest.sendCommand("Debugger.enable", {}, didEnableDebugger);
33 function didEnableDebugger()
35 // Start tight loop in page.
36 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" }, didEval);
37 function didEval()
39 InspectorTest.log("didEval");
43 InspectorTest.didFireTimer = function()
45 InspectorTest.log("didFireTimer");
46 InspectorTest.sendCommand("Debugger.pause", { });
49 InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
51 var message = messageObject["params"]["message"];
52 InspectorTest.log("SUCCESS: Paused");
53 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "terminated = true;" });
54 InspectorTest.sendCommand("Debugger.resume", { });
55 InspectorTest.completeTest();
58 </script>
59 </head>
60 <body onLoad="runTest();">
61 </body>
62 </html>