~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-location/test/initialization-iframe.html

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--
 
2
@license
 
3
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
 
4
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 
5
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 
6
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 
7
Code distributed by Google as part of the polymer project is also
 
8
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 
9
-->
 
10
 
 
11
<!DOCTYPE html>
 
12
<html>
 
13
  <head>
 
14
    <meta charset="utf-8">
 
15
    <title>Base source for injecting into an iframe for tests</title>
 
16
    <script src="../../webcomponentsjs/webcomponents.js"></script>
 
17
    <link rel='import' href='./initialization-cases.html'>
 
18
  </head>
 
19
  <body>
 
20
    <script>
 
21
      window.addEventListener("message", messageReceived, false);
 
22
 
 
23
      window.addEventListener('WebComponentsReady', function() {
 
24
        window.parent.postMessage({
 
25
          'type': 'ready'
 
26
        }, '*');
 
27
      });
 
28
 
 
29
      var appendBodyReceived = false;
 
30
      function messageReceived(msg) {
 
31
        if (!msg.data) {
 
32
          console.error('got invalid msg?');
 
33
        }
 
34
        // the parent can (at any time) ask for our URL.
 
35
        if (msg.data.type === 'urlQuery') {
 
36
          msg.source.postMessage({
 
37
            'type': 'urlQueryResponse',
 
38
            'href': window.location.href,
 
39
            'pathname': window.location.pathname,
 
40
            'hash': window.location.hash,
 
41
            'search': window.location.search
 
42
          }, '*');
 
43
        } else if (msg.data.type === 'appendBody') {
 
44
          if (appendBodyReceived) {
 
45
            throw new Error('should only receive at most one appendBody call');
 
46
          }
 
47
          var element = document.createElement(msg.data.tagName);
 
48
          document.body.appendChild(element);
 
49
          appendBodyReceived = true;
 
50
        }
 
51
      }
 
52
 
 
53
      window.addEventListener('error', function(e) {
 
54
        window.parent.postMessage({
 
55
          'type': 'error',
 
56
          'error': e.message
 
57
        }, '*');
 
58
      });
 
59
    </script>
 
60
  </body>
 
61
</html>