addon-sdk/source/lib/sdk/ui/frame/view.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/lib/sdk/ui/frame/view.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,18 @@
     1.4 +<script>
     1.5 +// HACK: This is not an ideal way to deliver chrome messages
     1.6 +// to a innef frame content but seems only way that would
     1.7 +// make `event.source` an this (outer frame) window.
     1.8 +window.onmessage = function(event) {
     1.9 +  var frame = document.querySelector("iframe");
    1.10 +  var content = frame.contentWindow;
    1.11 +  // If message is posted from chrome it has no `event.source`.
    1.12 +  if (event.source === null)
    1.13 +    content.postMessage(event.data, "*");
    1.14 +};
    1.15 +// Hack: Ideally we would have used srcdoc on iframe, but in
    1.16 +// that case origin of document is either content which is unable
    1.17 +// to load add-on resources or a chrome to which add-on resource
    1.18 +// can not send messages back.
    1.19 +document.documentElement.style.overflow = "hidden";
    1.20 +document.documentElement.innerHTML = atob(location.hash.substr(1));
    1.21 +</script>

mercurial