aboutsummaryrefslogtreecommitdiffstats
path: root/tests/reproducers/simple/JSToJSet/resources/JSToJava_Set.js
blob: 501577a18d2f69780b21b13cf69895da54fe95db (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
//dummy javascript class whose instance is passed as JSObject parameter:
function JSCar(mph,color){
    this.mph = mph;
    this.color = color;
}

function doSetTests( ){

    var urlArgs = document.URL.split("?");
    var testParams = urlArgs[1].split(";");
    var applet = document.getElementById('jstojSetApplet');
    var field = testParams[0];
    var value = testParams[1];

    if( value === "JavaScript"){
        if( field === "_char"){
            value = 97;
        }

        if( field === "_Character"){
            value = new (applet.Packages).java.lang.Character(65);
        }

        if( field === "_specialString"){
            value = "𠁎〒£$ǣ€𝍖";
        } 

        if( field === "_JSObject"){
            value =  new JSCar(100,"red");
        }

    }else if(value.indexOf('[') != -1){

        var elem = value.substring(1);
        value = new Array();
        eval('value[0] = elem');
    }

    eval('applet.' + field + '= value');

    //modifiing _intArray[0]    into  _intArray
    //          _DoubleArray[0] into  _DoubleArray   
    var nameEnd = field.indexOf('[');
    if( nameEnd != -1){
      field = field.substring(0,nameEnd);
    }
    
    applet.printNewValueAndFinish(field);
}