content/base/test/file_mozfiledataurl_inner.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 <!doctype html>
michael@0 2 <html>
michael@0 3 <script type="application/javascript;version=1.8">
michael@0 4 var img;
michael@0 5 var audio;
michael@0 6 var iframe;
michael@0 7
michael@0 8 addEventListener("message", function(e) {
michael@0 9 mess = JSON.parse(e.data);
michael@0 10
michael@0 11 if ("img" in mess)
michael@0 12 img.src = mess.img;
michael@0 13 else if ("audio" in mess)
michael@0 14 audio.src = mess.audio
michael@0 15 else if ("iframe" in mess)
michael@0 16 iframe.src = mess.iframe;
michael@0 17 else if ("xhr" in mess) {
michael@0 18 let xhr = new XMLHttpRequest();
michael@0 19 xhr.onload = function() {
michael@0 20 sendItUp({ text: xhr.responseText });
michael@0 21 }
michael@0 22 try {
michael@0 23 xhr.open("GET", mess.xhr);
michael@0 24 xhr.send();
michael@0 25 }
michael@0 26 catch (ex) {
michael@0 27 sendItUp({ didThrow: true });
michael@0 28 }
michael@0 29 }
michael@0 30
michael@0 31 }, false);
michael@0 32
michael@0 33 function sendItUp(obj) {
michael@0 34 window.parent.postMessage(JSON.stringify(obj), "*");
michael@0 35 }
michael@0 36
michael@0 37 function audioNotifyParent(e) {
michael@0 38 sendItUp({ type: e.type });
michael@0 39 }
michael@0 40
michael@0 41 function imgNotifyParent(e) {
michael@0 42 sendItUp({ type: e.type,
michael@0 43 width: e.target.width,
michael@0 44 height: e.target.height });
michael@0 45 }
michael@0 46
michael@0 47 function iframeNotifyParent(e) {
michael@0 48 res = { type: e.type };
michael@0 49 try {
michael@0 50 res.text = e.target.contentDocument.getElementsByTagName("p")[0].textContent;
michael@0 51 } catch (ex) {}
michael@0 52 try {
michael@0 53 res.imgWidth = e.target.contentDocument.getElementById("img").width;
michael@0 54 } catch (ex) {}
michael@0 55
michael@0 56 sendItUp(res);
michael@0 57 }
michael@0 58
michael@0 59 onload = function() {
michael@0 60 img = document.getElementById('img');
michael@0 61 img.onerror = img.onload = imgNotifyParent;
michael@0 62 iframe = document.getElementById('iframe');
michael@0 63 iframe.onerror = iframe.onload = iframeNotifyParent;
michael@0 64 audio = document.getElementById('audio');
michael@0 65 audio.onerror = audio.onloadeddata = audioNotifyParent;
michael@0 66 }
michael@0 67
michael@0 68 </script>
michael@0 69 <body>
michael@0 70 <img id=img>
michael@0 71 <audio id=audio>
michael@0 72 <iframe id=iframe></iframe>
michael@0 73 </html>

mercurial