mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
bug 354517, add help testing extension, r=davel
This commit is contained in:
parent
cc0dd1b2f4
commit
2ee471dc8d
57
testing/tests/l10n/extensions/help/Makefile.in
Executable file
57
testing/tests/l10n/extensions/help/Makefile.in
Executable file
@ -0,0 +1,57 @@
|
||||
# ***** 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 l10n testing.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.com>
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = help-helper
|
||||
XPI_NAME = help-helper
|
||||
#INSTALL_EXTENSION_ID = helper@l10n.mozilla.com
|
||||
XPI_PKGNAME = help-helper-$(EXTENSION_VERSION)
|
||||
EXTENSION_VERSION = 0.7
|
||||
|
||||
USE_EXTENSION_MANIFEST = 1
|
||||
DIST_FILES = install.rdf
|
||||
PREF_JS_EXPORTS = $(srcdir)/help-helper-prefs.js
|
||||
|
||||
DEFINES += -DEXTENSION_VERSION=$(EXTENSION_VERSION)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
193
testing/tests/l10n/extensions/help/chrome/content/help-helper.js
Executable file
193
testing/tests/l10n/extensions/help/chrome/content/help-helper.js
Executable file
@ -0,0 +1,193 @@
|
||||
/* ***** 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 l10n testing.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2066
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <l10n@mozilla.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
// Controller section
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
var Cc = Components.classes;
|
||||
var Cr = Components.results;
|
||||
|
||||
var RDF = Cc['@mozilla.org/rdf/rdf-service;1'].getService(Ci.nsIRDFService);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var AI = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULAppInfo);
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
|
||||
prefs = prefs.getBranch("l10n.tests.help.");
|
||||
var prefName = AI.name + '.' + AI.version.substr(0,3); // only take the major version
|
||||
var gData = eval('(' + prefs.getCharPref(prefName) + ')');
|
||||
|
||||
// Table of Contents is the first datasource
|
||||
var toc = ios.newURI(gData.datasources[0].url, null, null);
|
||||
|
||||
function getDS(data) {
|
||||
try {
|
||||
var ds = RDF.GetDataSourceBlocking(data.url);
|
||||
} catch (e) {
|
||||
Components.utils.reportError('failed to load RDF for ' + data.url);
|
||||
}
|
||||
ds.QueryInterface(Ci.rdfIDataSource);
|
||||
return ds;
|
||||
}
|
||||
gData.rdfds = gData.datasources.map(getDS);
|
||||
|
||||
var nc = "http://home.netscape.com/NC-rdf#";
|
||||
var lnk = RDF.GetResource(nc + 'link');
|
||||
|
||||
var toCheck = {};
|
||||
var checkList = [];
|
||||
var isGood;
|
||||
var current = null;
|
||||
var frm, gb = document.documentElement;
|
||||
|
||||
function triplehandler(aBaseURI) {
|
||||
return function(aSubj, aPred, aObj, aTruth) {
|
||||
if (aPred.EqualsNode(lnk)) {
|
||||
aObj.QueryInterface(Ci.nsIRDFLiteral);
|
||||
var target = ios.newURI(aObj.Value, null, aBaseURI);
|
||||
target.QueryInterface(Ci.nsIURL);
|
||||
var ref = target.ref;
|
||||
var base = target.prePath + target.filePath;
|
||||
if (! (base in toCheck)) {
|
||||
toCheck[base] = {};
|
||||
}
|
||||
toCheck[base][ref] = [aSubj, target];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onLoad(event) {
|
||||
//Components.utils.reportError(event.target + ' loaded');
|
||||
if (event.target != document) {
|
||||
return;
|
||||
}
|
||||
document.documentElement.removeAttribute('onload');
|
||||
frm = document.getElementById('frm');
|
||||
frm.addEventListener('load', frmLoad, true);
|
||||
gData.current = -1;
|
||||
runDS();
|
||||
}
|
||||
|
||||
function runDS() {
|
||||
gData.current++;
|
||||
if (gData.datasources.length == gData.current) {
|
||||
postChecks();
|
||||
return;
|
||||
}
|
||||
toCheck = {};
|
||||
checkList = [];
|
||||
isGood = true;
|
||||
var data = gData.datasources[gData.current];
|
||||
Components.utils.reportError('testing ' + data.title);
|
||||
createBox(data.title);
|
||||
var uri = ios.newURI(data.url, null, null);
|
||||
gData.rdfds[gData.current].visitAllTriples(triplehandler(uri));
|
||||
for (key in toCheck) {
|
||||
checkList.push([key, toCheck[key]]);
|
||||
}
|
||||
current = checkList.pop();
|
||||
frm.setAttribute('src', current[0]);
|
||||
}
|
||||
|
||||
function frmLoad(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
//Components.utils.reportError('loaded ' + current[0]);
|
||||
checkIDs(current[1], current[0]);
|
||||
if (checkList.length == 0) {
|
||||
if (isGood) {
|
||||
logMessage('PASS');
|
||||
}
|
||||
runDS();
|
||||
return;
|
||||
}
|
||||
current = checkList.pop();
|
||||
frm.setAttribute('src', current[0]);
|
||||
}
|
||||
|
||||
function checkIDs(refs, url) {
|
||||
if (!frm.contentDocument) {
|
||||
Components.utils.reportError(url + ' not found\n')
|
||||
return;
|
||||
}
|
||||
for (var ref in refs) {
|
||||
if (ref && !frm.contentDocument.getElementById(ref)) {
|
||||
isGood = false;
|
||||
var msg = 'ID "' + ref + '" in ' + url + ' not found';
|
||||
Components.utils.reportError(msg);
|
||||
var d = document.createElement('description');
|
||||
d.setAttribute('value', msg);
|
||||
gb.appendChild(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function postChecks() {
|
||||
if (gData.entrypoints) {
|
||||
createBox('Entry points');
|
||||
Components.utils.reportError('testing entry points');
|
||||
var good = 0; bad = 0;
|
||||
for each (idref in gData.entrypoints) {
|
||||
var r=RDF.GetResource(toc.spec + '#' + idref);
|
||||
if (gData.rdfds[0].GetTarget(r,lnk,true)) {
|
||||
good++;
|
||||
}
|
||||
else {
|
||||
bad++;
|
||||
logMessage('Entrypoint "' + idref + '" not resolved.');
|
||||
}
|
||||
}
|
||||
if (bad == 0) {
|
||||
logMessage('PASS');
|
||||
}
|
||||
}
|
||||
Components.utils.reportError('TESTING:DONE');
|
||||
}
|
||||
|
||||
// View section
|
||||
|
||||
function createBox(aTitle) {
|
||||
gb = document.createElement('groupbox');
|
||||
gb.appendChild(document.createElement('caption'));
|
||||
gb.firstChild.setAttribute('label', aTitle);
|
||||
document.documentElement.appendChild(gb);
|
||||
}
|
||||
|
||||
function logMessage(aMsg) {
|
||||
Components.utils.reportError(aMsg);
|
||||
var d = document.createElement('description');
|
||||
d.setAttribute('value', aMsg);
|
||||
gb.appendChild(d);
|
||||
}
|
46
testing/tests/l10n/extensions/help/chrome/content/help-helper.xul
Executable file
46
testing/tests/l10n/extensions/help/chrome/content/help-helper.xul
Executable file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.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 l10n testing.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Mozilla Foundation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <l10n@mozilla.com>
|
||||
-
|
||||
- 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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<window id="help-helper"
|
||||
title="Help Link Checker"
|
||||
onload="return onLoad(event)"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="help-helper.js"/>
|
||||
<iframe id="frm" style="height:0px;"/>
|
||||
</window>
|
1
testing/tests/l10n/extensions/help/help-helper-prefs.js
Executable file
1
testing/tests/l10n/extensions/help/help-helper-prefs.js
Executable file
@ -0,0 +1 @@
|
||||
pref("l10n.tests.help.Firefox.2.0", '{entrypoints:["firefox-help", "ieusers", "prefs-advanced-encryption", "prefs-advanced-general", "prefs-advanced-javascript", "prefs-advanced-network", "prefs-advanced-update", "prefs-clear-private-data", "prefs-connection-settings", "prefs-content", "prefs-feeds", "prefs-file-types", "prefs-fonts-and-colors", "prefs-languages", "prefs-main", "prefs-privacy", "prefs-security", "prefs-tabs"], datasources:[{url:"chrome://browser/locale/help/firebird-toc.rdf", title:"Table Of Contents"}, {url:"chrome://browser/locale/help/search-db.rdf", title:"Search"}]}');
|
27
testing/tests/l10n/extensions/help/install.rdf
Executable file
27
testing/tests/l10n/extensions/help/install.rdf
Executable file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>helper@l10n.mozilla.com</em:id>
|
||||
#expand <em:version>__EXTENSION_VERSION__</em:version>
|
||||
<em:type>2</em:type>
|
||||
|
||||
<!-- Target Application this extension can install into,
|
||||
with minimum and maximum supported versions. -->
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>2.0b2</em:minVersion>
|
||||
<em:maxVersion>2.0.*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Help Helper</em:name>
|
||||
<em:description>Finds all links in the help TOC and tries to resolve them.</em:description>
|
||||
<em:creator>Axel Hecht <l10n@mozilla.com></em:creator>
|
||||
<em:homepageURL>http://people.mozilla.com/~axel/l10n/</em:homepageURL>
|
||||
</Description>
|
||||
</RDF>
|
4
testing/tests/l10n/extensions/help/jar.mn
Executable file
4
testing/tests/l10n/extensions/help/jar.mn
Executable file
@ -0,0 +1,4 @@
|
||||
help-helper.jar:
|
||||
% content help-helper %content
|
||||
content/help-helper.xul (chrome/content/help-helper.xul)
|
||||
content/help-helper.js (chrome/content/help-helper.js)
|
@ -72,6 +72,9 @@ var bookmarksView = {
|
||||
};
|
||||
var bookmarksController = {
|
||||
__proto__: baseController,
|
||||
get path() {
|
||||
return 'results/' + this.tag + '/bookmarks-results.json';
|
||||
},
|
||||
beforeSelect: function() {
|
||||
this.result = {};
|
||||
this.isShown = false;
|
||||
|
@ -66,7 +66,32 @@ function JSON_c() {
|
||||
};
|
||||
};
|
||||
JSON_c.prototype = {
|
||||
cache : {
|
||||
MAX_SIZE: 6,
|
||||
_objs: {},
|
||||
_lru: [],
|
||||
get: function(aURL) {
|
||||
if (!(aURL in this._objs)) {
|
||||
return null;
|
||||
}
|
||||
var i = this._lru.indexOf(aURL);
|
||||
for (var j = i; j>0; j--) {
|
||||
this._lru[j] = this._lru[j-1];
|
||||
}
|
||||
this._lru[0] = aURL;
|
||||
return this._objs[aURL];
|
||||
},
|
||||
put: function(aURL, aObject) {
|
||||
this._lru.unshift(aURL);
|
||||
this._objs[aURL] = aObject;
|
||||
}
|
||||
},
|
||||
get : function(aURL, aCallback) {
|
||||
var obj = this.cache.get(aURL);
|
||||
if (obj) {
|
||||
controller.delay(controller, aCallback, [obj]);
|
||||
return;
|
||||
}
|
||||
var _t = this;
|
||||
var req = this._getRequest();
|
||||
req.overrideMimeType("text/plain"); // don't parse XML, this is js
|
||||
@ -78,6 +103,7 @@ JSON_c.prototype = {
|
||||
_t.handleSuccess(event.target);
|
||||
event.stopPropagation();
|
||||
};
|
||||
req._mURL = aURL;
|
||||
if (aCallback) {
|
||||
req.callback = aCallback;
|
||||
}
|
||||
@ -86,7 +112,7 @@ JSON_c.prototype = {
|
||||
req.send(null);
|
||||
} catch (e) {
|
||||
// work around send sending errors, but not the callback
|
||||
controller.handleFailure(req);
|
||||
this.handleFailure(req);
|
||||
}
|
||||
return req;
|
||||
},
|
||||
@ -96,6 +122,7 @@ JSON_c.prototype = {
|
||||
throw "expected response text in handleSuccess";
|
||||
if (o.callback) {
|
||||
var obj = eval('('+o.responseText+')');
|
||||
this.cache.put(o._mURL, obj);
|
||||
o.callback(obj);
|
||||
delete o.callback;
|
||||
}
|
||||
@ -234,6 +261,9 @@ baseController = {
|
||||
baseController._tag = aTag;
|
||||
view.setTag(aTag);
|
||||
},
|
||||
get path() {
|
||||
throw 'not implemented';
|
||||
},
|
||||
addLocales: function(lst) {
|
||||
var nl = lst.filter(function(el,i,a) {return this._l.indexOf(el) < 0;}, this);
|
||||
this._l = this._l.concat(nl);
|
||||
@ -253,6 +283,10 @@ baseController = {
|
||||
controller._target = aKey;
|
||||
view.selectTab(aKey);
|
||||
this.delay(controller, controller.showView, []);
|
||||
//controller.ensureData(aKey, nCV.controller.showView, nCV.controller);
|
||||
},
|
||||
ensureData: function(aKey, aCallback, aController) {
|
||||
var p = a;
|
||||
},
|
||||
showView: function(aClosure) {
|
||||
view.updateView(controller.locales, aClosure);
|
||||
@ -264,7 +298,7 @@ baseController = {
|
||||
var dlg = new YAHOO.widget.SimpleDialog("log-dlg", dlgProps);
|
||||
var prefix = '';
|
||||
if (aLocale) {
|
||||
prefix = '[' + aLocale * '] ';
|
||||
prefix = '[' + aLocale + '] ';
|
||||
}
|
||||
dlg.setHeader(prefix + 'build log, ' + aTag);
|
||||
dlg.setBody('Loading …');
|
||||
@ -279,6 +313,7 @@ baseController = {
|
||||
dlg.cfg.queueProperty("buttons", [okButton]);
|
||||
dlg.render(document.body);
|
||||
dlg.moveTo(10, 10);
|
||||
document.body.scrollTop = 0;
|
||||
var callback = function(obj) {
|
||||
_t.handleLog.apply(_t, [obj, dlg, aLocale]);
|
||||
};
|
||||
@ -286,15 +321,47 @@ baseController = {
|
||||
},
|
||||
handleLog: function(aLog, aDlg, aLocale) {
|
||||
var df = document.createDocumentFragment();
|
||||
var filter = function(lr) {
|
||||
return true;
|
||||
}
|
||||
if (aLocale) {
|
||||
filter = function(lr) {
|
||||
var logName = lr[0];
|
||||
var level = lr[1];
|
||||
var msg = lr[2];
|
||||
var loc = '/' + aLocale + '/';
|
||||
if (logName == 'cvsco') {
|
||||
return msg.indexOf('mozilla/') >= 0 ||
|
||||
msg.indexOf(loc) >= 0 ||
|
||||
msg.indexOf('make[') >= 0 ||
|
||||
msg.indexOf('checkout') >= 0;
|
||||
}
|
||||
if (logName == 'locales') {
|
||||
return msg.indexOf(loc) >= 0;
|
||||
}
|
||||
return logName == ('locales.' + aLocale);
|
||||
}
|
||||
}
|
||||
for each (var r in aLog) {
|
||||
if (!filter(r)) {
|
||||
continue;
|
||||
}
|
||||
var d = document.createElement('pre');
|
||||
d.className = 'log-row ' + r[1];
|
||||
// XXX filter on r[0:1]
|
||||
d.textContent = r[2].replace(/[\n\r]$/, '');
|
||||
d.textContent = r[2];
|
||||
df.appendChild(d);
|
||||
}
|
||||
aDlg.setBody(df);
|
||||
},
|
||||
showDetails: function(aTag, aLoc) {
|
||||
var cells = [];
|
||||
for (var key in baseController._c) {
|
||||
if (key != 'waterfall') {
|
||||
cells.push(baseController._c[key].controller.getContent(aLoc));
|
||||
}
|
||||
}
|
||||
},
|
||||
getContent: function(aLoc) {
|
||||
if (! this._target) return;
|
||||
return this._c[this._target].getContent(aLoc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user