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

function test()
{
    var object = [6, 28, 496];
    var localObject = WebInspector.RemoteObject.fromLocalObject(object);

    function getItem(index)
    {
        return this[index];
    }

    function getItemCallback(result)
    {
        InspectorTest.addResult("getItem(1) result: " + result);
    }

    function compareAndSwap(index, value, newValue)
    {
        if (this[index] !== value)
            throw "Data corrupted";
        this[index] = newValue;
        return "Done";
    }

    function compareAndSwapCallback(result, wasThrown)
    {
        InspectorTest.addResult("compareAndSwap(1, 28, 42) result: " + result.description);
    }

    function exceptionCallback(result, wasThrown)
    {
        InspectorTest.addResult("compareAndSwap(1, 28, 42) throws exception: " + wasThrown);
    }

    function guessWhat()
    {
        return 42;
    }

    function guessWhatCallback(result, wasThrown)
    {
        InspectorTest.addResult("guessWhat() result: " + result.description);
    }

    localObject.callFunctionJSON(getItem, [{value: 1}], getItemCallback);
    localObject.callFunction(compareAndSwap, [{value: 1}, {value: 28}, {value: 42}], compareAndSwapCallback);
    localObject.callFunction(compareAndSwap, [{value: 1}, {value: 28}, {value: 42}], exceptionCallback);
    localObject.callFunction(guessWhat, undefined, guessWhatCallback);
    localObject.callFunction(compareAndSwap, [{value: 0}, {value: 6}, {value: 7}]);
    InspectorTest.addResult("Final value of object: [" + object.join(", ") + "]");
    InspectorTest.completeTest();
}

</script>
</head>

<body onload="runTest()">
<p>Tests callFunction on local remote objects.</p>
</body>
</html>