зеркало из https://github.com/mozilla/gecko-dev.git
Bug 809567 - Hide ArchiveReader feature behind a pref (disabled by default), r=mounir
This commit is contained in:
Родитель
a3cbbff917
Коммит
6e439d8833
|
@ -6677,6 +6677,14 @@ ConstructorEnabled(const nsGlobalNameStruct *aStruct, nsGlobalWindow *aWin)
|
|||
}
|
||||
}
|
||||
|
||||
// Don't expose ArchiveReader unless user has explicitly enabled it
|
||||
if (aStruct->mDOMClassInfoID == eDOMClassInfo_ArchiveReader_id ||
|
||||
aStruct->mDOMClassInfoID == eDOMClassInfo_ArchiveRequest_id) {
|
||||
if (!dom::file::ArchiveReader::PrefEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
USING_FILE_NAMESPACE
|
||||
|
||||
ArchiveReader::ArchiveReader()
|
||||
|
@ -33,6 +35,12 @@ ArchiveReader::~ArchiveReader()
|
|||
nsLayoutStatics::Release();
|
||||
}
|
||||
|
||||
bool
|
||||
ArchiveReader::PrefEnabled()
|
||||
{
|
||||
return Preferences::GetBool("dom.archivereader.enabled", true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ArchiveReader::Initialize(nsISupports* aOwner,
|
||||
JSContext* aCx,
|
||||
|
@ -42,6 +50,10 @@ ArchiveReader::Initialize(nsISupports* aOwner,
|
|||
{
|
||||
NS_ENSURE_TRUE(aArgc == 1 || aArgc == 2, NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!PrefEnabled()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// We expect to get a Blob object
|
||||
if (!aArgv[0].isObject()) {
|
||||
return NS_ERROR_INVALID_ARG; // We're not interested
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
nsresult GetInputStream(nsIInputStream** aInputStream);
|
||||
nsresult GetSize(uint64_t* aSize);
|
||||
|
||||
static bool PrefEnabled();
|
||||
|
||||
public: // for the ArchiveRequest:
|
||||
nsresult RegisterRequest(ArchiveRequest* aRequest);
|
||||
|
||||
|
|
|
@ -13,11 +13,14 @@ var fileStorages = [
|
|||
|
||||
var utils = SpecialPowers.getDOMWindowUtils(window);
|
||||
|
||||
var archiveReaderEnabled = false;
|
||||
|
||||
var testGenerator = testSteps();
|
||||
|
||||
function runTest()
|
||||
{
|
||||
allowUnlimitedQuota();
|
||||
enableArchiveReader();
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
testGenerator.next();
|
||||
|
@ -26,6 +29,7 @@ function runTest()
|
|||
function finishTest()
|
||||
{
|
||||
resetUnlimitedQuota();
|
||||
resetArchiveReader();
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
testGenerator.close();
|
||||
|
@ -98,6 +102,17 @@ function resetUnlimitedQuota(url)
|
|||
removePermission("indexedDB-unlimited", url);
|
||||
}
|
||||
|
||||
function enableArchiveReader()
|
||||
{
|
||||
archiveReaderEnabled = SpecialPowers.getBoolPref("dom.archivereader.enabled");
|
||||
SpecialPowers.setBoolPref("dom.archivereader.enabled", true);
|
||||
}
|
||||
|
||||
function resetArchiveReader()
|
||||
{
|
||||
SpecialPowers.setBoolPref("dom.archivereader.enabled", archiveReaderEnabled);
|
||||
}
|
||||
|
||||
function getFileHandle(fileStorageKey, name)
|
||||
{
|
||||
var requestService = SpecialPowers.getDOMRequestService();
|
||||
|
|
|
@ -8,14 +8,8 @@
|
|||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p id="display">
|
||||
<input id="fileList" type="file"></input>
|
||||
</p>
|
||||
|
||||
<script type="text/javascript;version=1.7">
|
||||
<script type="text/javascript;version=1.7">
|
||||
function createZipFileWithData(fileData) {
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
|
@ -58,7 +52,7 @@
|
|||
function markTestDone() {
|
||||
++handleFinished;
|
||||
if (isFinished()) {
|
||||
SimpleTest.finish();
|
||||
finishTest();
|
||||
}
|
||||
}
|
||||
function isFinished() {
|
||||
|
@ -251,11 +245,17 @@
|
|||
ok(false, "ArchiveReader.getFiles() should not return an 'error'");
|
||||
markTestDone();
|
||||
}
|
||||
yield;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
testSteps();
|
||||
</script>
|
||||
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
||||
</head>
|
||||
|
||||
<body onload="runTest();">
|
||||
<p id="display">
|
||||
<input id="fileList" type="file"></input>
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
var testGenerator = testSteps();
|
||||
var archiveReaderEnabled = false;
|
||||
|
||||
// The test js is shared between xpcshell (which has no SpecialPowers object)
|
||||
// and content mochitests (where the |Components| object is accessible only as
|
||||
|
@ -68,6 +69,8 @@ if (!window.runTest) {
|
|||
allowUnlimitedQuota();
|
||||
}
|
||||
|
||||
enableArchiveReader();
|
||||
|
||||
clearAllDatabases(function () { testGenerator.next(); });
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +78,7 @@ if (!window.runTest) {
|
|||
function finishTest()
|
||||
{
|
||||
resetUnlimitedQuota();
|
||||
resetArchiveReader();
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
testGenerator.close();
|
||||
|
@ -163,12 +167,12 @@ function compareKeys(k1, k2) {
|
|||
if (!(k2 instanceof Array) ||
|
||||
k1.length != k2.length)
|
||||
return false;
|
||||
|
||||
|
||||
for (let i = 0; i < k1.length; ++i) {
|
||||
if (!compareKeys(k1[i], k2[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -211,6 +215,17 @@ function resetUnlimitedQuota(url)
|
|||
removePermission("indexedDB-unlimited", url);
|
||||
}
|
||||
|
||||
function enableArchiveReader()
|
||||
{
|
||||
archiveReaderEnabled = SpecialPowers.getBoolPref("dom.archivereader.enabled");
|
||||
SpecialPowers.setBoolPref("dom.archivereader.enabled", true);
|
||||
}
|
||||
|
||||
function resetArchiveReader()
|
||||
{
|
||||
SpecialPowers.setBoolPref("dom.archivereader.enabled", archiveReaderEnabled);
|
||||
}
|
||||
|
||||
function gc()
|
||||
{
|
||||
SpecialPowers.forceGC();
|
||||
|
|
|
@ -207,8 +207,6 @@ var interfaceNamesInGlobalScope =
|
|||
"SVGAltGlyphElement",
|
||||
"Screen",
|
||||
"FileReader",
|
||||
"ArchiveReader",
|
||||
"ArchiveRequest",
|
||||
"SVGSwitchElement",
|
||||
"SVGPolylineElement",
|
||||
"SVGPathSegLinetoAbs",
|
||||
|
|
|
@ -1681,6 +1681,9 @@ pref("editor.positioning.offset", 0);
|
|||
pref("dom.max_chrome_script_run_time", 20);
|
||||
pref("dom.max_script_run_time", 10);
|
||||
|
||||
// If true, ArchiveReader will be enabled
|
||||
pref("dom.archivereader.enabled", false);
|
||||
|
||||
// Hang monitor timeout after which we kill the browser, in seconds
|
||||
// (0 is disabled)
|
||||
// Disabled on all platforms per bug 705748 until the found issues are
|
||||
|
|
Загрузка…
Ссылка в новой задаче