OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 description('Unittests for private scripts.'); | 8 description('Unittests for private scripts.'); |
9 if (internals) | 9 if (!internals || !internals.privateScriptTest()) |
10 debug('This test needs window.internals.'); | 10 debug('This test needs window.internals.privateScriptTest().'); |
11 | 11 |
12 internals.doNothing(); | 12 var privateScriptTest = internals.privateScriptTest(); |
13 shouldBe('internals.return123()', '123'); | 13 privateScriptTest.doNothing(); |
14 shouldBe('internals.echoInteger(111)', '111'); | 14 shouldBe('privateScriptTest.return123()', '123'); |
15 shouldBeEqualToString('internals.echoString("foo")', 'foo') | 15 shouldBe('privateScriptTest.echoInteger(111)', '111'); |
16 shouldBe('internals.addInteger(111, 222)', '333'); | 16 shouldBeEqualToString('privateScriptTest.echoString("foo")', 'foo') |
17 shouldBeEqualToString('internals.addString("foo", "bar")', 'foobar') | 17 shouldBe('privateScriptTest.addInteger(111, 222)', '333'); |
| 18 shouldBeEqualToString('privateScriptTest.addString("foo", "bar")', 'foobar') |
18 | 19 |
19 shouldBe('internals.getIntegerFromPrototype()', '0'); | 20 shouldBe('privateScriptTest.getIntegerFromPrototype()', '0'); |
20 internals.setIntegerToPrototype(123); | 21 privateScriptTest.setIntegerToPrototype(123); |
21 shouldBe('internals.getIntegerFromPrototype()', '123'); | 22 shouldBe('privateScriptTest.getIntegerFromPrototype()', '123'); |
22 | 23 |
23 shouldBe('internals.getIntegerFromDocument(document)', '0'); | 24 shouldBe('privateScriptTest.getIntegerFromDocument(document)', '0'); |
24 internals.setIntegerToDocument(document, 123); | 25 privateScriptTest.setIntegerToDocument(document, 123); |
25 shouldBe('internals.getIntegerFromDocument(document)', '123'); | 26 shouldBe('privateScriptTest.getIntegerFromDocument(document)', '123'); |
26 | 27 |
27 var node1 = internals.createElement(document); | 28 var node1 = privateScriptTest.createElement(document); |
28 var node2 = internals.createElement(document); | 29 var node2 = privateScriptTest.createElement(document); |
29 var node3 = internals.createElement(document); | 30 var node3 = privateScriptTest.createElement(document); |
30 var node4 = internals.createElement(document); | 31 var node4 = privateScriptTest.createElement(document); |
31 internals.appendChild(node1, node2); | 32 privateScriptTest.appendChild(node1, node2); |
32 internals.appendChild(node1, node3); | 33 privateScriptTest.appendChild(node1, node3); |
33 internals.appendChild(node1, node4); | 34 privateScriptTest.appendChild(node1, node4); |
34 shouldBe('internals.firstChild(node1)', 'node2'); | 35 shouldBe('privateScriptTest.firstChild(node1)', 'node2'); |
35 shouldBe('internals.nextSibling(node2)', 'node3'); | 36 shouldBe('privateScriptTest.nextSibling(node2)', 'node3'); |
36 shouldBe('internals.nextSibling(node3)', 'node4'); | 37 shouldBe('privateScriptTest.nextSibling(node3)', 'node4'); |
37 shouldBe('internals.nextSibling(node4)', 'null'); | 38 shouldBe('privateScriptTest.nextSibling(node4)', 'null'); |
38 | 39 |
39 var node5 = internals.createElement(document); | 40 var node5 = privateScriptTest.createElement(document); |
40 shouldBeEqualToString('internals.innerHTML(node5)', '') | 41 shouldBeEqualToString('privateScriptTest.innerHTML(node5)', '') |
41 internals.setInnerHTML(node5, '<div>foo</div>'); | 42 privateScriptTest.setInnerHTML(node5, '<div>foo</div>'); |
42 shouldBeEqualToString('internals.innerHTML(node5)', '<div>foo</div>') | 43 shouldBeEqualToString('privateScriptTest.innerHTML(node5)', '<div>foo</div>') |
43 var node6 = internals.firstChild(node5); | 44 var node6 = privateScriptTest.firstChild(node5); |
44 shouldBeEqualToString('internals.innerHTML(node6)', 'foo'); | 45 shouldBeEqualToString('privateScriptTest.innerHTML(node6)', 'foo'); |
45 | 46 |
46 var node7 = internals.createElement(document); | 47 var node7 = privateScriptTest.createElement(document); |
47 shouldBeEqualToString('internals.innerHTML(node7)', '') | 48 shouldBeEqualToString('privateScriptTest.innerHTML(node7)', '') |
48 internals.addClickListener(node7); | 49 privateScriptTest.addClickListener(node7); |
49 internals.clickNode(document, node7); | 50 privateScriptTest.clickNode(document, node7); |
50 shouldBeEqualToString('internals.innerHTML(node7)', 'clicked') | 51 shouldBeEqualToString('privateScriptTest.innerHTML(node7)', 'clicked') |
51 | 52 |
52 shouldBe('internals.readonlyShortAttribute', '123'); | 53 shouldBe('privateScriptTest.readonlyShortAttribute', '123'); |
53 shouldBe('internals.shortAttribute', '-1'); | 54 shouldBe('privateScriptTest.shortAttribute', '-1'); |
54 internals.shortAttribute = 111; | 55 privateScriptTest.shortAttribute = 111; |
55 shouldBe('internals.shortAttribute', '111'); | 56 shouldBe('privateScriptTest.shortAttribute', '111'); |
56 shouldBeEqualToString('internals.stringAttribute', 'xxx'); | 57 shouldBeEqualToString('privateScriptTest.stringAttribute', 'xxx'); |
57 internals.stringAttribute = "foo"; | 58 privateScriptTest.stringAttribute = "foo"; |
58 shouldBeEqualToString('internals.stringAttribute', 'foo'); | 59 shouldBeEqualToString('privateScriptTest.stringAttribute', 'foo'); |
59 shouldBe('internals.nodeAttribute', 'null'); | 60 shouldBe('privateScriptTest.nodeAttribute', 'null'); |
60 var node8 = internals.createElement(document); | 61 var node8 = privateScriptTest.createElement(document); |
61 internals.nodeAttribute = node8; | 62 privateScriptTest.nodeAttribute = node8; |
62 shouldBe('internals.nodeAttribute', 'node8'); | 63 shouldBe('privateScriptTest.nodeAttribute', 'node8'); |
63 | 64 |
64 </script> | 65 </script> |
65 </body> | 66 </body> |
66 </html> | 67 </html> |
OLD | NEW |