aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/tests/LiveConnect/jjs_eval_test.js
blob: 55512dfdd6870e4164f3e568456c5d114a6295d9 (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
/******************************************************
 * Tests for parameter conversion between Java and JS *
 ******************************************************/


function jjsEvalTests() {

    document.getElementById("results").innerHTML +=  "<h2>Java -> JS Eval Test:</h2>";

    var tbl = document.createElement("table");
    var tblBody = document.createElement("tbody");
    var columnNames = new Array();
    columnNames[0] = "Evaluating";
    columnNames[1] = "Expected result";
    columnNames[2] = "Result";
    columnNames[3] = "Status";
    var row;

    createResultTable(tbl, tblBody, columnNames);

    try {
        row = document.createElement("tr");
        evalstr = "document.location";
        expectedvalue = eval(evalstr);
        actualValue = PluginTest.jjsEvalTest(evalstr);
        addResult(evalstr, expectedvalue, actualValue, row);
        check(actualValue, expectedvalue, "string", row);
    } catch (e) {
        error(type, "", e, row);
    }
    tblBody.appendChild(row);

    try {
        row = document.createElement("tr");
        evalstr = "1+1";
        expectedvalue = eval(evalstr);
        actualValue = PluginTest.jjsEvalTest(evalstr);
        addResult(evalstr, expectedvalue, actualValue, row);
        check(actualValue, expectedvalue, "string", row);
    } catch (e) {
        error(type, "", e, row);
    }
    tblBody.appendChild(row);

    try {
        row = document.createElement("tr");
        evalstr = "typeof(true)";
        expectedvalue = eval(evalstr);
        actualValue = PluginTest.jjsEvalTest(evalstr);
        addResult(evalstr, expectedvalue, actualValue, row);
        check(actualValue, expectedvalue, "string", row);
    } catch (e) {
        error(type, "", e, row);
    }
    tblBody.appendChild(row);
}