| <html> |
| <head><title>Privileged Apis test</title> |
| <script type='text/javascript' src='chrome_frame_tester_helpers.js'> |
| </script> |
| <script type='text/javascript'> |
| var testName = 'PrivilegedApis'; |
| function OnNavigationFailed(msg) { |
| onFailure(testName, 1, 'ChromeFrame Navigation failed: ' + msg); |
| } |
| |
| function OnPrivateMessage() { |
| onFailure(testName, 1, 'OnPrivateMessage should not execute'); |
| } |
| |
| function OnChromeFrameMessage(evt) { |
| try { |
| var d = new String(evt.data); |
| appendStatus('Message: ' + d); |
| if (d == 'succeed') { |
| onSuccess(testName, 1); |
| } else { |
| onFailure(testName, 1, 'unexpected data'); |
| } |
| } catch (e) { |
| onFailure(testName, 1, 'exception in OnChromeFrameMessage'); |
| } |
| } |
| |
| function tryPrivateMessage() { |
| var cf = GetChromeFrame(); |
| |
| try { |
| // Any message received by this listener is a failure. |
| // This succeeds in FF, but throws an exception in IE. |
| cf.addEventListener('onprivatemessage', OnPrivateMessage, false); |
| } catch(e) { |
| appendStatus('addEventListener onprivatemessage threw exception') |
| } |
| |
| // If this invocation succeeds, then 'fail' is reflected by the frame |
| // and we fail in the OnChromeFrameMessage handler above. |
| try { |
| cf.postPrivateMessage('fail', String(document.location), '*'); |
| onFailure(testName, 1, 'postPrivateMessage should throw'); |
| } catch(e) { |
| } |
| appendStatus('After postPrivateMessage') |
| } |
| |
| function OnChromeFrameLoaded(url) { |
| tryPrivateMessage(); |
| |
| // The frame reflects this twice, first to a bogus target |
| // and again to the default target '*'. We succeed if we |
| // get the reflected message to OnChromeFrameMessage and not to |
| // OnPrivateMessage. |
| var cf = GetChromeFrame(); |
| cf.postMessage('succeed'); |
| appendStatus('After cf.postMessage') |
| } |
| |
| function GetChromeFrame() { |
| return window.document.ChromeFrame; |
| } |
| </script> |
| </head> |
| <body> |
| <div id='statusPanel' style='border: 1px solid red; width: 100%'> |
| Test running.... |
| </div> |
| |
| <span id='ChromeFrameSpan'></span> |
| <!-- TODO(siggi): Test setting onprivatemessage in these params --> |
| <script type='text/javascript'> |
| insertControl( |
| 'ChromeFrameSpan', |
| { "src": "privileged_apis_frame.html", |
| "eventHandlers": { |
| "onload": "OnChromeFrameLoaded(arguments[0]);", |
| "onloaderror": "OnNavigationFailed();", |
| "onmessage": "return OnChromeFrameMessage(arguments[0]);" |
| }, |
| "embedAttributes": { "privileged_mode": "1" } |
| }); |
| </script> |
| <p>Tests that privileged apis are unavailable from regular pages</p> |
| </body> |
| </html> |