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 | |
michael@0 | 4 | const Cc = Components.classes; |
michael@0 | 5 | const Ci = Components.interfaces; |
michael@0 | 6 | |
michael@0 | 7 | const gPostData = "postdata=true"; |
michael@0 | 8 | |
michael@0 | 9 | function test() { |
michael@0 | 10 | waitForExplicitFinish(); |
michael@0 | 11 | |
michael@0 | 12 | let tab = gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 13 | registerCleanupFunction(function () { |
michael@0 | 14 | gBrowser.removeTab(tab); |
michael@0 | 15 | }); |
michael@0 | 16 | |
michael@0 | 17 | var dataStream = Cc["@mozilla.org/io/string-input-stream;1"]. |
michael@0 | 18 | createInstance(Ci.nsIStringInputStream); |
michael@0 | 19 | dataStream.data = gPostData; |
michael@0 | 20 | |
michael@0 | 21 | var postStream = Cc["@mozilla.org/network/mime-input-stream;1"]. |
michael@0 | 22 | createInstance(Ci.nsIMIMEInputStream); |
michael@0 | 23 | postStream.addHeader("Content-Type", "application/x-www-form-urlencoded"); |
michael@0 | 24 | postStream.addContentLength = true; |
michael@0 | 25 | postStream.setData(dataStream); |
michael@0 | 26 | |
michael@0 | 27 | tab.linkedBrowser.loadURIWithFlags("http://mochi.test:8888/browser/docshell/test/browser/print_postdata.sjs", 0, null, null, postStream); |
michael@0 | 28 | onTabLoad(tab, function (doc) { |
michael@0 | 29 | var bodyText = doc.body.textContent; |
michael@0 | 30 | is(bodyText, gPostData, "post data was submitted correctly"); |
michael@0 | 31 | finish(); |
michael@0 | 32 | }); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function onTabLoad(tab, cb) { |
michael@0 | 36 | tab.linkedBrowser.addEventListener("load", function listener(event) { |
michael@0 | 37 | if (event.originalTarget != tab.linkedBrowser.contentDocument || |
michael@0 | 38 | event.target.location.href == "about:blank") { |
michael@0 | 39 | info("skipping spurious load event"); |
michael@0 | 40 | return; |
michael@0 | 41 | } |
michael@0 | 42 | tab.linkedBrowser.removeEventListener("load", listener, true); |
michael@0 | 43 | cb(tab.linkedBrowser.contentDocument); |
michael@0 | 44 | }, true); |
michael@0 | 45 | } |