зеркало из https://github.com/mozilla/pjs.git
Patch 2 (tests only) - Bug 583408 - Notify user when the certificate attribute check fails. r=dtownsend, a=blocking2.0-beta6
This commit is contained in:
Родитель
1b16de559c
Коммит
e78bac6cb3
|
@ -85,8 +85,13 @@ _CHROME_FILES = \
|
||||||
test_0111_neverButton_basic.xul \
|
test_0111_neverButton_basic.xul \
|
||||||
test_0112_neverButton_billboard.xul \
|
test_0112_neverButton_billboard.xul \
|
||||||
test_0113_showNeverForVersionRemovedWithPref.xul \
|
test_0113_showNeverForVersionRemovedWithPref.xul \
|
||||||
test_0120_cert_valid_attributes_not_builtin.xul \
|
test_0121_check_requireBuiltinCert.xul \
|
||||||
test_0121_cert_invalid_attribute_name.xul \
|
test_0122_check_allowNonBuiltinCert_validCertAttrs.xul \
|
||||||
|
test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul \
|
||||||
|
test_0131_check_invalidCertAttrs_noUpdate.xul \
|
||||||
|
test_0132_check_invalidCertAttrs_hasUpdate.xul \
|
||||||
|
test_0141_notify_invalidCertAttrs_noUpdate.xul \
|
||||||
|
test_0142_notify_invalidCertAttrs_hasUpdate.xul \
|
||||||
test_9999_cleanup.xul \
|
test_9999_cleanup.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
|
||||||
<window title="Test update checking wizard with valid certificate attribute names and values and cert not built-in"
|
<window title="Test update check with certificate that is not built-in and valid certificate attribute names and values"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="runTestDefault();">
|
onload="runTestDefault();">
|
||||||
<script type="application/javascript"
|
<script type="application/javascript"
|
||||||
|
@ -35,7 +35,6 @@ const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName",
|
||||||
"md5Fingerprint", "tokenName", "issuerName", "serialNumber",
|
"md5Fingerprint", "tokenName", "issuerName", "serialNumber",
|
||||||
"issuerCommonName", "issuerOrganization",
|
"issuerCommonName", "issuerOrganization",
|
||||||
"issuerOrganizationUnit", "dbKey", "windowTitle"];
|
"issuerOrganizationUnit", "dbKey", "windowTitle"];
|
||||||
var gDefaultAppUpdateURL;
|
|
||||||
|
|
||||||
function runTest() {
|
function runTest() {
|
||||||
debugDump("Entering runTest");
|
debugDump("Entering runTest");
|
||||||
|
@ -81,27 +80,15 @@ function testXHRLoad(aEvent) {
|
||||||
aCertAttrName, cert[aCertAttrName]);
|
aCertAttrName, cert[aCertAttrName]);
|
||||||
});
|
});
|
||||||
|
|
||||||
var queryString = "?showDetails=1" + getVersionParams();
|
let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" +
|
||||||
var url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" +
|
|
||||||
getVersionParams();
|
getVersionParams();
|
||||||
gDefaultAppUpdateURL = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
||||||
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
||||||
debugDump("Default Update URL: " + url);
|
debugDump("Default Update URL: " + url);
|
||||||
|
|
||||||
gUP.checkForUpdates();
|
gUP.checkForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishTest() {
|
|
||||||
debugDump("Entering finishTest");
|
|
||||||
|
|
||||||
CERT_ATTRS.forEach(function(aCertAttrName) {
|
|
||||||
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERTS_BRANCH + "1." +
|
|
||||||
aCertAttrName);
|
|
||||||
});
|
|
||||||
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, gDefaultAppUpdateURL);
|
|
||||||
finishTestDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
|
||||||
|
<window title="Test update check without requiring a certificate that is built-in and valid certificate attribute names and values"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
|
onload="runTestDefault();">
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
const TESTS = [ {
|
||||||
|
pageid: PAGEID_CHECKING
|
||||||
|
}, {
|
||||||
|
pageid: PAGEID_FOUND_BASIC,
|
||||||
|
buttonClick: "extra1"
|
||||||
|
} ];
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/CertUtils.jsm");
|
||||||
|
|
||||||
|
const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName",
|
||||||
|
"organization", "organizationalUnit", "sha1Fingerprint",
|
||||||
|
"md5Fingerprint", "tokenName", "issuerName", "serialNumber",
|
||||||
|
"issuerCommonName", "issuerOrganization",
|
||||||
|
"issuerOrganizationUnit", "dbKey", "windowTitle"];
|
||||||
|
|
||||||
|
function runTest() {
|
||||||
|
debugDump("Entering runTest");
|
||||||
|
|
||||||
|
var request = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
|
||||||
|
createInstance(AUS_Ci.nsIXMLHttpRequest);
|
||||||
|
request.open("GET", "https://example.com/", true);
|
||||||
|
request.channel.notificationCallbacks = new BadCertHandler(true);
|
||||||
|
request.onload = function(event) { testXHRLoad(event); };
|
||||||
|
request.onerror = function(event) { testXHRError(event); };
|
||||||
|
request.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testXHRError(aEvent) {
|
||||||
|
debugDump("Entering testXHRError");
|
||||||
|
|
||||||
|
ok(true, "Entering testXHRError - something went wrong");
|
||||||
|
|
||||||
|
var request = aEvent.target;
|
||||||
|
var status = 0;
|
||||||
|
try {
|
||||||
|
status = request.status;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == 0)
|
||||||
|
status = request.channel.QueryInterface(AUS_Ci.nsIRequest).status;
|
||||||
|
|
||||||
|
ok(false, "XHR onerror called: " + status);
|
||||||
|
|
||||||
|
finishTestDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
function testXHRLoad(aEvent) {
|
||||||
|
debugDump("Entering testXHRLoad");
|
||||||
|
|
||||||
|
var channel = aEvent.target.channel;
|
||||||
|
var cert = channel.securityInfo.QueryInterface(AUS_Ci.nsISSLStatusProvider).
|
||||||
|
SSLStatus.QueryInterface(AUS_Ci.nsISSLStatus).serverCert;
|
||||||
|
CERT_ATTRS.forEach(function(aCertAttrName) {
|
||||||
|
Services.prefs.setCharPref(PREF_APP_UPDATE_CERTS_BRANCH + "1." +
|
||||||
|
aCertAttrName, cert[aCertAttrName]);
|
||||||
|
});
|
||||||
|
|
||||||
|
Services.prefs.setBoolPref(PREF_APP_UPDATE_CERT_REQUIREBUILTIN, false);
|
||||||
|
|
||||||
|
let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" +
|
||||||
|
getVersionParams();
|
||||||
|
gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
||||||
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
||||||
|
debugDump("Default Update URL: " + url);
|
||||||
|
|
||||||
|
gUP.checkForUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test"></pre>
|
||||||
|
</body>
|
||||||
|
</window>
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
|
||||||
|
<window title="Test update check without requiring a certificate that is built-in and without the certificate attribute check"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
|
onload="runTestDefault();">
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
const TESTS = [ {
|
||||||
|
pageid: PAGEID_CHECKING
|
||||||
|
}, {
|
||||||
|
pageid: PAGEID_FOUND_BASIC,
|
||||||
|
buttonClick: "extra1"
|
||||||
|
} ];
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/CertUtils.jsm");
|
||||||
|
|
||||||
|
function runTest() {
|
||||||
|
debugDump("Entering runTest");
|
||||||
|
|
||||||
|
Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME,
|
||||||
|
"Invalid Attribute Name");
|
||||||
|
Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_ERRORS, 1);
|
||||||
|
Services.prefs.setBoolPref(PREF_APP_UPDATE_CERT_REQUIREBUILTIN, false);
|
||||||
|
Services.prefs.setBoolPref(PREF_APP_UPDATE_CERT_CHECKATTRS, false);
|
||||||
|
|
||||||
|
let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" +
|
||||||
|
getVersionParams();
|
||||||
|
gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
||||||
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
||||||
|
debugDump("Default Update URL: " + url);
|
||||||
|
|
||||||
|
gUP.checkForUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test"></pre>
|
||||||
|
</body>
|
||||||
|
</window>
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
|
||||||
|
<window title="Test update check with invalid certificate attribute name with no update"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
|
onload="runTestDefault();">
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
const TESTS = [ {
|
||||||
|
pageid: PAGEID_CHECKING
|
||||||
|
}, {
|
||||||
|
pageid: PAGEID_ERROR_CERT_CHECK,
|
||||||
|
extraDelayedCheckFunction: checkCertErrorPage,
|
||||||
|
shouldBeHidden: false,
|
||||||
|
buttonClick: "finish"
|
||||||
|
} ];
|
||||||
|
|
||||||
|
function runTest() {
|
||||||
|
debugDump("Entering runTest");
|
||||||
|
|
||||||
|
Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME,
|
||||||
|
"Invalid Attribute Name");
|
||||||
|
Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_ERRORS, 1);
|
||||||
|
|
||||||
|
let url = "https://example.com/" + URL_PATH + "/update.sjs?noUpdates=1";
|
||||||
|
gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
||||||
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
||||||
|
debugDump("Default Update URL: " + url);
|
||||||
|
|
||||||
|
gUP.checkForUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test"></pre>
|
||||||
|
</body>
|
||||||
|
</window>
|
|
@ -8,7 +8,7 @@
|
||||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
|
||||||
<window title="Test update checking wizard with invalid certificate attribute name"
|
<window title="Test update check with invalid certificate attribute name with an update"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="runTestDefault();">
|
onload="runTestDefault();">
|
||||||
<script type="application/javascript"
|
<script type="application/javascript"
|
||||||
|
@ -20,42 +20,32 @@
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
// This is treated as no updates found until Bug 583408 is fixed
|
|
||||||
const TESTS = [ {
|
const TESTS = [ {
|
||||||
pageid: PAGEID_CHECKING
|
pageid: PAGEID_CHECKING
|
||||||
}, {
|
}, {
|
||||||
pageid: PAGEID_NO_UPDATES_FOUND,
|
pageid: PAGEID_ERROR_CERT_CHECK,
|
||||||
|
extraDelayedCheckFunction: checkCertErrorPage,
|
||||||
|
shouldBeHidden: true,
|
||||||
buttonClick: "finish"
|
buttonClick: "finish"
|
||||||
} ];
|
} ];
|
||||||
|
|
||||||
const PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME = PREF_APP_UPDATE_CERTS_BRANCH +
|
|
||||||
"1.invalidName";
|
|
||||||
var gDefaultAppUpdateURL;
|
|
||||||
|
|
||||||
function runTest() {
|
function runTest() {
|
||||||
debugDump("Entering runTest");
|
debugDump("Entering runTest");
|
||||||
|
|
||||||
Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME,
|
Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME,
|
||||||
"Invalid Attribute Name");
|
"Invalid Attribute Name");
|
||||||
|
Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_ERRORS, 1);
|
||||||
|
|
||||||
var queryString = "?showDetails=1" + getVersionParams();
|
let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" +
|
||||||
var url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" +
|
|
||||||
getVersionParams();
|
getVersionParams();
|
||||||
gDefaultAppUpdateURL = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
||||||
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
||||||
debugDump("Default Update URL: " + url);
|
debugDump("Default Update URL: " + url);
|
||||||
|
|
||||||
gUP.checkForUpdates();
|
gUP.checkForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishTest() {
|
|
||||||
debugDump("Entering finishTest - clearing user preference " +
|
|
||||||
PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME);
|
|
||||||
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME);
|
|
||||||
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, gDefaultAppUpdateURL);
|
|
||||||
finishTestDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
|
||||||
|
<window title="Test notification with invalid certificate attribute name with no update"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
|
onload="runTestDefault();">
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
const TESTS = [ {
|
||||||
|
pageid: PAGEID_ERROR_CERT_CHECK,
|
||||||
|
extraDelayedCheckFunction: checkCertErrorPage,
|
||||||
|
shouldBeHidden: false,
|
||||||
|
buttonClick: "finish"
|
||||||
|
} ];
|
||||||
|
|
||||||
|
function runTest() {
|
||||||
|
debugDump("Entering runTest");
|
||||||
|
|
||||||
|
Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME,
|
||||||
|
"Invalid Attribute Name");
|
||||||
|
|
||||||
|
let url = "https://example.com/" + URL_PATH + "/update.sjs?noUpdates=1";
|
||||||
|
gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
||||||
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
||||||
|
debugDump("Default Update URL: " + url);
|
||||||
|
|
||||||
|
certErrorsPrefObserver.init();
|
||||||
|
|
||||||
|
gAUS.notify(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test"></pre>
|
||||||
|
</body>
|
||||||
|
</window>
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
|
||||||
|
<window title="Test notification with invalid certificate attribute name with no update"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
|
onload="runTestDefault();">
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
const TESTS = [ {
|
||||||
|
pageid: PAGEID_ERROR_CERT_CHECK,
|
||||||
|
extraDelayedCheckFunction: checkCertErrorPage,
|
||||||
|
shouldBeHidden: true,
|
||||||
|
buttonClick: "finish"
|
||||||
|
} ];
|
||||||
|
|
||||||
|
function runTest() {
|
||||||
|
debugDump("Entering runTest");
|
||||||
|
|
||||||
|
Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME,
|
||||||
|
"Invalid Attribute Name");
|
||||||
|
|
||||||
|
let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" +
|
||||||
|
getVersionParams();
|
||||||
|
gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
|
||||||
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
|
||||||
|
debugDump("Default Update URL: " + url);
|
||||||
|
|
||||||
|
certErrorsPrefObserver.init();
|
||||||
|
|
||||||
|
gAUS.notify(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test"></pre>
|
||||||
|
</body>
|
||||||
|
</window>
|
|
@ -127,6 +127,7 @@ const PAGEID_LICENSE = "license"; // Done
|
||||||
const PAGEID_INCOMPAT_LIST = "incompatibleList"; // Done
|
const PAGEID_INCOMPAT_LIST = "incompatibleList"; // Done
|
||||||
const PAGEID_DOWNLOADING = "downloading"; // Done
|
const PAGEID_DOWNLOADING = "downloading"; // Done
|
||||||
const PAGEID_ERRORS = "errors"; // Done
|
const PAGEID_ERRORS = "errors"; // Done
|
||||||
|
const PAGEID_ERROR_CERT_CHECK = "errorcertcheck"; // Done
|
||||||
const PAGEID_ERROR_PATCHING = "errorpatching"; // Done
|
const PAGEID_ERROR_PATCHING = "errorpatching"; // Done
|
||||||
const PAGEID_FINISHED = "finished"; // Done
|
const PAGEID_FINISHED = "finished"; // Done
|
||||||
const PAGEID_FINISHED_BKGRD = "finishedBackground"; // Done
|
const PAGEID_FINISHED_BKGRD = "finishedBackground"; // Done
|
||||||
|
@ -142,6 +143,9 @@ const URI_UPDATE_PROMPT_DIALOG = "chrome://mozapps/content/update/updates.xul";
|
||||||
|
|
||||||
const CRC_ERROR = 4;
|
const CRC_ERROR = 4;
|
||||||
|
|
||||||
|
const PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME = PREF_APP_UPDATE_CERTS_BRANCH +
|
||||||
|
"1.invalidName";
|
||||||
|
|
||||||
const ADDON_ID_SUFFIX = "@appupdatetest.mozilla.org";
|
const ADDON_ID_SUFFIX = "@appupdatetest.mozilla.org";
|
||||||
const ADDON_PREP_DIR = "appupdateprep";
|
const ADDON_PREP_DIR = "appupdateprep";
|
||||||
// Preference for storing add-ons that are disabled by the tests to prevent them
|
// Preference for storing add-ons that are disabled by the tests to prevent them
|
||||||
|
@ -161,10 +165,11 @@ var gTimeoutTimer;
|
||||||
|
|
||||||
// The following vars are for restoring previous preference values (if present)
|
// The following vars are for restoring previous preference values (if present)
|
||||||
// when the test finishes.
|
// when the test finishes.
|
||||||
var gAppUpdateChannel; // app.update.channel (default prefbranch)
|
var gAppUpdateChannel; // app.update.channel (default prefbranch)
|
||||||
var gAppUpdateEnabled; // app.update.enabled
|
var gAppUpdateEnabled; // app.update.enabled
|
||||||
var gAppUpdateURL; // app.update.url.override
|
var gAppUpdateURLDefault; // app.update.url (default prefbranch)
|
||||||
var gExtUpdateURL; // extensions.update.url
|
var gAppUpdateURL; // app.update.url.override
|
||||||
|
var gExtUpdateURL; // extensions.update.url
|
||||||
|
|
||||||
var gTestCounter = -1;
|
var gTestCounter = -1;
|
||||||
var gWin;
|
var gWin;
|
||||||
|
@ -454,6 +459,7 @@ function getExpectedButtonStates() {
|
||||||
case PAGEID_NO_UPDATES_FOUND:
|
case PAGEID_NO_UPDATES_FOUND:
|
||||||
case PAGEID_MANUAL_UPDATE:
|
case PAGEID_MANUAL_UPDATE:
|
||||||
case PAGEID_ERRORS:
|
case PAGEID_ERRORS:
|
||||||
|
case PAGEID_ERROR_CERT_CHECK:
|
||||||
case PAGEID_INSTALLED:
|
case PAGEID_INSTALLED:
|
||||||
return { finish: { disabled: false, hidden: false } };
|
return { finish: { disabled: false, hidden: false } };
|
||||||
case PAGEID_ERROR_PATCHING:
|
case PAGEID_ERROR_PATCHING:
|
||||||
|
@ -607,6 +613,29 @@ function checkPrefHasUserValue(aPrefHasValue) {
|
||||||
(prefHasUserValue ? "true" : "false"));
|
(prefHasUserValue ? "true" : "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the link is hidden (certificate attribute check error with an
|
||||||
|
* update) or not (certificate attribute check error without an update) on the
|
||||||
|
* errorcertcheck page and that the app.update.cert.errors preference does note
|
||||||
|
& have a user value.
|
||||||
|
*
|
||||||
|
* @param aShouldBeHidden (optional)
|
||||||
|
* The expected value for the label's hidden attribute for the link. If
|
||||||
|
* aShouldBeHidden is undefined the value of the current test's
|
||||||
|
* shouldBeHidden property will be used.
|
||||||
|
*/
|
||||||
|
function checkCertErrorPage(aShouldBeHidden) {
|
||||||
|
let shouldBeHidden = aShouldBeHidden === undefined ? gTest.shouldBeHidden
|
||||||
|
: aShouldBeHidden;
|
||||||
|
is(gWin.document.getElementById("errorCertAttrLinkLabel").hidden, shouldBeHidden,
|
||||||
|
"Checking errorCertAttrLinkLabel hidden attribute equals " +
|
||||||
|
(shouldBeHidden ? "true" : "false"));
|
||||||
|
|
||||||
|
ok(!Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_ERRORS),
|
||||||
|
"Preference " + PREF_APP_UPDATE_CERT_ERRORS + " should not have a " +
|
||||||
|
"user value");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the update version info for the update url parameters to send to
|
* Gets the update version info for the update url parameters to send to
|
||||||
* update.sjs.
|
* update.sjs.
|
||||||
|
@ -684,6 +713,9 @@ function setupPrefs() {
|
||||||
gAppUpdateChannel = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_CHANNEL);
|
gAppUpdateChannel = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_CHANNEL);
|
||||||
setUpdateChannel();
|
setUpdateChannel();
|
||||||
|
|
||||||
|
// Uncomment for debugging
|
||||||
|
// Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, true)
|
||||||
|
|
||||||
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) {
|
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) {
|
||||||
gAppUpdateURL = Services.prefs.setIntPref(PREF_APP_UPDATE_URL_OVERRIDE);
|
gAppUpdateURL = Services.prefs.setIntPref(PREF_APP_UPDATE_URL_OVERRIDE);
|
||||||
}
|
}
|
||||||
|
@ -715,6 +747,10 @@ function resetPrefs() {
|
||||||
Services.prefs.clearUserPref(PREF_APP_UPDATE_URL_OVERRIDE);
|
Services.prefs.clearUserPref(PREF_APP_UPDATE_URL_OVERRIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gAppUpdateURLDefault) {
|
||||||
|
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, gAppUpdateURLDefault);
|
||||||
|
}
|
||||||
|
|
||||||
if (gAppUpdateChannel !== undefined) {
|
if (gAppUpdateChannel !== undefined) {
|
||||||
setUpdateChannel(gAppUpdateChannel);
|
setUpdateChannel(gAppUpdateChannel);
|
||||||
}
|
}
|
||||||
|
@ -749,6 +785,31 @@ function resetPrefs() {
|
||||||
Services.prefs.clearUserPref(PREF_APP_UPDATE_LOG);
|
Services.prefs.clearUserPref(PREF_APP_UPDATE_LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_MAXERRORS)) {
|
||||||
|
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_MAXERRORS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME)) {
|
||||||
|
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_REQUIREBUILTIN)) {
|
||||||
|
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_REQUIREBUILTIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_CHECKATTRS)) {
|
||||||
|
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_CHECKATTRS);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CERT_ATTRS.forEach(function(aCertAttrName) {
|
||||||
|
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERTS_BRANCH + "1." +
|
||||||
|
aCertAttrName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Services.prefs.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
|
Services.prefs.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
|
||||||
}
|
}
|
||||||
|
@ -1042,6 +1103,44 @@ function getUpdateWindow() {
|
||||||
return Services.wm.getMostRecentWindow(UPDATE_WINDOW_NAME);
|
return Services.wm.getMostRecentWindow(UPDATE_WINDOW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for certificate attribute check errors.
|
||||||
|
*/
|
||||||
|
var certErrorsPrefObserver = {
|
||||||
|
/**
|
||||||
|
* Sets up the app.update.cert.errors preference observer and sets the
|
||||||
|
* app.update.cert.maxErrors preference.
|
||||||
|
*
|
||||||
|
* @param aMaxErrors
|
||||||
|
* The value to set the app.update.cert.maxErrors preference to.
|
||||||
|
*/
|
||||||
|
init: function(aMaxErrors) {
|
||||||
|
let maxErrors = aMaxErrors ? aMaxErrors : 5;
|
||||||
|
Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_MAXERRORS, maxErrors);
|
||||||
|
Services.prefs.addObserver(PREF_APP_UPDATE_CERT_ERRORS, this, false);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference observer for the app.update.cert.errors preference.
|
||||||
|
*/
|
||||||
|
observe: function XPI_observe(aSubject, aTopic, aData) {
|
||||||
|
if (aData == PREF_APP_UPDATE_CERT_ERRORS) {
|
||||||
|
let errCount = Services.prefs.getIntPref(PREF_APP_UPDATE_CERT_ERRORS);
|
||||||
|
let errMax = Services.prefs.getIntPref(PREF_APP_UPDATE_CERT_MAXERRORS);
|
||||||
|
if (errCount >= errMax) {
|
||||||
|
debugDump("prefObserver - removing pref observer");
|
||||||
|
Services.prefs.removeObserver(PREF_APP_UPDATE_CERT_ERRORS, this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
debugDump("prefObserver - notifying AUS");
|
||||||
|
SimpleTest.executeSoon(function() {
|
||||||
|
gAUS.notify(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nsIObserver for receiving window open and close notifications.
|
* nsIObserver for receiving window open and close notifications.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -44,23 +44,26 @@ const AUS_Ci = Components.interfaces;
|
||||||
const AUS_Cr = Components.results;
|
const AUS_Cr = Components.results;
|
||||||
const AUS_Cu = Components.utils;
|
const AUS_Cu = Components.utils;
|
||||||
|
|
||||||
const PREF_APP_UPDATE_CERTS_BRANCH = "app.update.certs.";
|
const PREF_APP_UPDATE_CERTS_BRANCH = "app.update.certs.";
|
||||||
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
|
const PREF_APP_UPDATE_CERT_CHECKATTRS = "app.update.cert.checkAttributes";
|
||||||
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors";
|
||||||
const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
|
const PREF_APP_UPDATE_CERT_MAXERRORS = "app.update.cert.maxErrors";
|
||||||
const PREF_APP_UPDATE_LOG = "app.update.log";
|
const PREF_APP_UPDATE_CERT_REQUIREBUILTIN = "app.update.cert.requireBuiltIn";
|
||||||
const PREF_APP_UPDATE_SHOW_INSTALLED_UI = "app.update.showInstalledUI";
|
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
|
||||||
const PREF_APP_UPDATE_URL = "app.update.url";
|
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
||||||
const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details";
|
const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
|
||||||
const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override";
|
const PREF_APP_UPDATE_LOG = "app.update.log";
|
||||||
|
const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never.";
|
||||||
|
const PREF_APP_UPDATE_SHOW_INSTALLED_UI = "app.update.showInstalledUI";
|
||||||
|
const PREF_APP_UPDATE_URL = "app.update.url";
|
||||||
|
const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details";
|
||||||
|
const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override";
|
||||||
|
|
||||||
const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never.";
|
const PREF_APP_PARTNER_BRANCH = "app.partner.";
|
||||||
|
const PREF_DISTRIBUTION_ID = "distribution.id";
|
||||||
|
const PREF_DISTRIBUTION_VERSION = "distribution.version";
|
||||||
|
|
||||||
const PREF_APP_PARTNER_BRANCH = "app.partner.";
|
const PREF_EXTENSIONS_UPDATE_URL = "extensions.update.url";
|
||||||
const PREF_DISTRIBUTION_ID = "distribution.id";
|
|
||||||
const PREF_DISTRIBUTION_VERSION = "distribution.version";
|
|
||||||
|
|
||||||
const PREF_EXTENSIONS_UPDATE_URL = "extensions.update.url";
|
|
||||||
|
|
||||||
const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
|
const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
|
||||||
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
|
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
|
||||||
|
|
Загрузка…
Ссылка в новой задаче