summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/debugger/pause-in-inline-script.html
blob: 71af5380f7d98e1707b5732d46966e74f69410fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<html>
<head>
<script>function foo() { };
</script>
<script>
function bar() { };
</script><script>function f1() { debugger; }</script>
<script>
function f2() { return f1(); }
</script>

<script>
function f3()
{
    return f2();
}
f3();
</script>

<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>

<script>

var test = function()
{
    var testName = WebInspector.inspectedPageURL;
    testName = testName.substring(testName.lastIndexOf('/') + 1);

    InspectorTest.startDebuggerTest(step1);

    function step1()
    {
        InspectorTest.addResult("Did load front-end");
        InspectorTest.addResult("Paused: " + !!WebInspector.debuggerModel.debuggerPausedDetails());
        InspectorTest.reloadPage(didReload.bind(this));
        WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, didPauseAfterReload, this); 
    }

    function didReload()
    {
        InspectorTest.addResult("didReload");
        InspectorTest.completeDebuggerTest();
    }

    function didPauseAfterReload(details)
    {
        InspectorTest.addResult("didPauseAfterReload");
        InspectorTest.addResult("Source strings corresponding to the call stack:");
        dumpNextCallFrame(didDump);
    }

    var callFrameIndex = 0;
    function dumpNextCallFrame(next)
    {
        var callFrames = WebInspector.debuggerModel.callFrames;
        if (callFrameIndex === callFrames.length) {
            next();
            return;
        }
        var frame = callFrames[callFrameIndex];
        var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation(frame.location);
        InspectorTest.showUISourceCode(uiLocation.uiSourceCode, dumpCallFrameLine);

        function dumpCallFrameLine(sourceFrame)
        {
            var resourceText = sourceFrame._textEditor.text();
            var lines = resourceText.split("\n");
            var lineNumber = uiLocation.lineNumber;
            InspectorTest.addResult("Frame " + callFrameIndex + ") line " + lineNumber + ", content: " + lines[lineNumber] + " (must be part of function '" + frame.functionName + "')");
            callFrameIndex++
            dumpNextCallFrame(next);
        }
    }

    function uiSourceCodeAdded(uiSourceCode)
    {
        InspectorTest.addResult("uiSourceCodeAdded");
    }

    function didDump()
    {
        InspectorTest.resumeExecution(didResume);
    }

    function didResume()
    {
        InspectorTest.addResult("didResume");
    }
};
</script>

</head>

<body onload="runTest()">
<p>
Tests that main resource script text is correct when paused in inline script on reload.
<a href="https://bugs.webkit.org/show_bug.cgi?id=77548">Bug 77548.</a>
</p>

</body>
</html>