зеркало из https://github.com/mozilla/gecko-dev.git
bug 563662 - FPU Exception filter crashes when we hit a pure virtual function call. r=bsmedberg
--HG-- extra : rebase_source : 34016adebf806015162553df71ad28879105e978
This commit is contained in:
Родитель
7d26b0b244
Коммит
5edc4f7117
|
@ -408,6 +408,9 @@ bool MinidumpCallback(const XP_CHAR* dump_path,
|
|||
static bool FPEFilter(void* context, EXCEPTION_POINTERS* exinfo,
|
||||
MDRawAssertionInfo* assertion)
|
||||
{
|
||||
if (!exinfo)
|
||||
return true;
|
||||
|
||||
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)exinfo->ExceptionRecord;
|
||||
switch (e->ExceptionCode) {
|
||||
case STATUS_FLOAT_DENORMAL_OPERAND:
|
||||
|
|
|
@ -48,7 +48,6 @@ XPCSHELL_TESTS = unit
|
|||
|
||||
LIBRARY_NAME = testcrasher
|
||||
IS_COMPONENT = 1
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
XPIDLSRCS = nsITestCrasher.idl
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ interface nsILocalFile;
|
|||
[scriptable, uuid(95464a04-6949-46cb-b621-d167790704a0)]
|
||||
interface nsITestCrasher : nsISupports
|
||||
{
|
||||
void crash();
|
||||
void crash(in short how);
|
||||
|
||||
/**
|
||||
* Lock a directory using XRE_LockProfileDirectory.
|
||||
|
@ -14,4 +14,7 @@ interface nsITestCrasher : nsISupports
|
|||
* @return An opaque lock object.
|
||||
*/
|
||||
nsISupports lockDir(in nsILocalFile directory);
|
||||
|
||||
const short CRASH_INVALID_POINTER_DEREF = 0;
|
||||
const short CRASH_PURE_VIRTUAL_CALL = 1;
|
||||
};
|
||||
|
|
|
@ -19,12 +19,54 @@ private:
|
|||
|
||||
NS_IMPL_ISUPPORTS1(nsTestCrasher, nsITestCrasher)
|
||||
|
||||
/* void crash (); */
|
||||
NS_IMETHODIMP nsTestCrasher::Crash()
|
||||
/*
|
||||
* This pure virtual call example is from MSDN
|
||||
*/
|
||||
class A;
|
||||
|
||||
void fcn( A* );
|
||||
|
||||
class A
|
||||
{
|
||||
volatile int* foo = (int*)0x42;
|
||||
*foo = 0;
|
||||
// not reached
|
||||
public:
|
||||
virtual void f() = 0;
|
||||
A() { fcn( this ); }
|
||||
};
|
||||
|
||||
class B : A
|
||||
{
|
||||
void f() { }
|
||||
};
|
||||
|
||||
void fcn( A* p )
|
||||
{
|
||||
p->f();
|
||||
}
|
||||
|
||||
void PureVirtualCall()
|
||||
{
|
||||
// generates a pure virtual function call
|
||||
B b;
|
||||
}
|
||||
|
||||
/* void crash (); */
|
||||
NS_IMETHODIMP nsTestCrasher::Crash(PRInt16 how)
|
||||
{
|
||||
switch (how) {
|
||||
case nsITestCrasher::CRASH_INVALID_POINTER_DEREF: {
|
||||
volatile int* foo = (int*)0x42;
|
||||
*foo = 0;
|
||||
// not reached
|
||||
break;
|
||||
}
|
||||
case nsITestCrasher::CRASH_PURE_VIRTUAL_CALL: {
|
||||
PureVirtualCall();
|
||||
// not reached
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,3 +7,4 @@ let crashReporter =
|
|||
.getService(Components.interfaces.nsICrashReporter);
|
||||
crashReporter.enabled = true;
|
||||
crashReporter.minidumpPath = cwd;
|
||||
let crashType = Components.interfaces.nsITestCrasher.CRASH_INVALID_POINTER_DEREF;
|
||||
|
|
|
@ -4,4 +4,4 @@ cd.append("components");
|
|||
Components.manager instanceof Components.interfaces.nsIComponentRegistrar;
|
||||
Components.manager.autoRegister(cd);
|
||||
let crasher = Components.classes["@mozilla.org/testcrasher;1"].createInstance(Components.interfaces.nsITestCrasher);
|
||||
crasher.crash();
|
||||
crasher.crash(crashType);
|
||||
|
|
|
@ -18,8 +18,13 @@
|
|||
* minidump is an nsILocalFile of the minidump file produced,
|
||||
* and extra is an object containing the key,value pairs from
|
||||
* the .extra file.
|
||||
*
|
||||
* @param canReturnZero
|
||||
* If true, the subprocess may return with a zero exit code.
|
||||
* Certain types of crashes may not cause the process to
|
||||
* exit with an error.
|
||||
*/
|
||||
function do_crash(setup, callback)
|
||||
function do_crash(setup, callback, canReturnZero)
|
||||
{
|
||||
// get current process filename (xpcshell)
|
||||
let ds = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
|
@ -55,8 +60,11 @@ function do_crash(setup, callback)
|
|||
}
|
||||
catch(ex) {} // on Windows we exit with a -1 status when crashing.
|
||||
|
||||
// should exit with an error (should have crashed)
|
||||
do_check_neq(process.exitValue, 0);
|
||||
if (!canReturnZero) {
|
||||
// should exit with an error (should have crashed)
|
||||
do_check_neq(process.exitValue, 0);
|
||||
}
|
||||
|
||||
// find minidump
|
||||
let minidump = null;
|
||||
let en = do_get_cwd().directoryEntries;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
function run_test()
|
||||
{
|
||||
if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
|
||||
dump("INFO | test_crashreporter.js | Can't test crashreporter in a non-libxul build.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Try crashing with a pure virtual call
|
||||
do_crash(function() {
|
||||
crashType = Components.interfaces.nsITestCrasher.CRASH_PURE_VIRTUAL_CALL;
|
||||
crashReporter.annotateCrashReport("TestKey", "TestValue");
|
||||
},
|
||||
function(mdump, extra) {
|
||||
do_check_eq(extra.TestKey, "TestValue");
|
||||
},
|
||||
// process will exit with a zero exit status
|
||||
true);
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='2'>Sandbox</status>
|
||||
<summary>Should not return sandboxed add-on</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test2@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an incompatible add-on</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>2</min_version>
|
||||
<max_version>2</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test3@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an incompatible add-on</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>unknown@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>2</min_version>
|
||||
<max_version>2</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test4@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an add-on for a different OS</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>Windows</compatible_os>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>This should work fine</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>bug397778@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return items that are already installed</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not include the same result twice</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='2'>Theme</type>
|
||||
<guid>test6@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<rating>4</rating>
|
||||
<summary>Specific OS should work fine</summary>
|
||||
<eula>EULA should be confirmed</eula>
|
||||
<thumbnail>http://localhost:4444/test_bug404024/thumbnail.png</thumbnail>
|
||||
<icon>http://localhost:4444/test_bug404024/icon.png</icon>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>XPCShell</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100">
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='2'>Sandbox</status>
|
||||
<summary>Should not return sandboxed add-on</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test2@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an incompatible add-on</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>2</min_version>
|
||||
<max_version>2</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test3@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an incompatible add-on</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>unknown@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>2</min_version>
|
||||
<max_version>2</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test4@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an add-on for a different OS</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="Windows" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>This should work fine</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>bug397778@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return items that are already installed</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not include the same result twice</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='2'>Theme</type>
|
||||
<guid>test6@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<rating>4</rating>
|
||||
<summary>Specific OS should work fine</summary>
|
||||
<eula>EULA should be confirmed</eula>
|
||||
<thumbnail>http://localhost:4444/test_bug404024/thumbnail.png</thumbnail>
|
||||
<icon>http://localhost:4444/test_bug404024/icon.png</icon>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install os="Windows">http://localhost:4444/test.xpi</install>
|
||||
<install os="XPCShell">http://localhost:4444/XPCShell.xpi</install>
|
||||
<install os="Darwin">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100">
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<rating>-5</rating>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test2@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<rating>0</rating>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test3@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<rating>2</rating>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test4@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<rating>4</rating>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<rating>5</rating>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test6@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<rating>10</rating>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test7@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>TEST</name>
|
||||
<rating>100</rating>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test8@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test addon</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
|
@ -1,204 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Dave Townsend <dtownsend@oxymoronical.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
const PREF_GETADDONS_BROWSEADDONS = "extensions.getAddons.browseAddons";
|
||||
const PREF_GETADDONS_BROWSERECOMMENDED = "extensions.getAddons.recommended.browseURL";
|
||||
const PREF_GETADDONS_GETRECOMMENDED = "extensions.getAddons.recommended.url";
|
||||
const PREF_GETADDONS_BROWSESEARCHRESULTS = "extensions.getAddons.search.browseURL";
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
|
||||
const BROWSE = "http://localhost:4444/";
|
||||
const RECOMMENDED = "http://localhost:4444/recommended.html";
|
||||
const SEARCH = "http://localhost:4444/search.html?q=";
|
||||
|
||||
var BROWSE_SEARCH_URLS = [
|
||||
["test", SEARCH + "test" ],
|
||||
["SEARCH", SEARCH + "SEARCH" ],
|
||||
["test search", SEARCH + "test%20search" ],
|
||||
["odd=search:with&weird\"characters", SEARCH + "odd%3Dsearch%3Awith%26weird%22characters" ]
|
||||
];
|
||||
|
||||
do_load_httpd_js();
|
||||
var server;
|
||||
var addonRepo;
|
||||
|
||||
var RESULTS = [
|
||||
{
|
||||
id: "test5@tests.mozilla.org",
|
||||
name: "PASS",
|
||||
version: "1.0",
|
||||
summary: "This should work fine",
|
||||
description: "Test description",
|
||||
rating: -1,
|
||||
iconURL: null,
|
||||
thumbnailURL: null,
|
||||
homepageURL: "https://addons.mozilla.org/addon/5992",
|
||||
eula: null,
|
||||
type: Ci.nsIUpdateItem.TYPE_EXTENSION,
|
||||
xpiURL: "http://localhost:4444/test.xpi",
|
||||
xpiHash: "sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3"
|
||||
},
|
||||
{
|
||||
id: "test6@tests.mozilla.org",
|
||||
name: "PASS",
|
||||
version: "1.0",
|
||||
summary: "Specific OS should work fine",
|
||||
description: null,
|
||||
rating: 4,
|
||||
iconURL: "http://localhost:4444/test_bug404024/icon.png",
|
||||
thumbnailURL: "http://localhost:4444/test_bug404024/thumbnail.png",
|
||||
homepageURL: null,
|
||||
eula: "EULA should be confirmed",
|
||||
type: Ci.nsIUpdateItem.TYPE_THEME,
|
||||
xpiURL: "http://localhost:4444/test.xpi",
|
||||
xpiHash: null
|
||||
}
|
||||
];
|
||||
|
||||
function checkResults(addons, length) {
|
||||
do_check_eq(addons.length, RESULTS.length);
|
||||
do_check_eq(addons.length, length);
|
||||
|
||||
for (var i = 0; i < addons.length; i++) {
|
||||
if (addons[i].name == "FAIL")
|
||||
do_throw(addons[i].id + " - " + addons[i].summary);
|
||||
if (addons[i].name != "PASS")
|
||||
do_throw(addons[i].id + " - " + "invalid add-on name " + addons[i].name);
|
||||
}
|
||||
|
||||
for (var i = 0; i < addons.length; i++) {
|
||||
for (var p in RESULTS[i]) {
|
||||
if (addons[i][p] != RESULTS[i][p])
|
||||
do_throw("Failed on property " + p + " on add-on " + addons[i].id +
|
||||
addons[i][p] + " == " + RESULTS[i][p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var RecommendedCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
// Search is complete
|
||||
do_check_false(addonRepo.isSearching);
|
||||
checkResults(addons, length);
|
||||
|
||||
// "search" for the same results
|
||||
addonRepo.searchAddons("bug404024", 10, SearchCallback);
|
||||
// Should be searching now and any attempt to retrieve again should be ignored
|
||||
do_check_true(addonRepo.isSearching);
|
||||
addonRepo.searchAddons("test search", 10, FailCallback);
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Recommended results failed");
|
||||
}
|
||||
};
|
||||
|
||||
var SearchCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
do_check_false(addonRepo.isSearching);
|
||||
checkResults(addons, length);
|
||||
|
||||
server.stop(do_test_finished);
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Search results failed");
|
||||
}
|
||||
};
|
||||
|
||||
var FailCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Should not be called");
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Should not be called");
|
||||
}
|
||||
};
|
||||
|
||||
function run_test()
|
||||
{
|
||||
// Setup for test
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
// Install an add-on so we can check the same add-on isn't returns in the results
|
||||
startupEM();
|
||||
gEM.installItemFromFile(do_get_addon("test_bug397778"), NS_INSTALL_LOCATION_APPPROFILE);
|
||||
restartEM();
|
||||
|
||||
server = new nsHttpServer();
|
||||
server.registerDirectory("/", do_get_file("data"));
|
||||
server.start(4444);
|
||||
|
||||
// Point the addons repository to the test server
|
||||
gPrefs.setCharPref(PREF_GETADDONS_BROWSEADDONS, BROWSE);
|
||||
gPrefs.setCharPref(PREF_GETADDONS_BROWSERECOMMENDED, RECOMMENDED);
|
||||
gPrefs.setCharPref(PREF_GETADDONS_GETRECOMMENDED, "http://localhost:4444/test_bug404024.xml");
|
||||
gPrefs.setCharPref(PREF_GETADDONS_BROWSESEARCHRESULTS, SEARCH + "%TERMS%");
|
||||
gPrefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, "http://localhost:4444/test_%TERMS%.xml");
|
||||
|
||||
addonRepo = Components.classes["@mozilla.org/extensions/addon-repository;1"]
|
||||
.getService(Components.interfaces.nsIAddonRepository);
|
||||
|
||||
do_check_neq(addonRepo, null);
|
||||
// Check the homepage and recommended urls
|
||||
do_check_eq(addonRepo.homepageURL, BROWSE);
|
||||
do_check_eq(addonRepo.getRecommendedURL(), RECOMMENDED);
|
||||
|
||||
// Check that search urls are correct
|
||||
for (var i = 0; i < BROWSE_SEARCH_URLS.length; i++) {
|
||||
var url = addonRepo.getSearchURL(BROWSE_SEARCH_URLS[i][0]);
|
||||
if (url != BROWSE_SEARCH_URLS[i][1])
|
||||
do_throw("BROWSE_SEARCH_URL[" + i + "] returned " + url);
|
||||
}
|
||||
|
||||
do_test_pending();
|
||||
// This should fail because we cancel it immediately.
|
||||
addonRepo.retrieveRecommendedAddons(10, FailCallback);
|
||||
addonRepo.cancelSearch();
|
||||
// Pull some results.
|
||||
addonRepo.retrieveRecommendedAddons(10, RecommendedCallback);
|
||||
// Should be searching now and any attempt to retrieve again should be ignored
|
||||
do_check_true(addonRepo.isSearching);
|
||||
addonRepo.retrieveRecommendedAddons(10, FailCallback);
|
||||
}
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Dave Townsend <dtownsend@oxymoronical.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
const PREF_GETADDONS_BROWSEADDONS = "extensions.getAddons.browseAddons";
|
||||
const PREF_GETADDONS_BROWSERECOMMENDED = "extensions.getAddons.recommended.browseURL";
|
||||
const PREF_GETADDONS_GETRECOMMENDED = "extensions.getAddons.recommended.url";
|
||||
const PREF_GETADDONS_BROWSESEARCHRESULTS = "extensions.getAddons.search.browseURL";
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
|
||||
const BROWSE = "http://localhost:4444/";
|
||||
const RECOMMENDED = "http://localhost:4444/recommended.html";
|
||||
const SEARCH = "http://localhost:4444/search/";
|
||||
|
||||
var BROWSE_SEARCH_URLS = [
|
||||
["test", SEARCH + "test" ],
|
||||
["SEARCH", SEARCH + "SEARCH" ],
|
||||
["test search", SEARCH + "test%20search" ],
|
||||
["odd=search:with&weird\"characters", SEARCH + "odd%3Dsearch%3Awith%26weird%22characters" ]
|
||||
];
|
||||
|
||||
do_load_httpd_js();
|
||||
var server;
|
||||
var addonRepo;
|
||||
|
||||
var RESULTS = [
|
||||
{
|
||||
id: "test5@tests.mozilla.org",
|
||||
name: "PASS",
|
||||
version: "1.0",
|
||||
summary: "This should work fine",
|
||||
description: "Test description",
|
||||
rating: -1,
|
||||
iconURL: null,
|
||||
thumbnailURL: null,
|
||||
homepageURL: "https://addons.mozilla.org/addon/5992",
|
||||
eula: null,
|
||||
type: Ci.nsIUpdateItem.TYPE_EXTENSION,
|
||||
xpiURL: "http://localhost:4444/test.xpi",
|
||||
xpiHash: "sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3"
|
||||
},
|
||||
{
|
||||
id: "test6@tests.mozilla.org",
|
||||
name: "PASS",
|
||||
version: "1.0",
|
||||
summary: "Specific OS should work fine",
|
||||
description: null,
|
||||
rating: 4,
|
||||
iconURL: "http://localhost:4444/test_bug404024/icon.png",
|
||||
thumbnailURL: "http://localhost:4444/test_bug404024/thumbnail.png",
|
||||
homepageURL: null,
|
||||
eula: "EULA should be confirmed",
|
||||
type: Ci.nsIUpdateItem.TYPE_THEME,
|
||||
xpiURL: "http://localhost:4444/XPCShell.xpi",
|
||||
xpiHash: null
|
||||
}
|
||||
];
|
||||
|
||||
function checkResults(addons) {
|
||||
do_check_eq(addons.length, RESULTS.length);
|
||||
|
||||
for (var i = 0; i < addons.length; i++) {
|
||||
if (addons[i].name == "FAIL")
|
||||
do_throw(addons[i].id + " - " + addons[i].summary);
|
||||
if (addons[i].name != "PASS")
|
||||
do_throw(addons[i].id + " - " + "invalid add-on name " + addons[i].name);
|
||||
}
|
||||
|
||||
for (var i = 0; i < addons.length; i++) {
|
||||
for (var p in RESULTS[i]) {
|
||||
if (addons[i][p] != RESULTS[i][p])
|
||||
do_throw("Failed on property " + p + " on add-on " + addons[i].id +
|
||||
addons[i][p] + " == " + RESULTS[i][p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var RecommendedCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
// Search is complete
|
||||
do_check_false(addonRepo.isSearching);
|
||||
checkResults(addons);
|
||||
|
||||
// "search" for the same results
|
||||
addonRepo.searchAddons("bug417606", 10, SearchCallback);
|
||||
// Should be searching now and any attempt to retrieve again should be ignored
|
||||
do_check_true(addonRepo.isSearching);
|
||||
addonRepo.searchAddons("test search", 10, FailCallback);
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Recommended results failed");
|
||||
}
|
||||
};
|
||||
|
||||
var SearchCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
do_check_false(addonRepo.isSearching);
|
||||
do_check_eq(total, 100);
|
||||
checkResults(addons);
|
||||
|
||||
server.stop(do_test_finished);
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Search results failed");
|
||||
}
|
||||
};
|
||||
|
||||
var FailCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Should not be called");
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Should not be called");
|
||||
}
|
||||
};
|
||||
|
||||
function run_test()
|
||||
{
|
||||
// Setup for test
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
// Install an add-on so we can check the same add-on isn't returns in the results
|
||||
startupEM();
|
||||
gEM.installItemFromFile(do_get_addon("test_bug397778"), NS_INSTALL_LOCATION_APPPROFILE);
|
||||
restartEM();
|
||||
|
||||
server = new nsHttpServer();
|
||||
server.registerDirectory("/", do_get_file("data"));
|
||||
server.start(4444);
|
||||
|
||||
// Point the addons repository to the test server
|
||||
gPrefs.setCharPref(PREF_GETADDONS_BROWSEADDONS, BROWSE);
|
||||
gPrefs.setCharPref(PREF_GETADDONS_BROWSERECOMMENDED, RECOMMENDED);
|
||||
gPrefs.setCharPref(PREF_GETADDONS_GETRECOMMENDED, "http://localhost:4444/test_bug417606.xml");
|
||||
gPrefs.setCharPref(PREF_GETADDONS_BROWSESEARCHRESULTS, SEARCH + "%TERMS%");
|
||||
gPrefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, "http://localhost:4444/test_%TERMS%.xml");
|
||||
|
||||
addonRepo = Components.classes["@mozilla.org/extensions/addon-repository;1"]
|
||||
.getService(Components.interfaces.nsIAddonRepository);
|
||||
|
||||
do_check_neq(addonRepo, null);
|
||||
// Check the homepage and recommended urls
|
||||
do_check_eq(addonRepo.homepageURL, BROWSE);
|
||||
do_check_eq(addonRepo.getRecommendedURL(), RECOMMENDED);
|
||||
|
||||
// Check that search urls are correct
|
||||
for (var i = 0; i < BROWSE_SEARCH_URLS.length; i++) {
|
||||
var url = addonRepo.getSearchURL(BROWSE_SEARCH_URLS[i][0]);
|
||||
if (url != BROWSE_SEARCH_URLS[i][1])
|
||||
do_throw("BROWSE_SEARCH_URL[" + i + "] returned " + url);
|
||||
}
|
||||
|
||||
do_test_pending();
|
||||
// This should fail because we cancel it immediately.
|
||||
addonRepo.retrieveRecommendedAddons(10, FailCallback);
|
||||
addonRepo.cancelSearch();
|
||||
// Pull some results.
|
||||
addonRepo.retrieveRecommendedAddons(10, RecommendedCallback);
|
||||
// Should be searching now and any attempt to retrieve again should be ignored
|
||||
do_check_true(addonRepo.isSearching);
|
||||
addonRepo.retrieveRecommendedAddons(10, FailCallback);
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Dave Townsend <dtownsend@oxymoronical.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
const PREF_GETADDONS_GETRECOMMENDED = "extensions.getAddons.recommended.url";
|
||||
|
||||
do_load_httpd_js();
|
||||
var server;
|
||||
var addonRepo;
|
||||
|
||||
var RESULTS = [
|
||||
-1,
|
||||
-1,
|
||||
0,
|
||||
2,
|
||||
4,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
];
|
||||
|
||||
var RecommendedCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
dump("loaded");
|
||||
// Search is complete
|
||||
do_check_eq(length, RESULTS.length);
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (addons[i].rating != RESULTS[i])
|
||||
do_throw("Rating for " + addons[i].id + " was " + addons[i].rating + ", should have been " + RESULTS[i]);
|
||||
}
|
||||
server.stop(do_test_finished);
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Recommended results failed");
|
||||
}
|
||||
};
|
||||
|
||||
function run_test()
|
||||
{
|
||||
// EM needs to be running.
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
startupEM();
|
||||
|
||||
server = new nsHttpServer();
|
||||
server.registerDirectory("/", do_get_file("data"));
|
||||
server.start(4444);
|
||||
|
||||
// Point the addons repository to the test server
|
||||
gPrefs.setCharPref(PREF_GETADDONS_GETRECOMMENDED, "http://localhost:4444/test_bug424262.xml");
|
||||
|
||||
addonRepo = Components.classes["@mozilla.org/extensions/addon-repository;1"]
|
||||
.getService(Components.interfaces.nsIAddonRepository);
|
||||
|
||||
do_check_neq(addonRepo, null);
|
||||
|
||||
do_test_pending();
|
||||
// Pull some results.
|
||||
addonRepo.retrieveRecommendedAddons(RESULTS.length, RecommendedCallback);
|
||||
}
|
||||
|
|
@ -1,601 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Dave Townsend <dtownsend@oxymoronical.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
|
||||
|
||||
do_load_httpd_js();
|
||||
|
||||
var ADDONS = [{
|
||||
id: "test_bug449027_1@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 1",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_2@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 2",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_3@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 3",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_4@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 4",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_5@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 5",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_6@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 6",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_7@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 7",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_8@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 8",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_9@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 9",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_10@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 10",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_11@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 11",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_12@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 12",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_13@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 13",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_14@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 14",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_15@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 15",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_16@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 16",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_17@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 17",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_18@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 18",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
id: "test_bug449027_19@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 19",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_20@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 20",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_21@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 21",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_22@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 22",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_23@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 23",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_24@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 24",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
id: "test_bug449027_25@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 25",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}];
|
||||
|
||||
var PLUGINS = [{
|
||||
name: "test_bug449027_1",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_2",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_3",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_4",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_5",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_6",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_7",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_8",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_9",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_10",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_11",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_12",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_13",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_14",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_15",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_16",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_17",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_18",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false
|
||||
}, {
|
||||
name: "test_bug449027_19",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_20",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_21",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_22",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_23",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_24",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}, {
|
||||
name: "test_bug449027_25",
|
||||
version: "5",
|
||||
blocklisted: false,
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true
|
||||
}];
|
||||
|
||||
var gCallback = null;
|
||||
var gTestserver = null;
|
||||
var gNewBlocks = [];
|
||||
|
||||
// A fake plugin host for the blocklist service to use
|
||||
var PluginHost = {
|
||||
getPluginTags: function(countRef) {
|
||||
countRef.value = PLUGINS.length;
|
||||
return PLUGINS;
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsIPluginHost)
|
||||
|| iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
var PluginHostFactory = {
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return PluginHost.QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
|
||||
// Don't need the full interface, attempts to call other methods will just
|
||||
// throw which is just fine
|
||||
var WindowWatcher = {
|
||||
openWindow: function(parent, url, name, features, arguments) {
|
||||
// Should be called to list the newly blocklisted items
|
||||
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
|
||||
do_check_neq(gCallback, null);
|
||||
|
||||
var args = arguments.wrappedJSObject;
|
||||
|
||||
gNewBlocks = [];
|
||||
var list = args.list;
|
||||
for (var i = 0; i < list.length; i++)
|
||||
gNewBlocks.push(list[i].name + " " + list[i].version);
|
||||
|
||||
// Call the callback after the blocklist has finished up
|
||||
do_timeout(0, gCallback);
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsIWindowWatcher)
|
||||
|| iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
var WindowWatcherFactory = {
|
||||
createInstance: function createInstance(outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return WindowWatcher.QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
|
||||
"Fake Plugin Host",
|
||||
"@mozilla.org/plugin/host;1", PluginHostFactory);
|
||||
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
||||
"Fake Window Watcher",
|
||||
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
|
||||
|
||||
function create_addon(addon) {
|
||||
var installrdf = "<?xml version=\"1.0\"?>\n" +
|
||||
"\n" +
|
||||
"<RDF xmlns=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
|
||||
" xmlns:em=\"http://www.mozilla.org/2004/em-rdf#\">\n" +
|
||||
" <Description about=\"urn:mozilla:install-manifest\">\n" +
|
||||
" <em:id>" + addon.id + "</em:id>\n" +
|
||||
" <em:version>" + addon.version + "</em:version>\n" +
|
||||
" <em:targetApplication>\n" +
|
||||
" <Description>\n" +
|
||||
" <em:id>xpcshell@tests.mozilla.org</em:id>\n" +
|
||||
" <em:minVersion>3</em:minVersion>\n" +
|
||||
" <em:maxVersion>3</em:maxVersion>\n" +
|
||||
" </Description>\n" +
|
||||
" </em:targetApplication>\n" +
|
||||
" <em:name>" + addon.name + "</em:name>\n" +
|
||||
" </Description>\n" +
|
||||
"</RDF>\n";
|
||||
var target = gProfD.clone();
|
||||
target.append("extensions");
|
||||
target.append(addon.id);
|
||||
target.append("install.rdf");
|
||||
target.create(target.NORMAL_FILE_TYPE, 0644);
|
||||
var stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
stream.init(target, 0x04 | 0x08 | 0x20, 0664, 0); // write, create, truncate
|
||||
stream.write(installrdf, installrdf.length);
|
||||
stream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that items are blocklisted correctly according to the current test.
|
||||
* If a lastTest is provided checks that the notification dialog got passed
|
||||
* the newly blocked items compared to the previous test.
|
||||
*/
|
||||
function check_state(test, lastTest) {
|
||||
for (var i = 0; i < ADDONS.length; i++) {
|
||||
var blocked = getManifestProperty(ADDONS[i].id, "blocklisted") == "true";
|
||||
if (blocked != ADDONS[i][test])
|
||||
do_throw("Blocklist state did not match expected for extension " + (i + 1) + ", test " + test);
|
||||
}
|
||||
for (i = 0; i < PLUGINS.length; i++) {
|
||||
if (PLUGINS[i].blocklisted != PLUGINS[i][test])
|
||||
do_throw("Blocklist state did not match expected for plugin " + (i + 1) + ", test " + test);
|
||||
}
|
||||
|
||||
if (lastTest) {
|
||||
var expected = 0;
|
||||
for (i = 0; i < ADDONS.length; i++) {
|
||||
if (ADDONS[i][test] && !ADDONS[i][lastTest]) {
|
||||
if (gNewBlocks.indexOf(ADDONS[i].name + " " + ADDONS[i].version) < 0)
|
||||
do_throw("Addon " + (i + 1) + " should have been listed in the blocklist notification for test " + test);
|
||||
expected++;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < PLUGINS.length; i++) {
|
||||
if (PLUGINS[i][test] && !PLUGINS[i][lastTest]) {
|
||||
if (gNewBlocks.indexOf(PLUGINS[i].name + " " + PLUGINS[i].version) < 0)
|
||||
do_throw("Plugin " + (i + 1) + " should have been listed in the blocklist notification for test " + test);
|
||||
expected++;
|
||||
}
|
||||
}
|
||||
|
||||
do_check_eq(expected, gNewBlocks.length);
|
||||
}
|
||||
}
|
||||
|
||||
function load_blocklist(file) {
|
||||
gPrefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file);
|
||||
var blocklist = Components.classes["@mozilla.org/extensions/blocklist;1"]
|
||||
.getService(Components.interfaces.nsITimerCallback);
|
||||
blocklist.notify(null);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
// Setup for test
|
||||
dump("Setting up tests\n");
|
||||
// Rather than keeping lots of identical add-ons in version control, just
|
||||
// write them into the profile.
|
||||
for (var i = 0; i < ADDONS.length; i++)
|
||||
create_addon(ADDONS[i]);
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
|
||||
startupEM();
|
||||
|
||||
gTestserver = new nsHttpServer();
|
||||
gTestserver.registerDirectory("/data/", do_get_file("data"));
|
||||
gTestserver.start(4444);
|
||||
|
||||
do_test_pending();
|
||||
check_test_pt1();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the initial state is correct
|
||||
*/
|
||||
function check_test_pt1() {
|
||||
dump("Checking pt 1\n");
|
||||
for (var i = 0; i < ADDONS.length; i++) {
|
||||
if (!gEM.getItemForID(ADDONS[i].id))
|
||||
do_throw("Addon " + (i + 1) + " did not get installed correctly");
|
||||
}
|
||||
check_state("start", null);
|
||||
run_test_pt2();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the toolkit based blocks
|
||||
*/
|
||||
function run_test_pt2() {
|
||||
dump("Running test pt 2\n");
|
||||
gCallback = check_test_pt2;
|
||||
load_blocklist("test_bug449027_toolkit.xml");
|
||||
}
|
||||
|
||||
function check_test_pt2() {
|
||||
dump("Checking pt 2\n");
|
||||
check_state("toolkitBlocks", "start");
|
||||
run_test_pt3();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the application based blocks
|
||||
*/
|
||||
function run_test_pt3() {
|
||||
dump("Running test pt 3\n");
|
||||
gCallback = check_test_pt3;
|
||||
load_blocklist("test_bug449027_app.xml");
|
||||
}
|
||||
|
||||
function check_test_pt3() {
|
||||
dump("Checking pt 3\n");
|
||||
check_state("appBlocks", "toolkitBlocks");
|
||||
gTestserver.stop(do_test_finished);
|
||||
}
|
|
@ -1,530 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Dave Townsend <dtownsend@oxymoronical.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
|
||||
|
||||
do_load_httpd_js();
|
||||
|
||||
var ADDONS = [{
|
||||
// Tests how the blocklist affects a disabled add-on
|
||||
id: "test_bug455906_1@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 1",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled add-on
|
||||
id: "test_bug455906_2@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 2",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled add-on, to be disabled by the notification
|
||||
id: "test_bug455906_3@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 3",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}, {
|
||||
// Tests how the blocklist affects a disabled add-on that was already warned about
|
||||
id: "test_bug455906_4@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 4",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled add-on that was already warned about
|
||||
id: "test_bug455906_5@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 5",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}, {
|
||||
// Tests how the blocklist affects an already blocked add-on
|
||||
id: "test_bug455906_6@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 6",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}, {
|
||||
// Tests how the blocklist affects an incompatible add-on
|
||||
id: "test_bug455906_7@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 7",
|
||||
version: "5",
|
||||
appVersion: "2"
|
||||
}, {
|
||||
// Spare add-on used to ensure we get a notification when switching lists
|
||||
id: "dummy_bug455906_1@tests.mozilla.org",
|
||||
name: "Dummy Addon 1",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}, {
|
||||
// Spare add-on used to ensure we get a notification when switching lists
|
||||
id: "dummy_bug455906_2@tests.mozilla.org",
|
||||
name: "Dummy Addon 2",
|
||||
version: "5",
|
||||
appVersion: "3"
|
||||
}];
|
||||
|
||||
var PLUGINS = [{
|
||||
// Tests how the blocklist affects a disabled plugin
|
||||
name: "test_bug455906_1",
|
||||
version: "5",
|
||||
disabled: true,
|
||||
blocklisted: false
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled plugin
|
||||
name: "test_bug455906_2",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled plugin, to be disabled by the notification
|
||||
name: "test_bug455906_3",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false
|
||||
}, {
|
||||
// Tests how the blocklist affects a disabled plugin that was already warned about
|
||||
name: "test_bug455906_4",
|
||||
version: "5",
|
||||
disabled: true,
|
||||
blocklisted: false
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled plugin that was already warned about
|
||||
name: "test_bug455906_5",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false
|
||||
}, {
|
||||
// Tests how the blocklist affects an already blocked plugin
|
||||
name: "test_bug455906_6",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: true
|
||||
}];
|
||||
|
||||
var gNotificationCheck = null;
|
||||
var gTestCheck = null;
|
||||
var gTestserver = null;
|
||||
|
||||
// A fake plugin host for the blocklist service to use
|
||||
var PluginHost = {
|
||||
getPluginTags: function(countRef) {
|
||||
countRef.value = PLUGINS.length;
|
||||
return PLUGINS;
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsIPluginHost)
|
||||
|| iid.equals(Ci.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
var PluginHostFactory = {
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return PluginHost.QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
|
||||
// Don't need the full interface, attempts to call other methods will just
|
||||
// throw which is just fine
|
||||
var WindowWatcher = {
|
||||
openWindow: function(parent, url, name, features, arguments) {
|
||||
// Should be called to list the newly blocklisted items
|
||||
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
|
||||
|
||||
if (gNotificationCheck) {
|
||||
var args = arguments.wrappedJSObject;
|
||||
gNotificationCheck(args);
|
||||
}
|
||||
|
||||
// Call the next test after the blocklist has finished up
|
||||
do_timeout(0, gTestCheck);
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsIWindowWatcher)
|
||||
|| iid.equals(Ci.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
var WindowWatcherFactory = {
|
||||
createInstance: function createInstance(outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return WindowWatcher.QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
|
||||
"Fake Plugin Host",
|
||||
"@mozilla.org/plugin/host;1", PluginHostFactory);
|
||||
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
||||
"Fake Window Watcher",
|
||||
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
|
||||
|
||||
function create_addon(addon) {
|
||||
var installrdf = "<?xml version=\"1.0\"?>\n" +
|
||||
"\n" +
|
||||
"<RDF xmlns=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
|
||||
" xmlns:em=\"http://www.mozilla.org/2004/em-rdf#\">\n" +
|
||||
" <Description about=\"urn:mozilla:install-manifest\">\n" +
|
||||
" <em:id>" + addon.id + "</em:id>\n" +
|
||||
" <em:version>" + addon.version + "</em:version>\n" +
|
||||
" <em:targetApplication>\n" +
|
||||
" <Description>\n" +
|
||||
" <em:id>xpcshell@tests.mozilla.org</em:id>\n" +
|
||||
" <em:minVersion>" + addon.appVersion + "</em:minVersion>\n" +
|
||||
" <em:maxVersion>" + addon.appVersion + "</em:maxVersion>\n" +
|
||||
" </Description>\n" +
|
||||
" </em:targetApplication>\n" +
|
||||
" <em:name>" + addon.name + "</em:name>\n" +
|
||||
" </Description>\n" +
|
||||
"</RDF>\n";
|
||||
var target = gProfD.clone();
|
||||
target.append("extensions");
|
||||
target.append(addon.id);
|
||||
target.append("install.rdf");
|
||||
target.create(target.NORMAL_FILE_TYPE, 0644);
|
||||
var stream = Cc["@mozilla.org/network/file-output-stream;1"].
|
||||
createInstance(Ci.nsIFileOutputStream);
|
||||
stream.init(target, 0x04 | 0x08 | 0x20, 0664, 0); // write, create, truncate
|
||||
stream.write(installrdf, installrdf.length);
|
||||
stream.close();
|
||||
}
|
||||
|
||||
function load_blocklist(file) {
|
||||
gPrefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file);
|
||||
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
|
||||
getService(Ci.nsITimerCallback);
|
||||
blocklist.notify(null);
|
||||
}
|
||||
|
||||
function isUserDisabled(id) {
|
||||
return getManifestProperty(id, "userDisabled") == "true";
|
||||
}
|
||||
|
||||
function isAppDisabled(id) {
|
||||
return getManifestProperty(id, "appDisabled") == "true";
|
||||
}
|
||||
|
||||
function check_addon_state(id) {
|
||||
return isUserDisabled(id) + "," + isAppDisabled(id);
|
||||
}
|
||||
|
||||
function check_plugin_state(plugin) {
|
||||
return plugin.disabled + "," + plugin.blocklisted;
|
||||
}
|
||||
|
||||
// Performs the initial setup
|
||||
function run_test() {
|
||||
// Setup for test
|
||||
dump("Setting up tests\n");
|
||||
// Rather than keeping lots of identical add-ons in version control, just
|
||||
// write them into the profile.
|
||||
for (var i = 0; i < ADDONS.length; i++)
|
||||
create_addon(ADDONS[i]);
|
||||
|
||||
// Copy the initial blocklist into the profile to check add-ons start in the
|
||||
// right state.
|
||||
var blocklist = do_get_file("data/bug455906_start.xml")
|
||||
blocklist.copyTo(gProfD, "blocklist.xml");
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
|
||||
startupEM();
|
||||
|
||||
gTestserver = new nsHttpServer();
|
||||
gTestserver.registerDirectory("/data/", do_get_file("data"));
|
||||
gTestserver.start(4444);
|
||||
|
||||
do_test_pending();
|
||||
check_test_pt1();
|
||||
}
|
||||
|
||||
// Before every main test this is the state the add-ons are meant to be in
|
||||
function check_initial_state() {
|
||||
do_check_eq(check_addon_state(ADDONS[0].id), "true,false");
|
||||
do_check_eq(check_addon_state(ADDONS[1].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[2].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[3].id), "true,false");
|
||||
do_check_eq(check_addon_state(ADDONS[4].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[5].id), "false,true");
|
||||
do_check_eq(check_addon_state(ADDONS[6].id), "false,true");
|
||||
|
||||
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[2]), "false,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[3]), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[4]), "false,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[5]), "false,true");
|
||||
}
|
||||
|
||||
// Tests the add-ons were installed and the initial blocklist applied as expected
|
||||
function check_test_pt1() {
|
||||
dump("Checking pt 1\n");
|
||||
for (var i = 0; i < ADDONS.length; i++) {
|
||||
if (!gEM.getItemForID(ADDONS[i].id))
|
||||
do_throw("Addon " + (i + 1) + " did not get installed correctly");
|
||||
}
|
||||
|
||||
do_check_eq(check_addon_state(ADDONS[0].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[1].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[2].id), "false,false");
|
||||
|
||||
// Warn add-ons should be user disabled automatically
|
||||
do_check_eq(check_addon_state(ADDONS[3].id), "true,false");
|
||||
do_check_eq(check_addon_state(ADDONS[4].id), "true,false");
|
||||
|
||||
// Blocked and incompatible should be app disabled only
|
||||
do_check_eq(check_addon_state(ADDONS[5].id), "false,true");
|
||||
do_check_eq(check_addon_state(ADDONS[6].id), "false,true");
|
||||
|
||||
// We've overridden the plugin host so we cannot tell what that would have
|
||||
// initialised the plugins as
|
||||
|
||||
// Put the add-ons into the base state
|
||||
gEM.disableItem(ADDONS[0].id);
|
||||
gEM.enableItem(ADDONS[4].id);
|
||||
restartEM();
|
||||
check_initial_state();
|
||||
|
||||
gNotificationCheck = check_notification_pt2;
|
||||
gTestCheck = check_test_pt2;
|
||||
load_blocklist("bug455906_warn.xml");
|
||||
}
|
||||
|
||||
function check_notification_pt2(args) {
|
||||
dump("Checking notification pt 2\n");
|
||||
do_check_eq(args.list.length, 4);
|
||||
|
||||
for (let i = 0; i < args.list.length; i++) {
|
||||
let addon = args.list[i];
|
||||
if (addon.item instanceof Ci.nsIUpdateItem) {
|
||||
switch (addon.item.id) {
|
||||
case "test_bug455906_2@tests.mozilla.org":
|
||||
do_check_false(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_3@tests.mozilla.org":
|
||||
do_check_false(addon.blocked);
|
||||
addon.disable = true;
|
||||
break;
|
||||
default:
|
||||
do_throw("Unknown addon: " + addon.item.id);
|
||||
}
|
||||
}
|
||||
else if (addon.item instanceof Ci.nsIPluginTag) {
|
||||
switch (addon.item.name) {
|
||||
case "test_bug455906_2":
|
||||
do_check_false(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_3":
|
||||
do_check_false(addon.blocked);
|
||||
addon.disable = true;
|
||||
break;
|
||||
default:
|
||||
do_throw("Unknown addon: " + addon.item.name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
do_throw("Unknown add-on type " + addon.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function check_test_pt2() {
|
||||
restartEM();
|
||||
dump("Checking results pt 2\n");
|
||||
|
||||
// Should have disabled this add-on as requested
|
||||
do_check_eq(check_addon_state(ADDONS[2].id), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[2]), "true,false");
|
||||
|
||||
// The blocked add-on should have changed to user disabled
|
||||
do_check_eq(check_addon_state(ADDONS[5].id), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[5]), "true,false");
|
||||
|
||||
// These should have been unchanged
|
||||
do_check_eq(check_addon_state(ADDONS[0].id), "true,false");
|
||||
do_check_eq(check_addon_state(ADDONS[1].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[3].id), "true,false");
|
||||
do_check_eq(check_addon_state(ADDONS[4].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[6].id), "false,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[3]), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[4]), "false,false");
|
||||
|
||||
// Back to starting state
|
||||
gEM.enableItem(ADDONS[2].id);
|
||||
gEM.enableItem(ADDONS[5].id);
|
||||
PLUGINS[2].disabled = false;
|
||||
PLUGINS[5].disabled = false;
|
||||
restartEM();
|
||||
gNotificationCheck = null;
|
||||
gTestCheck = run_test_pt3;
|
||||
load_blocklist("bug455906_start.xml");
|
||||
}
|
||||
|
||||
function run_test_pt3() {
|
||||
restartEM();
|
||||
check_initial_state();
|
||||
|
||||
gNotificationCheck = check_notification_pt3;
|
||||
gTestCheck = check_test_pt3;
|
||||
load_blocklist("bug455906_block.xml");
|
||||
}
|
||||
|
||||
function check_notification_pt3(args) {
|
||||
dump("Checking notification pt 3\n");
|
||||
do_check_eq(args.list.length, 6);
|
||||
|
||||
for (let i = 0; i < args.list.length; i++) {
|
||||
let addon = args.list[i];
|
||||
if (addon.item instanceof Ci.nsIUpdateItem) {
|
||||
switch (addon.item.id) {
|
||||
case "test_bug455906_2@tests.mozilla.org":
|
||||
do_check_true(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_3@tests.mozilla.org":
|
||||
do_check_true(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_5@tests.mozilla.org":
|
||||
do_check_true(addon.blocked);
|
||||
break;
|
||||
default:
|
||||
do_throw("Unknown addon: " + addon.item.id);
|
||||
}
|
||||
}
|
||||
else if (addon.item instanceof Ci.nsIPluginTag) {
|
||||
switch (addon.item.name) {
|
||||
case "test_bug455906_2":
|
||||
do_check_true(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_3":
|
||||
do_check_true(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_5":
|
||||
do_check_true(addon.blocked);
|
||||
break;
|
||||
default:
|
||||
do_throw("Unknown addon: " + addon.item.name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
do_throw("Unknown add-on type " + addon.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function check_test_pt3() {
|
||||
restartEM();
|
||||
dump("Checking results pt 3\n");
|
||||
|
||||
// All should have gained the blocklist state, user disabled as previously
|
||||
do_check_eq(check_addon_state(ADDONS[0].id), "true,true");
|
||||
do_check_eq(check_addon_state(ADDONS[1].id), "false,true");
|
||||
do_check_eq(check_addon_state(ADDONS[2].id), "false,true");
|
||||
do_check_eq(check_addon_state(ADDONS[3].id), "true,true");
|
||||
do_check_eq(check_addon_state(ADDONS[4].id), "false,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[0]), "true,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[1]), "false,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[2]), "false,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[3]), "true,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[4]), "false,true");
|
||||
|
||||
// Shouldn't be changed
|
||||
do_check_eq(check_addon_state(ADDONS[5].id), "false,true");
|
||||
do_check_eq(check_addon_state(ADDONS[6].id), "false,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[5]), "false,true");
|
||||
|
||||
// Back to starting state
|
||||
gNotificationCheck = null;
|
||||
gTestCheck = run_test_pt4;
|
||||
load_blocklist("bug455906_start.xml");
|
||||
}
|
||||
|
||||
function run_test_pt4() {
|
||||
gEM.enableItem(ADDONS[4].id);
|
||||
PLUGINS[4].disabled = false;
|
||||
restartEM();
|
||||
check_initial_state();
|
||||
|
||||
gNotificationCheck = check_notification_pt4;
|
||||
gTestCheck = check_test_pt4;
|
||||
load_blocklist("bug455906_empty.xml");
|
||||
}
|
||||
|
||||
function check_notification_pt4(args) {
|
||||
dump("Checking notification pt 4\n");
|
||||
|
||||
// Should be just the dummy add-on to force this notification
|
||||
do_check_eq(args.list.length, 1);
|
||||
do_check_true(args.list[0].item instanceof Ci.nsIUpdateItem);
|
||||
do_check_eq(args.list[0].item.id, "dummy_bug455906_2@tests.mozilla.org");
|
||||
}
|
||||
|
||||
function check_test_pt4() {
|
||||
restartEM();
|
||||
dump("Checking results pt 4\n");
|
||||
|
||||
// This should have become unblocked
|
||||
do_check_eq(check_addon_state(ADDONS[5].id), "false,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[5]), "false,false");
|
||||
|
||||
// No change for anything else
|
||||
do_check_eq(check_addon_state(ADDONS[0].id), "true,false");
|
||||
do_check_eq(check_addon_state(ADDONS[1].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[2].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[3].id), "true,false");
|
||||
do_check_eq(check_addon_state(ADDONS[4].id), "false,false");
|
||||
do_check_eq(check_addon_state(ADDONS[6].id), "false,true");
|
||||
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[2]), "false,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[3]), "true,false");
|
||||
do_check_eq(check_plugin_state(PLUGINS[4]), "false,false");
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
function finish() {
|
||||
gTestserver.stop(do_test_finished);
|
||||
}
|
|
@ -1,194 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Blair McBride <bmcbride@mozilla.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
do_load_httpd_js();
|
||||
|
||||
|
||||
const nsIBLS = Ci.nsIBlocklistService;
|
||||
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
|
||||
|
||||
var gBlocklist = null;
|
||||
var gPrefs = null;
|
||||
var gTestserver = null;
|
||||
|
||||
var gNextTestPart = null;
|
||||
|
||||
|
||||
var PLUGINS = [{
|
||||
// Tests a plugin whose state goes from not-blocked, to outdated
|
||||
name: "test_bug514327_outdated",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false
|
||||
}, {
|
||||
// Used to trigger the blocklist dialog, which indicates the blocklist has updated
|
||||
name: "test_bug514327_1",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false
|
||||
}, {
|
||||
// Used to trigger the blocklist dialog, which indicates the blocklist has updated
|
||||
name: "test_bug514327_2",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false
|
||||
} ];
|
||||
|
||||
|
||||
// A fake plugin host for the blocklist service to use
|
||||
var PluginHost = {
|
||||
getPluginTags: function(countRef) {
|
||||
countRef.value = PLUGINS.length;
|
||||
return PLUGINS;
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsIPluginHost)
|
||||
|| iid.equals(Ci.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
var PluginHostFactory = {
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return PluginHost.QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
|
||||
// Don't need the full interface, attempts to call other methods will just
|
||||
// throw which is just fine
|
||||
var WindowWatcher = {
|
||||
openWindow: function(parent, url, name, features, arguments) {
|
||||
// Should be called to list the newly blocklisted items
|
||||
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
|
||||
// Should only include one item
|
||||
do_check_eq(arguments.wrappedJSObject.list.length, 1);
|
||||
// And that item should be the blocked plugin, not the outdated one
|
||||
var item = arguments.wrappedJSObject.list[0];
|
||||
do_check_true(item.item instanceof Ci.nsIPluginTag);
|
||||
do_check_neq(item.name, "test_bug514327_outdated");
|
||||
|
||||
// Call the next test after the blocklist has finished up
|
||||
do_timeout(0, gNextTestPart);
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsIWindowWatcher)
|
||||
|| iid.equals(Ci.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
var WindowWatcherFactory = {
|
||||
createInstance: function createInstance(outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return WindowWatcher.QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
|
||||
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
|
||||
"Fake Plugin Host",
|
||||
"@mozilla.org/plugin/host;1", PluginHostFactory);
|
||||
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
||||
"Fake Window Watcher",
|
||||
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
|
||||
|
||||
|
||||
function do_update_blocklist(aDatafile, aNextPart) {
|
||||
gNextTestPart = aNextPart;
|
||||
|
||||
gPrefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + aDatafile);
|
||||
gBlocklist.QueryInterface(Ci.nsITimerCallback).notify(null);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
gTestserver = new nsHttpServer();
|
||||
gTestserver.registerDirectory("/data/", do_get_file("data"));
|
||||
gTestserver.start(4444);
|
||||
|
||||
|
||||
// initialize the blocklist with no entries
|
||||
var source = do_get_file("data/test_bug514327_3_empty.xml");
|
||||
source.copyTo(gProfD, "blocklist.xml");
|
||||
|
||||
gPrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch2);
|
||||
gBlocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(nsIBLS);
|
||||
|
||||
// should NOT be marked as outdated by the blocklist
|
||||
do_check_true(gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED);
|
||||
|
||||
do_test_pending();
|
||||
|
||||
// update blocklist with data that marks the plugin as outdated
|
||||
do_update_blocklist("test_bug514327_3_outdated_1.xml", test_part_1);
|
||||
}
|
||||
|
||||
function test_part_1() {
|
||||
// plugin should now be marked as outdated
|
||||
do_check_true(gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_OUTDATED);
|
||||
// and the notifyUser pref should be set to true
|
||||
do_check_true(gPrefs.getBoolPref("plugins.update.notifyUser"));
|
||||
|
||||
// preternd the user has been notified, reset the pref
|
||||
gPrefs.setBoolPref("plugins.update.notifyUser", false);
|
||||
|
||||
// update blocklist with data that marks the plugin as outdated
|
||||
do_update_blocklist("test_bug514327_3_outdated_2.xml", test_part_2);
|
||||
}
|
||||
|
||||
function test_part_2() {
|
||||
// plugin should still be marked as outdated
|
||||
do_check_true(gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_OUTDATED);
|
||||
// and the notifyUser pref should NOT be set to true, as the plugin was already outdated
|
||||
do_check_false(gPrefs.getBoolPref("plugins.update.notifyUser"));
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
function finish() {
|
||||
gTestserver.stop(do_test_finished);
|
||||
}
|
Загрузка…
Ссылка в новой задаче