summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/debugger/navigator-view.html
blob: 305e9858577e6acb6c968db888af32853f8ac6b8 (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
103
104
105
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script src="../../http/tests/inspector/workspace-test.js"></script>

<script>
function test()
{
    WebInspector.showPanel("sources");
    InspectorTest.createWorkspace(true);
    var panel = new WebInspector.SourcesPanel(InspectorTest.testWorkspace);
    var navigator = panel._navigator;

    var uiSourceCodes = [];
    function addUISourceCode(url, isContentScript)
    {
        var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, "");
        var uiSourceCode = InspectorTest.testNetworkWorkspaceProvider.addFileForURL(url, contentProvider, false, isContentScript);
        uiSourceCodes.push(uiSourceCode);
    }

    function dumpNavigator()
    {
        InspectorTest.dumpScriptsNavigator(navigator, "  ");
    }

    function expandDomains(tree)
    {
        var children = navigator._sourcesView._scriptsTree.children;
        for (var i = 0; i < children.length; ++i)
          children[i].expand();
    }

    var rootURL = "http://localhost:8080/LayoutTests/inspector/debugger/";
    InspectorTest.addResult("Adding first resource:");
    addUISourceCode(rootURL + "foo/bar/script.js", false);
    dumpNavigator();
    InspectorTest.addResult("Expanding domains:");
    expandDomains(navigator._sourcesView._scriptsTree);
    dumpNavigator();
    InspectorTest.addResult("Adding second resource:");
    addUISourceCode(rootURL + "foo/bar/script.js?a=2", false);
    dumpNavigator();
    InspectorTest.addResult("Adding other resources:");
    addUISourceCode(rootURL + "foo/bar/script.js?a=1", false);
    addUISourceCode(rootURL + "foo/baz/script.js", false);
    dumpNavigator();

    InspectorTest.addResult("Adding content scripts and some random resources:");
    addUISourceCode(rootURL + "foo/bar/contentScript2.js?a=1", true);
    addUISourceCode(rootURL + "foo/bar/contentScript.js?a=2", true);
    addUISourceCode(rootURL + "foo/bar/contentScript.js?a=1", true);
    addUISourceCode("http://example.com/", false);
    addUISourceCode("http://example.com/?a=b", false);
    addUISourceCode("?a=b", false);
    addUISourceCode("very_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_url", false);
    dumpNavigator();

    InspectorTest.addResult("Revealing first resource:");
    navigator.revealUISourceCode(uiSourceCodes[0]);
    dumpNavigator();

    // Here we keep http://localhost:8080/LayoutTests/inspector/debugger2/ folder collapsed while adding resources into it.
    InspectorTest.addResult("Adding some resources to change the way debugger folder looks like, first:");
    var rootURL2 = "http://localhost:8080/LayoutTests/inspector/debugger2/";
    addUISourceCode(rootURL2 + "foo/bar/script.js", false);
    dumpNavigator();

    InspectorTest.addResult("Second:");
    addUISourceCode(rootURL2 + "foo/bar/script.js?a=2", false);
    dumpNavigator();
    InspectorTest.addResult("Others:");
    addUISourceCode(rootURL2 + "foo/bar/script.js?a=1", false);
    addUISourceCode(rootURL2 + "foo/baz/script.js", false);
    dumpNavigator();

    var rootURL3 = "http://localhost:8080/LayoutTests/inspector/debugger3/";
    addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/constructor/foo.js", false);
    addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/foo.js", false);
    addUISourceCode(rootURL3 + "hasOwnProperty/foo.js", false);
    dumpNavigator();

    InspectorTest.addResult("Revealing all resources:");
    for (var i = 0; i < uiSourceCodes.length; ++i)
        navigator.revealUISourceCode(uiSourceCodes[i]);
    dumpNavigator();

    InspectorTest.addResult("Removing all resources:");
    for (var i = 0; i < uiSourceCodes.length; ++i)
        navigator.removeUISourceCode(uiSourceCodes[i]);
    dumpNavigator();

    InspectorTest.completeTest();
}
</script>

</head>
<body onload="runTest()">
<p>
Tests scripts panel file selectors.
</p>
</body>

</html>