зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1246244 - Regression test. r=jaws,Margaret
MozReview-Commit-ID: BRbHkzSTRrA --HG-- extra : rebase_source : 13b2686fbc602cd89fc565815bf73a187b7c5f00
This commit is contained in:
Родитель
7c22c1ff84
Коммит
17dd9fad6c
|
@ -47,3 +47,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g'
|
|||
[browser_mute2.js]
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g'
|
||||
[browser_quickfind_editable.js]
|
||||
[browser_saveImageURL.js]
|
||||
support-files =
|
||||
image.jpg
|
||||
image_page.html
|
|
@ -0,0 +1,64 @@
|
|||
"use strict";
|
||||
|
||||
const IMAGE_PAGE = "https://example.com/browser/toolkit/content/tests/browser/image_page.html";
|
||||
const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
|
||||
|
||||
MockFilePicker.init(window);
|
||||
MockFilePicker.returnValue = MockFilePicker.returnCancel;
|
||||
|
||||
function waitForFilePicker() {
|
||||
return new Promise((resolve) => {
|
||||
MockFilePicker.showCallback = () => {
|
||||
MockFilePicker.showCallback = null;
|
||||
ok(true, "Saw the file picker");
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that saveImageURL works when we pass in the aIsContentWindowPrivate
|
||||
* argument instead of a document. This is the preferred API.
|
||||
*/
|
||||
add_task(function* preferred_API() {
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: IMAGE_PAGE,
|
||||
}, function*(browser) {
|
||||
let url = yield ContentTask.spawn(browser, null, function*() {
|
||||
let image = content.document.getElementById("image");
|
||||
return image.href;
|
||||
});
|
||||
|
||||
saveImageURL(url, "image.jpg", null, true, false, null, null, null, null, false);
|
||||
yield waitForFilePicker();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that saveImageURL will still work when passed a document instead
|
||||
* of the aIsContentWindowPrivate argument. This is the deprecated API, and
|
||||
* will not work in apps using remote browsers having PREF_UNSAFE_FORBIDDEN
|
||||
* set to true.
|
||||
*/
|
||||
add_task(function* deprecated_API() {
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: IMAGE_PAGE,
|
||||
}, function*(browser) {
|
||||
yield pushPrefs([PREF_UNSAFE_FORBIDDEN, false]);
|
||||
|
||||
let url = yield ContentTask.spawn(browser, null, function*() {
|
||||
let image = content.document.getElementById("image");
|
||||
return image.href;
|
||||
});
|
||||
|
||||
// Now get the document directly from content. If we run this test with
|
||||
// e10s-enabled, this will be a CPOW, which is forbidden. We'll just
|
||||
// pass the XUL document instead to test this interface.
|
||||
let doc = document;
|
||||
|
||||
saveImageURL(url, "image.jpg", null, true, false, null, doc, null, null);
|
||||
yield waitForFilePicker();
|
||||
});
|
||||
});
|
|
@ -1,5 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/Promise.jsm");
|
||||
|
||||
/**
|
||||
* A wrapper for the findbar's method "close", which is not synchronous
|
||||
* because of animation.
|
||||
|
@ -18,3 +23,9 @@ function closeFindbarAndWait(findbar) {
|
|||
findbar.close();
|
||||
});
|
||||
}
|
||||
|
||||
function pushPrefs(...aPrefs) {
|
||||
let deferred = Promise.defer();
|
||||
SpecialPowers.pushPrefEnv({"set": aPrefs}, deferred.resolve);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 24 KiB |
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OHAI</title>
|
||||
<body>
|
||||
<img id="image" src="image.jpg" />
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче