summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/version-controller.html
blob: 7289f1f1e611d905984424b675c3cf3208fdf1ff (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
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script>
function test()
{
    function createBreakpoint(uiSourceCodeId, lineNumber, condition, enabled)
    {
        return { sourceFileId: uiSourceCodeId, lineNumber: lineNumber, condition: condition, enabled: enabled };
    }

    InspectorTest.runTestSuite([
        function testMethodsToRunToUpdateVersion(next)
        {
            function runVersionControllerTest(oldVersion, currentVersion)
            {
                InspectorTest.addResult("Testing methods to run to upgrade from " + oldVersion + " to " + currentVersion + ".");
                var versionController = new WebInspector.VersionController();
                var methodsToRun = versionController._methodsToRunToUpdateVersion(oldVersion, currentVersion);
                InspectorTest.addResult("Methods to run: " + JSON.stringify(methodsToRun));
                InspectorTest.addResult("");
            }

            runVersionControllerTest(0, 0);
            runVersionControllerTest(0, 1);
            runVersionControllerTest(0, 2);
            runVersionControllerTest(0, 3);
            runVersionControllerTest(1, 1);
            runVersionControllerTest(1, 2);
            runVersionControllerTest(1, 3);
            runVersionControllerTest(2, 2);
            runVersionControllerTest(2, 3);
            next();
        },

        function testClearBreakpointsWhenTooMany(next)
        {
            function runClearBreakpointsTest(breakpointsCount, maxBreakpointsCount)
            {
                InspectorTest.addResult("Starting test with " + breakpointsCount + " breakpoints and " + maxBreakpointsCount + " allowed at max.");
                var versionController = new WebInspector.VersionController();
                var serializedBreakpoints = [];
                for (var i = 0; i < breakpointsCount; ++i)
                    serializedBreakpoints.push(createBreakpoint("file" + i + ".js", i % 10, "", true));
                var breakpointsSetting = new InspectorTest.MockSetting(serializedBreakpoints);
                versionController._clearBreakpointsWhenTooMany(breakpointsSetting, maxBreakpointsCount);
                InspectorTest.addResult("Number of breakpoints left in the setting after the test: " + breakpointsSetting.get().length + ".");
                InspectorTest.addResult("");
            }

            runClearBreakpointsTest(0, 500);
            runClearBreakpointsTest(1, 500);
            runClearBreakpointsTest(2, 500);
            runClearBreakpointsTest(499, 500);
            runClearBreakpointsTest(500, 500);
            runClearBreakpointsTest(501, 500);
            runClearBreakpointsTest(1000, 500);
            next();
        }
    ]);
}
</script>
</head>
<body onload="runTest()">
<p>Tests inspector version controller.</p>
</body>
</html>