jsobjc-simple.html 1.01 KB
Newer Older
ddkilzer's avatar
ddkilzer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<html>
<head><title> simple.html </title>
<script>
function print(message) {
    var paragraph = document.createElement('p');
    paragraph.appendChild(document.createTextNode(message));
    document.getElementById('console').appendChild(paragraph);
}

function test() {
    if (window.layoutTestController)
        layoutTestController.dumpAsText();
    if (!window.objCPlugin)
        return print('FAIL - no objCPlugin');
    objCPlugin.removeBridgeRestrictions_(window);
    if (!window.objc)
        return print('FAIL - no window.objc');
    
    // test creating an obj-c object
    var NSCell = objc('NSCell');
    print('got class: ' + NSCell);
darin's avatar
darin committed
22
    var cell = NSCell.alloc().init().autorelease();
ddkilzer's avatar
ddkilzer committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    print('created object: <' + cell.className() + '>');
    cell.setValue_forKey_('zoe', 'stringValue');
    print('set string value: ' + cell.stringValue());
    if (cell.stringValue() == 'zoe')
        print('PASS');
    else
        print('FAIL');
}
</script>
</head>
<body onload="test();">
<div id='console'/>
</body>
</html>