OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head><title>Privileged Apis test</title> |
| 3 <script type='text/javascript' src='chrome_frame_tester_helpers.js'> |
| 4 </script> |
| 5 <script type='text/javascript'> |
| 6 var testName = 'PrivilegedApis'; |
| 7 function OnNavigationFailed(msg) { |
| 8 onFailure(testName, 1, 'ChromeFrame Navigation failed: ' + msg); |
| 9 } |
| 10 |
| 11 function OnPrivateMessage() { |
| 12 onFailure(testName, 1, 'OnPrivateMessage should not execute'); |
| 13 } |
| 14 |
| 15 function OnChromeFrameMessage(evt) { |
| 16 try { |
| 17 var d = new String(evt.data); |
| 18 appendStatus('Message: ' + d); |
| 19 if (d == 'succeed') { |
| 20 onSuccess(testName, 1); |
| 21 } else { |
| 22 onFailure(testName, 1, 'unexpected data'); |
| 23 } |
| 24 } catch (e) { |
| 25 onFailure(testName, 1, 'exception in OnChromeFrameMessage'); |
| 26 } |
| 27 } |
| 28 |
| 29 function OnChromeFrameLoaded(url) { |
| 30 var cf = GetChromeFrame(); |
| 31 |
| 32 try { |
| 33 // Any message received by this listener is a failure. |
| 34 // This succeeds in FF, but throws an exception in IE. |
| 35 cf.addEventListener('onprivatemessage', OnPrivateMessage, false); |
| 36 } catch(e) { |
| 37 cf.onprivatemessage = |
| 38 appendStatus('addEventListener onprivatemessage threw exception') |
| 39 } |
| 40 |
| 41 // If this invocation succeeds, then 'fail' is reflected by the frame |
| 42 // and we fail in the OnChromeFrameMessage handler above. |
| 43 try { |
| 44 cf.postPrivateMessage('fail', String(document.location), '*'); |
| 45 onFailure(testName, 1, 'postPrivateMessage should throw'); |
| 46 } catch(e) { |
| 47 } |
| 48 appendStatus('After postPrivateMessage') |
| 49 // The frame reflects this twice, first to a bogus target |
| 50 // and again to the default target '*'. We succeed if we |
| 51 // get the reflected message to OnChromeFrameMessage and not to |
| 52 // OnPrivateMessage. |
| 53 cf.postMessage('succeed'); |
| 54 } |
| 55 |
| 56 function GetChromeFrame() { |
| 57 return window.document.ChromeFrame; |
| 58 } |
| 59 </script> |
| 60 </head> |
| 61 <body> |
| 62 <div id='statusPanel' style='border: 1px solid red; width: 100%'> |
| 63 Test running.... |
| 64 </div> |
| 65 |
| 66 <!-- TODO(siggi): Test setting onprivatemessage in these params --> |
| 67 <object id='ChromeFrame' width='500' height='500' |
| 68 codebase='http://www.google.com' |
| 69 classid='CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A'> |
| 70 <param name='src' value='privileged_apis_frame.html'> |
| 71 <param name='onload' value='OnChromeFrameLoaded(arguments[0]);'> |
| 72 <param name='onloaderror' value='OnNavigationFailed();'> |
| 73 <param name='onmessage' value='OnChromeFrameMessage(arguments[0]);'> |
| 74 <embed id='ChromeFramePlugin' width='500' height='500' name='ChromeFra
me' |
| 75 src='privileged_apis_frame.html' |
| 76 type='application/chromeframe' |
| 77 onload='OnChromeFrameLoaded(arguments[0]);' |
| 78 onloaderror='OnNavigationFailed();' |
| 79 onmessage='return OnChromeFrameMessage(arguments[0]);' |
| 80 privileged_mode='1' |
| 81 </embed> |
| 82 </object> |
| 83 <p>Tests that privileged apis are unavailable from regular pages</p> |
| 84 </body> |
| 85 </html> |
OLD | NEW |