summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/debugger/content-providers.html
blob: eb77f625c91ab246e7e7297bdc3dfec8d75cfd19 (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
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>

<script>

function test()
{
    function createMockScript(id, source, range)
    {
        range = range || [0, 0, 100, 0];
        return {
            requestContent: function(callback)
            {
                callback(source);
            },
            get lineOffset() { return range[0]; },
            get columnOffset() { return range[1]; },
            get endLine() { return range[2]; },
            get endColumn() { return range[3]; }
        };
    }

    InspectorTest.runTestSuite([
        function testConcatenatedScriptsContentProvider(next)
        {
            var scripts = [];
            scripts.push(createMockScript("1", "\nfunction baz()\n{\n  return 0;\n}\n", [3, 20, 7, 0]));
            scripts.push(createMockScript("2", "function foo() { return 0; }", [0, 10, 0, 38]));
            scripts.push(createMockScript("3", "function bar() { return 0; }", [1, 70, 1, 98]));
            scripts.push(createMockScript("4", "this should not appear in displayed content", [0, 20, 0, 63]));
            var contentProvider = new WebInspector.ConcatenatedScriptsContentProvider(scripts);
            function didRequestContent(content)
            {
                InspectorTest.addResult(content);
                next();
            }
            contentProvider.requestContent(didRequestContent);
        }
    ]);
};

</script>

</head>

<body onload="runTest()">
<p>Tests ContentProvider implementations.</p>
</body>
</html>