2 <head><title>Privileged Apis test</title>
3 <script type='text/javascript' src='chrome_frame_tester_helpers.js'>
5 <script type='text/javascript'>
6 var testName = 'PrivilegedApis';
7 function OnNavigationFailed(msg) {
8 onFailure(testName, 1, 'ChromeFrame Navigation failed: ' + msg);
11 function OnPrivateMessage() {
12 onFailure(testName, 1, 'OnPrivateMessage should not execute');
15 function OnChromeFrameMessage(evt) {
17 var d = new String(evt.data);
18 appendStatus('Message: ' + d);
20 onSuccess(testName, 1);
22 onFailure(testName, 1, 'unexpected data');
25 onFailure(testName, 1, 'exception in OnChromeFrameMessage');
29 function tryPrivateMessage() {
30 var cf = GetChromeFrame();
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);
37 appendStatus('addEventListener onprivatemessage threw exception')
40 // If this invocation succeeds, then 'fail' is reflected by the frame
41 // and we fail in the OnChromeFrameMessage handler above.
43 cf.postPrivateMessage('fail', String(document.location), '*');
44 onFailure(testName, 1, 'postPrivateMessage should throw');
47 appendStatus('After postPrivateMessage')
50 function OnChromeFrameLoaded(url) {
53 // The frame reflects this twice, first to a bogus target
54 // and again to the default target '*'. We succeed if we
55 // get the reflected message to OnChromeFrameMessage and not to
57 var cf = GetChromeFrame();
58 cf.postMessage('succeed');
59 appendStatus('After cf.postMessage')
62 function GetChromeFrame() {
63 return window.document.ChromeFrame;
68 <div id='statusPanel' style='border: 1px solid red; width: 100%'>
72 <span id='ChromeFrameSpan'></span>
73 <!-- TODO(siggi): Test setting onprivatemessage in these params -->
74 <script type='text/javascript'>
77 { "src": "privileged_apis_frame.html",
79 "onload": "OnChromeFrameLoaded(arguments[0]);",
80 "onloaderror": "OnNavigationFailed();",
81 "onmessage": "return OnChromeFrameMessage(arguments[0]);"
83 "embedAttributes": { "privileged_mode": "1" }
86 <p>Tests that privileged apis are unavailable from regular pages</p>