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
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'>
21
window.addEventListener("message", messageReceived, false);
23
window.addEventListener('WebComponentsReady', function() {
24
window.parent.postMessage({
29
var appendBodyReceived = false;
30
function messageReceived(msg) {
32
console.error('got invalid msg?');
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
43
} else if (msg.data.type === 'appendBody') {
44
if (appendBodyReceived) {
45
throw new Error('should only receive at most one appendBody call');
47
var element = document.createElement(msg.data.tagName);
48
document.body.appendChild(element);
49
appendBodyReceived = true;
53
window.addEventListener('error', function(e) {
54
window.parent.postMessage({