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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <script>
michael@0 2 // HACK: This is not an ideal way to deliver chrome messages
michael@0 3 // to a innef frame content but seems only way that would
michael@0 4 // make `event.source` an this (outer frame) window.
michael@0 5 window.onmessage = function(event) {
michael@0 6 var frame = document.querySelector("iframe");
michael@0 7 var content = frame.contentWindow;
michael@0 8 // If message is posted from chrome it has no `event.source`.
michael@0 9 if (event.source === null)
michael@0 10 content.postMessage(event.data, "*");
michael@0 11 };
michael@0 12 // Hack: Ideally we would have used srcdoc on iframe, but in
michael@0 13 // that case origin of document is either content which is unable
michael@0 14 // to load add-on resources or a chrome to which add-on resource
michael@0 15 // can not send messages back.
michael@0 16 document.documentElement.style.overflow = "hidden";
michael@0 17 document.documentElement.innerHTML = atob(location.hash.substr(1));
michael@0 18 </script>

mercurial