Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 3 | <!doctype html> |
michael@0 | 4 | |
michael@0 | 5 | <html> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"/> |
michael@0 | 8 | <title>Network Monitor test page</title> |
michael@0 | 9 | </head> |
michael@0 | 10 | |
michael@0 | 11 | <body> |
michael@0 | 12 | <p>Performing requests</p> |
michael@0 | 13 | |
michael@0 | 14 | <p> |
michael@0 | 15 | <canvas width="100" height="100"></canvas> |
michael@0 | 16 | </p> |
michael@0 | 17 | |
michael@0 | 18 | <hr/> |
michael@0 | 19 | |
michael@0 | 20 | <form method="post" action="#" enctype="multipart/form-data" target="target" id="post-form"> |
michael@0 | 21 | <input type="text" name="param1" value="value1"/> |
michael@0 | 22 | <input type="text" name="param2" value="value2"/> |
michael@0 | 23 | <input type="text" name="param3" value="value3"/> |
michael@0 | 24 | <input type="submit"/> |
michael@0 | 25 | </form> |
michael@0 | 26 | <iframe name="target"></iframe> |
michael@0 | 27 | |
michael@0 | 28 | <script type="text/javascript"> |
michael@0 | 29 | |
michael@0 | 30 | function ajaxGet(aUrl, aCallback) { |
michael@0 | 31 | var xhr = new XMLHttpRequest(); |
michael@0 | 32 | xhr.open("GET", aUrl + "?param1=value1¶m2=value2¶m3=value3", true); |
michael@0 | 33 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
michael@0 | 34 | xhr.onload = function() { |
michael@0 | 35 | aCallback(); |
michael@0 | 36 | }; |
michael@0 | 37 | xhr.send(); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function ajaxPost(aUrl, aCallback) { |
michael@0 | 41 | var xhr = new XMLHttpRequest(); |
michael@0 | 42 | xhr.open("POST", aUrl, true); |
michael@0 | 43 | xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
michael@0 | 44 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
michael@0 | 45 | xhr.onload = function() { |
michael@0 | 46 | aCallback(); |
michael@0 | 47 | }; |
michael@0 | 48 | var params = "param1=value1¶m2=value2¶m3=value3"; |
michael@0 | 49 | xhr.send(params); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function ajaxMultipart(aUrl, aCallback) { |
michael@0 | 53 | var xhr = new XMLHttpRequest(); |
michael@0 | 54 | xhr.open("POST", aUrl, true); |
michael@0 | 55 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
michael@0 | 56 | xhr.onload = function() { |
michael@0 | 57 | aCallback(); |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | getCanvasElem().toBlob((blob) => { |
michael@0 | 61 | var formData = new FormData(); |
michael@0 | 62 | formData.append("param1", "value1"); |
michael@0 | 63 | formData.append("file", blob, "filename.png"); |
michael@0 | 64 | xhr.send(formData); |
michael@0 | 65 | }); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function submitForm() { |
michael@0 | 69 | var form = document.querySelector("#post-form"); |
michael@0 | 70 | form.submit(); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function getCanvasElem() { |
michael@0 | 74 | return document.querySelector("canvas"); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | function initCanvas() { |
michael@0 | 78 | var canvas = getCanvasElem(); |
michael@0 | 79 | var ctx = canvas.getContext("2d"); |
michael@0 | 80 | ctx.fillRect(0,0,100,100); |
michael@0 | 81 | ctx.clearRect(20,20,60,60); |
michael@0 | 82 | ctx.strokeRect(25,25,50,50); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | function performRequests(aUrl) { |
michael@0 | 86 | ajaxGet(aUrl, () => { |
michael@0 | 87 | ajaxPost(aUrl, () => { |
michael@0 | 88 | ajaxMultipart(aUrl, () => { |
michael@0 | 89 | submitForm(); |
michael@0 | 90 | }); |
michael@0 | 91 | }); |
michael@0 | 92 | }); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | initCanvas(); |
michael@0 | 96 | </script> |
michael@0 | 97 | </body> |
michael@0 | 98 | |
michael@0 | 99 | </html> |