зеркало из https://github.com/mozilla/pjs.git
Bug 435788: Plugin finder service can't install plugins using installerLocation, stage 1. r=robstrong
This commit is contained in:
Родитель
a39e374d59
Коммит
ba1cc8ffd6
|
@ -5935,7 +5935,8 @@ missingPluginInstaller.prototype.newDisabledPlugin = function(aEvent){
|
|||
}
|
||||
|
||||
missingPluginInstaller.prototype.refreshBrowser = function(aEvent) {
|
||||
var browser = aEvent.target;
|
||||
// browser elements are anonymous so we can't just use target.
|
||||
var browser = aEvent.originalTarget;
|
||||
var notificationBox = gBrowser.getNotificationBox(browser);
|
||||
var notification = notificationBox.getNotificationWithValue("missing-plugins");
|
||||
|
||||
|
|
|
@ -44,5 +44,14 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
EXTRA_COMPONENTS = pluginGlue.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
ifdef ENABLE_TESTS
|
||||
# OSX will display a security warning when running the downloaded installer
|
||||
ifneq (Darwin,$(OS_TARGET))
|
||||
# On Linux nsILocalFile.launch will only open documents, not run executables
|
||||
ifneq (Linux,$(OS_TARGET))
|
||||
DIRS += tests
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -85,9 +85,13 @@ InstallerObserver.prototype = {
|
|||
var uri = ios.newURI(this._plugin.InstallerLocation, null, null);
|
||||
uri.QueryInterface(Components.interfaces.nsIURL);
|
||||
|
||||
// Use a local filename appropriate for the OS
|
||||
var leafName = uri.fileName;
|
||||
if (leafName.indexOf('.') == -1)
|
||||
throw "Filename needs to contain a dot for platform-native launching to work correctly.";
|
||||
var os = Components.classes["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Components.interfaces.nsIXULRuntime)
|
||||
.OS;
|
||||
if (os == "WINNT" && leafName.indexOf(".") < 0)
|
||||
leafName += ".exe";
|
||||
|
||||
var dirs = Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties);
|
||||
|
@ -95,7 +99,7 @@ InstallerObserver.prototype = {
|
|||
var resultFile = dirs.get("TmpD", Components.interfaces.nsIFile);
|
||||
resultFile.append(leafName);
|
||||
resultFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE,
|
||||
0x770);
|
||||
0770);
|
||||
|
||||
var channel = ios.newChannelFromURI(uri);
|
||||
this._downloader =
|
||||
|
@ -174,6 +178,8 @@ InstallerObserver.prototype = {
|
|||
|
||||
result.QueryInterface(Components.interfaces.nsILocalFile);
|
||||
try {
|
||||
// Make sure the file is executable
|
||||
result.permissions = 0770;
|
||||
result.launch();
|
||||
this._fireNotification(nsIXPIProgressDialog.INSTALL_DONE, null);
|
||||
// It would be nice to remove the tempfile, but we don't have
|
||||
|
|
|
@ -481,7 +481,7 @@ nsPluginInstallerWizard.prototype.showPluginResults = function (){
|
|||
notInstalledList += "&mimetype=" + pluginInfoItem;
|
||||
} else if (!myPluginItem.licenseAccepted) {
|
||||
statusMsg = this.getString("pluginInstallationSummary.licenseNotAccepted");
|
||||
} else if (!myPluginItem.XPILocation) {
|
||||
} else if (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation) {
|
||||
statusMsg = this.getString("pluginInstallationSummary.notAvailable");
|
||||
notInstalledList += "&mimetype=" + pluginInfoItem;
|
||||
} else {
|
||||
|
@ -495,7 +495,8 @@ nsPluginInstallerWizard.prototype.showPluginResults = function (){
|
|||
|
||||
// manual url - either returned from the webservice or the pluginspage attribute
|
||||
var manualUrl;
|
||||
if ((myPluginItem.error || !myPluginItem.XPILocation) && (myPluginItem.manualInstallationURL || this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage)){
|
||||
if ((myPluginItem.error || (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation)) &&
|
||||
(myPluginItem.manualInstallationURL || this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage)){
|
||||
manualUrl = myPluginItem.manualInstallationURL ? myPluginItem.manualInstallationURL : this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage;
|
||||
}
|
||||
|
||||
|
@ -669,13 +670,25 @@ function wizardFinish(){
|
|||
|
||||
// don't refresh if no plugins were found or installed
|
||||
if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) &&
|
||||
(gPluginInstaller.mPluginInfoArray.length != 0) &&
|
||||
gPluginInstaller.mBrowser) {
|
||||
// notify listeners that a plugin is installed,
|
||||
// so that they can reset the UI and update the browser.
|
||||
var event = document.createEvent("Events");
|
||||
event.initEvent("NewPluginInstalled", true, true);
|
||||
gPluginInstaller.mBrowser.dispatchEvent(event);
|
||||
(gPluginInstaller.mPluginInfoArray.length != 0)) {
|
||||
|
||||
// reload plugins so JS detection works immediately
|
||||
try {
|
||||
var pm = Components.classes["@mozilla.org/plugin/manager;1"]
|
||||
.getService(Components.interfaces.nsIPluginManager);
|
||||
pm.reloadPlugins(false);
|
||||
}
|
||||
catch (e) {
|
||||
// reloadPlugins throws an exception if there were no plugins to load
|
||||
}
|
||||
|
||||
if (gPluginInstaller.mBrowser) {
|
||||
// notify listeners that a plugin is installed,
|
||||
// so that they can reset the UI and update the browser.
|
||||
var event = document.createEvent("Events");
|
||||
event.initEvent("NewPluginInstalled", true, true);
|
||||
gPluginInstaller.mBrowser.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
# ***** 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 Plugin Finder Service.
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = test_plugins
|
||||
relativesrcdir = toolkit/mozapps/plugins/tests
|
||||
TESTROOT = $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
_BROWSER_FILES = \
|
||||
browser_bug435788.js \
|
||||
pfs_bug435788_1.rdf \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
GoodPlugin.cpp \
|
||||
$(NULL)
|
||||
|
||||
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
|
||||
|
||||
PROGRAMS = $(SIMPLE_PROGRAMS:%$(BIN_SUFFIX)=$(TESTROOT)/%)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
$(PROGRAMS): $(TESTROOT)/% : %$(BIN_SUFFIX)
|
||||
$(NSINSTALL) -D $(TESTROOT)
|
||||
cp $^ $@
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(TESTROOT)
|
||||
|
||||
libs:: $(PROGRAMS)
|
|
@ -0,0 +1,90 @@
|
|||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
const TEST_ROOT = "http://example.com/browser/toolkit/mozapps/plugins/tests/";
|
||||
|
||||
var gPrefs, gPFS, gDS;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gPrefs = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
gDS = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
prepare_test_1();
|
||||
}
|
||||
|
||||
function finishTest(e) {
|
||||
gPrefs.clearUserPref("pfs.datasource.url");
|
||||
finish();
|
||||
}
|
||||
|
||||
function delete_installer() {
|
||||
// Guess at the filename for the installer and delete it
|
||||
try {
|
||||
var filename = "setup";
|
||||
if (Components.classes["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Components.interfaces.nsIXULRuntime)
|
||||
.OS == "WINNT")
|
||||
filename += ".exe";
|
||||
var file = gDS.get("TmpD", Ci.nsIFile);
|
||||
file.append(filename);
|
||||
if (file.exists())
|
||||
file.remove(false);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
|
||||
function prepare_test_1() {
|
||||
gPrefs.setCharPref("pfs.datasource.url", TEST_ROOT + "pfs_bug435788_1.rdf");
|
||||
|
||||
var missingPluginsArray = {
|
||||
"application/x-working-plugin": {
|
||||
mimetype: "application/x-working-plugin",
|
||||
pluginsPage: ""
|
||||
}
|
||||
};
|
||||
|
||||
gPFS = window.openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
|
||||
"PFSWindow", "chrome,centerscreen,resizable=yes",
|
||||
{plugins: missingPluginsArray});
|
||||
gPFS.addEventListener("load", test_1_start, false);
|
||||
}
|
||||
|
||||
function test_1_start() {
|
||||
gPFS.addEventListener("unload", finishTest, false);
|
||||
|
||||
gPFS.document.documentElement.wizardPages[1].addEventListener("pageshow", function() {
|
||||
executeSoon(test_1_available);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test_1_available() {
|
||||
var list = gPFS.document.getElementById("pluginList");
|
||||
is(list.childNodes.length, 1, "Should have found 1 plugin to install");
|
||||
is(list.childNodes[0].label, "Test plugin 1 ", "Should have seen the right plugin name");
|
||||
|
||||
gPFS.document.documentElement.wizardPages[4].addEventListener("pageshow", function() {
|
||||
executeSoon(test_1_complete);
|
||||
}, false);
|
||||
gPFS.document.documentElement.getButton("next").click();
|
||||
}
|
||||
|
||||
function test_1_complete() {
|
||||
var list = gPFS.document.getElementById("pluginResultList");
|
||||
is(list.childNodes.length, 1, "Should have attempted to install 1 plugin");
|
||||
var status = list.childNodes[0].childNodes[2];
|
||||
is(status.tagName, "label", "Should have a status");
|
||||
is(status.value, "Installed", "Should have been a successful install");
|
||||
|
||||
// This is necessary because PFS doesn't delete the installer it runs. Give it
|
||||
// a second to finish then delete it ourselves
|
||||
setTimeout(test_1_finish, 1000);
|
||||
}
|
||||
|
||||
function test_1_finish() {
|
||||
delete_installer();
|
||||
|
||||
gPFS.document.documentElement.getButton("finish").click();
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:pfs="http://www.mozilla.org/2004/pfs-rdf#">
|
||||
|
||||
<RDF:Description about="urn:mozilla:plugin-results:application/x-working-plugin">
|
||||
<pfs:plugins><RDF:Seq>
|
||||
<RDF:li resource="urn:mozilla:plugin:{8d3ab839-e03e-41a5-acd3-be1eabf94810}"/>
|
||||
</RDF:Seq></pfs:plugins>
|
||||
</RDF:Description>
|
||||
|
||||
<RDF:Description about="urn:mozilla:plugin:{8d3ab839-e03e-41a5-acd3-be1eabf94810}">
|
||||
<pfs:updates><RDF:Seq>
|
||||
<RDF:li resource="urn:mozilla:plugin:{8d3ab839-e03e-41a5-acd3-be1eabf94810}:"/>
|
||||
</RDF:Seq></pfs:updates>
|
||||
</RDF:Description>
|
||||
|
||||
<RDF:Description about="urn:mozilla:plugin:{8d3ab839-e03e-41a5-acd3-be1eabf94810}:">
|
||||
<pfs:name>Test plugin 1</pfs:name>
|
||||
<pfs:requestedMimetype>application/x-working-plugin</pfs:requestedMimetype>
|
||||
<pfs:guid>{8d3ab839-e03e-41a5-acd3-be1eabf94810}</pfs:guid>
|
||||
<pfs:version/>
|
||||
<pfs:IconUrl/>
|
||||
<pfs:InstallerLocation>http://example.com/browser/toolkit/mozapps/plugins/tests/GoodPlugin</pfs:InstallerLocation>
|
||||
<pfs:InstallerHash/>
|
||||
<pfs:InstallerShowsUI>false</pfs:InstallerShowsUI>
|
||||
<pfs:manualInstallationURL>http://www.mozilla.com</pfs:manualInstallationURL>
|
||||
<pfs:licenseURL/>
|
||||
<pfs:needsRestart>false</pfs:needsRestart>
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
Загрузка…
Ссылка в новой задаче