zecke@webkit.org | 1fccd86 | 2009-05-20 17:35:22 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <script> |
| 4 | function doTest() |
| 5 | { |
rniwa@webkit.org | 5cf7fa8 | 2012-06-15 07:38:37 +0000 | [diff] [blame] | 6 | if (window.testRunner) |
| 7 | testRunner.dumpAsText(); |
zecke@webkit.org | 1fccd86 | 2009-05-20 17:35:22 +0000 | [diff] [blame] | 8 | |
| 9 | var plugin = document.getElementById("testPlugin"); |
| 10 | var console = document.getElementById("console"); |
| 11 | |
| 12 | var o = { internalFunction : Object, doStuff: function() {return 20;}, stringProperty : 'str', nullProperty : null, undefinedProperty : undefined }; |
| 13 | |
| 14 | function report(property, result, expected) { |
| 15 | if (result !== expected) { |
| 16 | console.innerHTML += "FAILURE: " + property + "<br/>"; |
| 17 | } else { |
| 18 | console.innerHTML += "SUCCESS: " + property + "<br/>"; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | function shouldBeFunction(property, expected) { |
| 23 | report(property, plugin.testHasMethod(o, property), expected); |
| 24 | } |
| 25 | |
| 26 | function shouldBeProperty(property, expected) { |
| 27 | report(property, plugin.testHasProperty(o, property), expected); |
| 28 | } |
| 29 | |
| 30 | /* test hasmethod */ |
| 31 | console.innerHTML += "Testing hasmethod<br />"; |
| 32 | shouldBeFunction("internalFunction", true); |
| 33 | shouldBeFunction("doStuff", true); |
| 34 | shouldBeFunction("undefinedProperty", false); |
| 35 | |
| 36 | /* test hasproperty */ |
| 37 | console.innerHTML += "<br />Testing hasproperty<br />"; |
| 38 | shouldBeProperty("internalFunction", true); |
| 39 | shouldBeProperty("doStuff", true); |
| 40 | shouldBeProperty("stringProperty", true); |
| 41 | shouldBeProperty("nullProperty", true); |
| 42 | shouldBeProperty("undefinedProperty", true); |
| 43 | shouldBeProperty("notDefinedProperty", false); |
| 44 | } |
| 45 | </script> |
| 46 | </head> |
| 47 | <body onload="doTest();"> |
| 48 | <p>Test if the plugin can properly invoke the browserfuncs</p> |
| 49 | <embed id="testPlugin" type="application/x-webkit-test-netscape"></embed> |
| 50 | <div id="console"></div> |
| 51 | </body> |
| 52 | </html> |