mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Backout e5269e137290, (bug 794606), e94dbc151121 (bug 794602), and 0ea0cfc7f6f4 (bug 792821) due to mochitest-other orange on a CLOSED TREE.
This commit is contained in:
parent
5d449321b9
commit
44a8d6faa6
@ -105,7 +105,7 @@ var stringBundle;
|
||||
persist.progressListener = xfer;
|
||||
|
||||
// save the canvas data to the file
|
||||
persist.saveURI(source, null, null, null, null, file, null);
|
||||
persist.saveURI(source, null, null, null, null, file);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -194,8 +194,6 @@ _BROWSER_FILES = \
|
||||
bug564387_video1.ogv \
|
||||
bug564387_video1.ogv^headers^ \
|
||||
browser_save_link.js \
|
||||
browser_save_private_link.js \
|
||||
bug792517.html \
|
||||
bug792517-2.html \
|
||||
bug792517.sjs \
|
||||
browser_scope.js \
|
||||
|
@ -1,116 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
MockFilePicker.init();
|
||||
|
||||
function checkDiskCacheFor(filename) {
|
||||
let visitor = {
|
||||
visitDevice: function(deviceID, deviceInfo) {
|
||||
if (deviceID == "disk")
|
||||
info(deviceID + " device contains " + deviceInfo.entryCount + " entries");
|
||||
return deviceID == "disk";
|
||||
},
|
||||
|
||||
visitEntry: function(deviceID, entryInfo) {
|
||||
info(entryInfo.key);
|
||||
is(entryInfo.key.contains(filename), false, "web content present in disk cache");
|
||||
}
|
||||
};
|
||||
cache.visitEntries(visitor);
|
||||
}
|
||||
|
||||
var cache = Cc["@mozilla.org/network/cache-service;1"]
|
||||
.getService(Ci.nsICacheService);
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
var fileName;
|
||||
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
gBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/bug792517.html");
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
pb.privateBrowsingEnabled = false;
|
||||
gBrowser.addTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
gBrowser.addEventListener("pageshow", function pageShown(event) {
|
||||
if (event.target.location == "about:blank")
|
||||
return;
|
||||
gBrowser.removeEventListener("pageshow", pageShown);
|
||||
|
||||
executeSoon(function () {
|
||||
document.addEventListener("popupshown", contextMenuOpened);
|
||||
|
||||
var img = gBrowser.contentDocument.getElementById("img");
|
||||
EventUtils.synthesizeMouseAtCenter(img,
|
||||
{ type: "contextmenu", button: 2 },
|
||||
gBrowser.contentWindow);
|
||||
});
|
||||
});
|
||||
|
||||
function contextMenuOpened(event) {
|
||||
cache.evictEntries(Ci.nsICache.STORE_ANYWHERE);
|
||||
|
||||
event.currentTarget.removeEventListener("popupshown", contextMenuOpened);
|
||||
|
||||
// Create the folder the image 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 = onTransferComplete;
|
||||
mockTransferRegisterer.register();
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
mockTransferRegisterer.unregister();
|
||||
MockFilePicker.cleanup();
|
||||
destDir.remove(true);
|
||||
});
|
||||
|
||||
// Select "Save Image As" option from context menu
|
||||
var saveVideoCommand = document.getElementById("context-saveimage");
|
||||
saveVideoCommand.doCommand();
|
||||
|
||||
event.target.hidePopup();
|
||||
}
|
||||
|
||||
function onTransferComplete(downloadSuccess) {
|
||||
ok(downloadSuccess, "Image file should have been downloaded successfully");
|
||||
|
||||
// Give the request a chance to finish and create a cache entry
|
||||
executeSoon(function() {
|
||||
checkDiskCacheFor(fileName);
|
||||
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;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<img src="moz.png" id="img">
|
||||
</body>
|
||||
</html>
|
@ -138,10 +138,9 @@ function addDownload(dm, aParams)
|
||||
let test = dm.getDownload(dl.id);
|
||||
|
||||
aParams.runBeforeStart.call(undefined, dl);
|
||||
|
||||
|
||||
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
|
||||
persist.savePrivacyAwareURI(dl.source, null, null, null, null, dl.targetFile,
|
||||
aParams.isPrivate);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
return [dl.targetFile, persist];
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||
wbp->SetProgressListener(this);
|
||||
|
||||
return wbp->SaveURI(imageURI, nullptr, docURI, nullptr, nullptr,
|
||||
mBackgroundFile, content->OwnerDoc()->GetLoadContext());
|
||||
mBackgroundFile);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -128,11 +128,6 @@ gcli.addCommand({
|
||||
ctx.drawWindow(window, left, top, width, height, "#fff");
|
||||
let data = canvas.toDataURL("image/png", "");
|
||||
|
||||
let loadContext = document.defaultView
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
|
||||
try {
|
||||
if (clipboard) {
|
||||
let io = Cc["@mozilla.org/network/io-service;1"]
|
||||
@ -151,6 +146,10 @@ gcli.addCommand({
|
||||
|
||||
let trans = Cc["@mozilla.org/widget/transferable;1"]
|
||||
.createInstance(Ci.nsITransferable);
|
||||
let loadContext = document.defaultView
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
trans.init(loadContext);
|
||||
trans.addDataFlavor(channel.contentType);
|
||||
trans.setTransferData(channel.contentType, wrapped, -1);
|
||||
@ -215,7 +214,7 @@ gcli.addCommand({
|
||||
Persist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
|
||||
|
||||
let source = ioService.newURI(data, "UTF8", null);
|
||||
persist.saveURI(source, null, null, null, null, file, loadContext);
|
||||
persist.saveURI(source, null, null, null, null, file);
|
||||
|
||||
div.textContent = gcli.lookup("screenshotSavedToFile") + " \"" + filename +
|
||||
"\"";
|
||||
|
@ -130,8 +130,7 @@ NS_IMPL_ISUPPORTS1(nsContentAreaDragDropDataProvider, nsIFlavorDataProvider)
|
||||
// into the file system
|
||||
nsresult
|
||||
nsContentAreaDragDropDataProvider::SaveURIToFile(nsAString& inSourceURIString,
|
||||
nsIFile* inDestFile,
|
||||
bool isPrivate)
|
||||
nsIFile* inDestFile)
|
||||
{
|
||||
nsCOMPtr<nsIURI> sourceURI;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(sourceURI), inSourceURIString);
|
||||
@ -156,8 +155,7 @@ nsContentAreaDragDropDataProvider::SaveURIToFile(nsAString& inSourceURIString,
|
||||
|
||||
persist->SetPersistFlags(nsIWebBrowserPersist::PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION);
|
||||
|
||||
return persist->SavePrivacyAwareURI(sourceURI, nullptr, nullptr, nullptr, nullptr,
|
||||
inDestFile, isPrivate);
|
||||
return persist->SaveURI(sourceURI, nullptr, nullptr, nullptr, nullptr, inDestFile);
|
||||
}
|
||||
|
||||
// This is our nsIFlavorDataProvider callback. There are several
|
||||
@ -229,10 +227,7 @@ nsContentAreaDragDropDataProvider::GetFlavorData(nsITransferable *aTransferable,
|
||||
|
||||
file->Append(targetFilename);
|
||||
|
||||
bool isPrivate;
|
||||
aTransferable->GetIsPrivateData(&isPrivate);
|
||||
|
||||
rv = SaveURIToFile(sourceURLString, file, isPrivate);
|
||||
rv = SaveURIToFile(sourceURLString, file);
|
||||
// send back an nsIFile
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
CallQueryInterface(file, aData);
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
virtual ~nsContentAreaDragDropDataProvider() {}
|
||||
|
||||
nsresult SaveURIToFile(nsAString& inSourceURIString,
|
||||
nsIFile* inDestFile, bool isPrivate);
|
||||
nsIFile* inDestFile);
|
||||
};
|
||||
|
||||
|
||||
|
@ -916,18 +916,10 @@ NS_IMETHODIMP nsWebBrowser::SetProgressListener(nsIWebProgressListener * aProgre
|
||||
|
||||
/* void saveURI (in nsIURI aURI, in nsIURI aReferrer,
|
||||
in nsISupports aCacheKey, in nsIInputStream aPostData, in wstring aExtraHeaders,
|
||||
in nsISupports aFile, in nsILoadContext aPrivacyContext); */
|
||||
in nsISupports aFile); */
|
||||
NS_IMETHODIMP nsWebBrowser::SaveURI(
|
||||
nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer, nsIInputStream *aPostData,
|
||||
const char *aExtraHeaders, nsISupports *aFile, nsILoadContext* aPrivacyContext)
|
||||
{
|
||||
return SavePrivacyAwareURI(aURI, aCacheKey, aReferrer, aPostData, aExtraHeaders,
|
||||
aFile, aPrivacyContext && aPrivacyContext->UsePrivateBrowsing());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::SavePrivacyAwareURI(
|
||||
nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer, nsIInputStream *aPostData,
|
||||
const char *aExtraHeaders, nsISupports *aFile, bool aIsPrivate)
|
||||
const char *aExtraHeaders, nsISupports *aFile)
|
||||
{
|
||||
if (mPersist)
|
||||
{
|
||||
@ -965,8 +957,7 @@ NS_IMETHODIMP nsWebBrowser::SavePrivacyAwareURI(
|
||||
mPersist->SetProgressListener(this);
|
||||
mPersist->SetPersistFlags(mPersistFlags);
|
||||
mPersist->GetCurrentState(&mPersistCurrentState);
|
||||
rv = mPersist->SavePrivacyAwareURI(uri, aCacheKey, aReferrer, aPostData,
|
||||
aExtraHeaders, aFile, aIsPrivate);
|
||||
rv = mPersist->SaveURI(uri, aCacheKey, aReferrer, aPostData, aExtraHeaders, aFile);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
mPersist = nullptr;
|
||||
|
@ -12,12 +12,11 @@ interface nsIDOMDocument;
|
||||
interface nsIWebProgressListener;
|
||||
interface nsIFile;
|
||||
interface nsIChannel;
|
||||
interface nsILoadContext;
|
||||
|
||||
/**
|
||||
* Interface for persisting DOM documents and URIs to local or remote storage.
|
||||
*/
|
||||
[scriptable, uuid(35c1f231-582b-4315-a26c-a1227e3539b4)]
|
||||
[scriptable, uuid(dd4e0a6a-210f-419a-ad85-40e8543b9465)]
|
||||
interface nsIWebBrowserPersist : nsICancelable
|
||||
{
|
||||
/** No special persistence behaviour. */
|
||||
@ -131,11 +130,6 @@ interface nsIWebBrowserPersist : nsICancelable
|
||||
* @param aFile Target file. This may be a nsIFile object or an
|
||||
* nsIURI object with a file scheme or a scheme that
|
||||
* supports uploading (e.g. ftp).
|
||||
* @param aPrivacyContext A context from which the privacy status of this
|
||||
* save operation can be determined. Must only be null
|
||||
* in situations in which no such context is available
|
||||
* (eg. the operation has no logical association with any
|
||||
* window or document)
|
||||
*
|
||||
* @see nsIFile
|
||||
* @see nsIURI
|
||||
@ -146,19 +140,7 @@ interface nsIWebBrowserPersist : nsICancelable
|
||||
*/
|
||||
void saveURI(in nsIURI aURI, in nsISupports aCacheKey,
|
||||
in nsIURI aReferrer, in nsIInputStream aPostData,
|
||||
in string aExtraHeaders, in nsISupports aFile,
|
||||
in nsILoadContext aPrivacyContext);
|
||||
|
||||
/**
|
||||
* @param aIsPrivate Treat the save operation as private (ie. with
|
||||
* regards to networking operations and persistence
|
||||
* of intermediate data, etc.)
|
||||
* @see saveURI for all other parameter descriptions
|
||||
*/
|
||||
void savePrivacyAwareURI(in nsIURI aURI, in nsISupports aCacheKey,
|
||||
in nsIURI aReferrer, in nsIInputStream aPostData,
|
||||
in string aExtraHeaders, in nsISupports aFile,
|
||||
in boolean aIsPrivate);
|
||||
in string aExtraHeaders, in nsISupports aFile);
|
||||
|
||||
/**
|
||||
* Save a channel to a file. It must not be opened yet.
|
||||
|
@ -197,7 +197,6 @@ nsWebBrowserPersist::nsWebBrowserPersist() :
|
||||
mStartSaving(false),
|
||||
mReplaceExisting(true),
|
||||
mSerializingOutput(false),
|
||||
mIsPrivate(false),
|
||||
mPersistFlags(kDefaultPersistFlags),
|
||||
mPersistResult(NS_OK),
|
||||
mTotalCurrentProgress(0),
|
||||
@ -332,16 +331,9 @@ NS_IMETHODIMP nsWebBrowserPersist::SetProgressListener(
|
||||
|
||||
/* void saveURI (in nsIURI aURI, in nsISupports aCacheKey, in nsIURI aReferrer,
|
||||
in nsIInputStream aPostData, in wstring aExtraHeaders,
|
||||
in nsISupports aFile, in nsILoadContext aPrivayContext); */
|
||||
in nsISupports aFile); */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::SaveURI(
|
||||
nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer, nsIInputStream *aPostData, const char *aExtraHeaders, nsISupports *aFile, nsILoadContext* aPrivacyContext)
|
||||
{
|
||||
return SavePrivacyAwareURI(aURI, aCacheKey, aReferrer, aPostData, aExtraHeaders, aFile,
|
||||
aPrivacyContext && aPrivacyContext->UsePrivateBrowsing());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowserPersist::SavePrivacyAwareURI(
|
||||
nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer, nsIInputStream *aPostData, const char *aExtraHeaders, nsISupports *aFile, bool aIsPrivate)
|
||||
nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer, nsIInputStream *aPostData, const char *aExtraHeaders, nsISupports *aFile)
|
||||
{
|
||||
NS_ENSURE_TRUE(mFirstAndOnlyUse, NS_ERROR_FAILURE);
|
||||
mFirstAndOnlyUse = false; // Stop people from reusing this object!
|
||||
@ -353,7 +345,7 @@ NS_IMETHODIMP nsWebBrowserPersist::SavePrivacyAwareURI(
|
||||
|
||||
// SaveURI doesn't like broken uris.
|
||||
mPersistFlags |= PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS;
|
||||
rv = SaveURIInternal(aURI, aCacheKey, aReferrer, aPostData, aExtraHeaders, fileAsURI, false, aIsPrivate);
|
||||
rv = SaveURIInternal(aURI, aCacheKey, aReferrer, aPostData, aExtraHeaders, fileAsURI, false);
|
||||
return NS_FAILED(rv) ? rv : NS_OK;
|
||||
}
|
||||
|
||||
@ -393,10 +385,6 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveDocument(
|
||||
nsCOMPtr<nsIURI> datapathAsURI;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDocument);
|
||||
nsCOMPtr<nsILoadContext> privacyContext = doc ? doc->GetLoadContext() : nullptr;
|
||||
mIsPrivate = privacyContext && privacyContext->UsePrivateBrowsing();
|
||||
|
||||
rv = GetValidURIFromObject(aFile, getter_AddRefs(fileAsURI));
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_INVALID_ARG);
|
||||
if (aDataPath)
|
||||
@ -1177,7 +1165,7 @@ nsresult nsWebBrowserPersist::AppendPathToURI(nsIURI *aURI, const nsAString & aP
|
||||
nsresult nsWebBrowserPersist::SaveURIInternal(
|
||||
nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer,
|
||||
nsIInputStream *aPostData, const char *aExtraHeaders,
|
||||
nsIURI *aFile, bool aCalcFileExt, bool aIsPrivate)
|
||||
nsIURI *aFile, bool aCalcFileExt)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ENSURE_ARG_POINTER(aFile);
|
||||
@ -1231,12 +1219,6 @@ nsresult nsWebBrowserPersist::SaveURIInternal(
|
||||
rv = NS_NewChannel(getter_AddRefs(inputChannel), aURI,
|
||||
nullptr, nullptr, static_cast<nsIInterfaceRequestor *>(this),
|
||||
loadFlags);
|
||||
|
||||
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(inputChannel);
|
||||
if (pbChannel)
|
||||
{
|
||||
pbChannel->SetPrivate(aIsPrivate);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || inputChannel == nullptr)
|
||||
{
|
||||
@ -2529,8 +2511,7 @@ nsWebBrowserPersist::EnumPersistURIs(nsHashKey *aKey, void *aData, void* closure
|
||||
rv = pthis->AppendPathToURI(fileAsURI, data->mFilename);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
rv = pthis->SaveURIInternal(uri, nullptr, nullptr, nullptr, nullptr, fileAsURI, true,
|
||||
pthis->mIsPrivate);
|
||||
rv = pthis->SaveURIInternal(uri, nullptr, nullptr, nullptr, nullptr, fileAsURI, true);
|
||||
// if SaveURIInternal fails, then it will have called EndDownload,
|
||||
// which means that |aData| is no longer valid memory. we MUST bail.
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
@ -63,7 +63,7 @@ protected:
|
||||
nsresult SaveURIInternal(
|
||||
nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer,
|
||||
nsIInputStream *aPostData, const char *aExtraHeaders, nsIURI *aFile,
|
||||
bool aCalcFileExt, bool aIsPrivate);
|
||||
bool aCalcFileExt);
|
||||
nsresult SaveChannelInternal(
|
||||
nsIChannel *aChannel, nsIURI *aFile, bool aCalcFileExt);
|
||||
nsresult SaveDocumentInternal(
|
||||
@ -202,7 +202,6 @@ private:
|
||||
bool mStartSaving;
|
||||
bool mReplaceExisting;
|
||||
bool mSerializingOutput;
|
||||
bool mIsPrivate;
|
||||
uint32_t mPersistFlags;
|
||||
nsresult mPersistResult;
|
||||
int64_t mTotalCurrentProgress;
|
||||
|
@ -90,9 +90,7 @@ interface imgITools : nsISupports
|
||||
* document.
|
||||
*
|
||||
* @param doc
|
||||
* A document. Null is allowed, but must _only_ be passed
|
||||
* when there is no way to obtain a relevant document for
|
||||
* the current context in which a cache is desired.
|
||||
* A document. Must not be null.
|
||||
*/
|
||||
imgICache getImgCacheForDocument(in nsIDOMDocument doc);
|
||||
|
||||
|
@ -6511,7 +6511,7 @@ var WebappsUI = {
|
||||
persist.persistFlags |= Ci.nsIWebBrowserPersist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
|
||||
|
||||
let source = Services.io.newURI(fullsizeIcon, "UTF8", null);
|
||||
persist.saveURI(source, null, null, null, null, iconFile, null);
|
||||
persist.saveURI(source, null, null, null, null, iconFile);
|
||||
} catch(ex) {
|
||||
console.log(ex);
|
||||
}
|
||||
|
@ -862,11 +862,7 @@ SessionStore.prototype = {
|
||||
|
||||
let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist);
|
||||
persist.persistFlags = Ci.nsIWebBrowserPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES | Ci.nsIWebBrowserPersist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
|
||||
let privacyContext = browser.contentWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
persist.saveURI(source, null, null, null, null, file, privacyContext);
|
||||
persist.saveURI(source, null, null, null, null, file);
|
||||
|
||||
aStringValue = target.spec;
|
||||
}
|
||||
|
@ -1587,8 +1587,7 @@ nsDownloadManager::RetryDownload(uint32_t aID)
|
||||
dl->mCancelable = wbp;
|
||||
(void)wbp->SetProgressListener(dl);
|
||||
|
||||
rv = wbp->SavePrivacyAwareURI(dl->mSource, nullptr, nullptr, nullptr, nullptr,
|
||||
dl->mTarget, dl->mPrivate);
|
||||
rv = wbp->SaveURI(dl->mSource, nullptr, nullptr, nullptr, nullptr, dl->mTarget);
|
||||
if (NS_FAILED(rv)) {
|
||||
dl->mCancelable = nullptr;
|
||||
(void)wbp->SetProgressListener(nullptr);
|
||||
@ -2990,11 +2989,6 @@ nsDownload::Resume()
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), mSource, nullptr, nullptr, ir);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(channel);
|
||||
if (pbChannel) {
|
||||
pbChannel->SetPrivate(mDownloadManager->mInPrivateBrowsing);
|
||||
}
|
||||
|
||||
// Make sure we can get a file, either the temporary or the real target, for
|
||||
// both purposes of file size and a target to write to
|
||||
nsCOMPtr<nsIFile> targetLocalFile(mTempFile);
|
||||
|
@ -111,7 +111,6 @@ function addDownload(aParams)
|
||||
// it is part of the active downloads the moment addDownload is called
|
||||
gDownloadCount++;
|
||||
|
||||
let dm = downloadUtils.downloadManager;
|
||||
var dl = dm.addDownload(Ci.nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD,
|
||||
createURI(aParams.sourceURI),
|
||||
createURI(aParams.targetFile), aParams.downloadName, null,
|
||||
@ -124,8 +123,7 @@ function addDownload(aParams)
|
||||
aParams.runBeforeStart.call(undefined, dl);
|
||||
|
||||
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
|
||||
persist.savePrivacyAwareURI(dl.source, null, null, null, null, dl.targetFile,
|
||||
aParams.isPrivate);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ function run_test()
|
||||
Math.round(Date.now() * 1000), null, persist, false);
|
||||
|
||||
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile, null);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ function run_test()
|
||||
createURI(destFile), null, null,
|
||||
Math.round(Date.now() * 1000), null, persist, false);
|
||||
persist.progressListener = dl.QueryInterface(nsIWPL);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile, null);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
// Mark as pending, so clear this when we actually finish the download
|
||||
do_test_pending();
|
||||
|
@ -1,124 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
this.__defineGetter__("pb", function () {
|
||||
delete this.pb;
|
||||
try {
|
||||
return this.pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
} catch (e) {}
|
||||
return this.pb = null;
|
||||
});
|
||||
|
||||
// Public request gets times=0 cookie, completes
|
||||
// Private request gets times=1 cookie, canceled
|
||||
// Private resumed request sends times=1 cookie, completes
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
let httpserv = new HttpServer();
|
||||
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
let times = 0;
|
||||
httpserv.registerPathHandler("/head_download_manager.js", function (meta, response) {
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.setStatusLine("1.1", !meta.hasHeader('range') ? 200 : 206);
|
||||
|
||||
// Set a cookie if none is sent with the request. Public and private requests
|
||||
// should therefore receive different cookies, so we can tell if the resumed
|
||||
// request is actually treated as private or not.
|
||||
if (!meta.hasHeader('Cookie')) {
|
||||
do_check_true(times == 0 || times == 1);
|
||||
response.setHeader('Set-Cookie', 'times=' + times++);
|
||||
} else {
|
||||
do_check_eq(times, 2);
|
||||
do_check_eq(meta.getHeader('Cookie'), 'times=1');
|
||||
}
|
||||
let full = "";
|
||||
let body = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; //60
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
full += body;
|
||||
}
|
||||
response.write(full);
|
||||
});
|
||||
httpserv.start(4444);
|
||||
|
||||
let state = 0;
|
||||
|
||||
let listener = {
|
||||
onDownloadStateChange: function(aState, aDownload) {
|
||||
switch (aDownload.state) {
|
||||
case downloadUtils.downloadManager.DOWNLOAD_DOWNLOADING:
|
||||
// We only care about the private download
|
||||
if (state != 1)
|
||||
break;
|
||||
|
||||
state++;
|
||||
do_check_true(aDownload.resumable);
|
||||
|
||||
downloadUtils.downloadManager.pauseDownload(aDownload.id);
|
||||
do_check_eq(aDownload.state, downloadUtils.downloadManager.DOWNLOAD_PAUSED);
|
||||
|
||||
do_execute_soon(function() {
|
||||
downloadUtils.downloadManager.resumeDownload(aDownload.id);
|
||||
});
|
||||
break;
|
||||
|
||||
case downloadUtils.downloadManager.DOWNLOAD_FINISHED:
|
||||
if (state == 0) {
|
||||
do_execute_soon(function() {
|
||||
// Perform an identical request but in private mode.
|
||||
// It should receive a different cookie than the
|
||||
// public request.
|
||||
|
||||
state++;
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
addDownload({
|
||||
isPrivate: pb.privateBrowsingEnabled,
|
||||
sourceURI: downloadCSource,
|
||||
downloadName: downloadCName + "!!!",
|
||||
runBeforeStart: function (aDownload) {
|
||||
// Check that dl is retrievable
|
||||
do_check_eq(downloadUtils.downloadManager.activeDownloadCount, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if (state == 2) {
|
||||
// We're done here.
|
||||
do_execute_soon(function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
httpserv.stop(do_test_finished);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
onStateChange: function(a, b, c, d, e) { },
|
||||
onProgressChange: function(a, b, c, d, e, f, g) { },
|
||||
onSecurityChange: function(a, b, c, d) { }
|
||||
};
|
||||
|
||||
downloadUtils.downloadManager.addListener(listener);
|
||||
|
||||
const downloadCSource = "http://localhost:4444/head_download_manager.js";
|
||||
const downloadCName = "download-C";
|
||||
|
||||
// First a public download that completes without interruption.
|
||||
let dl = addDownload({
|
||||
isPrivate: pb.privateBrowsingEnabled,
|
||||
sourceURI: downloadCSource,
|
||||
downloadName: downloadCName,
|
||||
runBeforeStart: function (aDownload) {
|
||||
// Check that dl is retrievable
|
||||
do_check_eq(downloadUtils.downloadManager.activeDownloadCount, 1);
|
||||
}
|
||||
});
|
||||
}
|
@ -126,7 +126,7 @@ function run_test()
|
||||
createURI(destFile), null, null,
|
||||
Math.round(Date.now() * 1000), null, persist, false);
|
||||
persist.progressListener = dl.QueryInterface(nsIWPL);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile, null);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
// Mark as pending, so clear this when we actually finish the download
|
||||
do_test_pending();
|
||||
|
@ -145,7 +145,7 @@ function run_test()
|
||||
createURI(destFile), null, null,
|
||||
Math.round(Date.now() * 1000), null, persist, false);
|
||||
persist.progressListener = dl.QueryInterface(nsIWPL);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile, null);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
// Mark as pending, so clear this when we actually finish the download
|
||||
do_test_pending();
|
||||
|
@ -21,7 +21,6 @@ skip-if = os == "android"
|
||||
[test_memory_db_support.js]
|
||||
[test_offline_support.js]
|
||||
[test_old_download_files_removed.js]
|
||||
[test_private_resume.js]
|
||||
[test_privatebrowsing.js]
|
||||
[test_privatebrowsing_cancel.js]
|
||||
[test_removeDownloadsByTimeframe.js]
|
||||
|
@ -433,13 +433,9 @@ function internalPersist(persistArgs)
|
||||
persist.saveDocument(persistArgs.sourceDocument, targetFileURL, filesFolder,
|
||||
persistArgs.targetContentType, encodingFlags, kWrapColumn);
|
||||
} else {
|
||||
let privacyContext = persistArgs.initiatingWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
persist.saveURI(persistArgs.sourceURI,
|
||||
persistArgs.sourceCacheKey, persistArgs.sourceReferrer, persistArgs.sourcePostData, null,
|
||||
targetFileURL, privacyContext);
|
||||
targetFileURL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,12 +109,8 @@ function test()
|
||||
createURI(destFile), null, null,
|
||||
Math.round(Date.now() * 1000), null, persist, false);
|
||||
|
||||
var privacyContext = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
|
||||
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile, privacyContext);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
@ -72,12 +72,8 @@ function addDownload(aName) {
|
||||
createURI(dmFile), null, null,
|
||||
Math.round(Date.now() * 1000), null, persist, false);
|
||||
|
||||
let privacyContext = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
|
||||
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile, privacyContext);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
@ -770,7 +770,7 @@ function _persistImage(sourceURL, localFileName, successCallback) {
|
||||
|
||||
persist.progressListener = new _persistProgressListener(successCallback);
|
||||
|
||||
persist.saveURI(sourceURI, null, null, null, null, targetURI, null);
|
||||
persist.saveURI(sourceURI, null, null, null, null, targetURI);
|
||||
}
|
||||
|
||||
function _persistProgressListener(successCallback) {
|
||||
|
@ -504,14 +504,9 @@ nsresult nsDragService::SaveAsContents(PCSZ pszDest, nsIURL* aURL)
|
||||
if (NS_FAILED(file->OpenANSIFileDesc("wb+", &fp)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
GetSourceDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDoc);
|
||||
|
||||
fwrite("", 0, 1, fp);
|
||||
fclose(fp);
|
||||
webPersist->SaveURI(linkURI, nullptr, nullptr, nullptr, nullptr, file,
|
||||
document->GetLoadContext());
|
||||
webPersist->SaveURI(linkURI, nullptr, nullptr, nullptr, nullptr, file);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user