summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/data/postmessage_basic_host.html
blob: e5ecef93d7ec4bb5c2927b6d889ce487d595bd74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!-- saved from url=(0014)about:internet -->
<html>
<!-- This page is meant to load inside the host browser like IE/FF -->
  <head>
    <script type="text/javascript" src="chrome_frame_tester_helpers.js">
    </script>
    <script type="text/javascript">
      var post_message_reply_received = 0;

      function onChromeFrameLoaded() {
        appendStatus('Chrome frame loaded...');
        document.ChromeFrame.postMessage('Hello from host');
        setTimeout(onPostMessageFailure, 10000);
      }

      function onNavigationFailed(msg) {
        onFailure('PostMessage', 1, 'ChromeFrame Navigation failed: ' + msg);
      }

      function onChromeFrameMessage(evt) {
        try {
          var d = new String(evt.data);
          appendStatus('Message: ' + d);
          if (d == 'Hello from ChromeFrame') {
            post_message_reply_received = 1;
            onSuccess('PostMessage', 1);
          } else {
            onFailure('PostMessage', 1, 'unexpected data');
          }
        } catch (e) {
          onFailure('PostMessage', 1, 'exception in onChromeFrameMessage');
        }
      }

      function onPostMessageFailure() {
        if (!post_message_reply_received) {
          onFailure('PostMessage', 1, 'Did not receive reply back from frame');
        }
      }
    </script>
  </head>

  <body>
    <object id="ChromeFrame" width="500" height ="300"
        codebase="http://www.google.com"
        classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A">
        <param name="src" value="postmessage_basic_frame.html">
        <param name="onload" value="onChromeFrameLoaded();">
        <param name="onloaderror" value="onNavigationFailed();">
        <param name="onmessage" value="onChromeFrameMessage(arguments[0]);">
        <embed id="ChromeFramePlugin" name="ChromeFrame"
            width="500" height="500"
            src="postmessage_basic_frame.html"
            type="application/chromeframe"
            onload="onChromeFrameLoaded();"
            onloaderror="onNavigationFailed();"
            onmessage="onChromeFrameMessage(arguments[0]);">
        </embed>
    </object>
    <br>
    <br>
    <p>Test for PostMessage from the host browser to ChromeFrame and back</p>
    <button onclick="document.ChromeFrame.postMessage('Message from button');">
      Send message to frame</button>
    <div id="statusPanel" style="border: 1px solid red; width: 100%">
      Test running....
    </div>
  </body>
</html>