Backed out changeset 71a2a9d7618e

This commit is contained in:
Josh Matthews 2012-10-03 13:12:12 -04:00
parent 666487f922
commit 1e9909c85a
5 changed files with 0 additions and 154 deletions

View File

@ -2,8 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
function nsContextMenu(aXulMenu, aBrowser, aIsShift) {
this.shouldDisplay = true;
this.initMenu(aBrowser, aXulMenu, aIsShift);
@ -1008,10 +1006,6 @@ nsContextMenu.prototype = {
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var channel = ioService.newChannelFromURI(makeURI(linkURL));
if (channel instanceof Ci.nsIPrivateBrowsingChannel) {
var docIsPrivate = PrivateBrowsingUtils.isWindowPrivate(doc.defaultView);
channel.setPrivate(docIsPrivate);
}
channel.notificationCallbacks = new callbacks();
let flags = Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS;

View File

@ -193,9 +193,6 @@ _BROWSER_FILES = \
bug564387.html \
bug564387_video1.ogv \
bug564387_video1.ogv^headers^ \
browser_save_link.js \
bug792517-2.html \
bug792517.sjs \
browser_scope.js \
browser_selectTabAtIndex.js \
browser_tab_dragdrop.js \

View File

@ -1,127 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init();
let tempScope = {};
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
let NetUtil = tempScope.NetUtil;
// Trigger a save of a link in public mode, then trigger an identical save
// in private mode and ensure that the second request is differentiated from
// the first by checking the cookies that are sent.
function triggerSave(aCallback) {
var fileName;
gBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/bug792517-2.html");
gBrowser.addEventListener("pageshow", function pageShown(event) {
if (event.target.location == "about:blank")
return;
gBrowser.removeEventListener("pageshow", pageShown);
executeSoon(function () {
document.addEventListener("popupshown", contextMenuOpened);
var link = gBrowser.contentDocument.getElementById("fff");
EventUtils.synthesizeMouseAtCenter(link,
{ type: "contextmenu", button: 2 },
gBrowser.contentWindow);
});
});
function contextMenuOpened(event) {
event.currentTarget.removeEventListener("popupshown", contextMenuOpened);
// Create the folder the link will be saved into.
var destDir = createTemporarySaveDirectory();
var destFile = destDir.clone();
MockFilePicker.displayDirectory = destDir;
MockFilePicker.showCallback = function(fp) {
fileName = fp.defaultString;
destFile.append (fileName);
MockFilePicker.returnFiles = [destFile];
MockFilePicker.filterIndex = 1; // kSaveAsType_URL
};
mockTransferCallback = function(a) onTransferComplete(a, destFile, destDir);
// Select "Save Link As" option from context menu
var saveLinkCommand = document.getElementById("context-savelink");
saveLinkCommand.doCommand();
event.target.hidePopup();
}
function onTransferComplete(downloadSuccess, destFile, destDir) {
ok(downloadSuccess, "Link should have been downloaded successfully");
// Give the request a chance to finish
executeSoon(function() aCallback(destFile, destDir));
}
}
function readFile(file, callback) {
let channel = NetUtil.newChannel(file);
channel.contentType = "application/javascript";
NetUtil.asyncFetch(channel, function(inputStream, status) {
ok(Components.isSuccessCode(status),
"file was read successfully");
let content = NetUtil.readInputStreamToString(inputStream,
inputStream.available());
executeSoon(function() callback(content));
});
}
function test() {
waitForExplicitFinish();
let pb = Cc["@mozilla.org/privatebrowsing;1"]
.getService(Ci.nsIPrivateBrowsingService);
mockTransferRegisterer.register();
registerCleanupFunction(function () {
mockTransferRegisterer.unregister();
MockFilePicker.cleanup();
pb.privateBrowsingEnabled = false;
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
gBrowser.addTab();
gBrowser.removeCurrentTab();
});
triggerSave(function(destFile, destDir) {
readFile(destFile, function(content) {
is(content, "cookie-not-present", "no cookie should be sent");
destDir.remove(true);
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
pb.privateBrowsingEnabled = true;
triggerSave(function(destFile, destDir) {
readFile(destFile, function(content) {
is(content, "cookie-not-present", "no cookie should be sent");
destDir.remove(true);
finish();
});
});
});
});
}
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
this);
function createTemporarySaveDirectory() {
var saveDir = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
saveDir.append("testsavedir");
if (!saveDir.exists())
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
return saveDir;
}

View File

@ -1,5 +0,0 @@
<html>
<body>
<a href="bug792517.sjs" id="fff">this is a link</a>
</body>
</html>

View File

@ -1,13 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
function handleRequest(aRequest, aResponse) {
aResponse.setStatusLine(aRequest.httpVersion, 200);
if (aRequest.hasHeader('Cookie')) {
aResponse.write("cookie-present");
} else {
aResponse.setHeader("Set-Cookie", "foopy=1");
aResponse.write("cookie-not-present");
}
}