bug 358740, add initial landing of coverage extension for l10n testing, r=rcampbell

git-svn-id: svn://10.0.0.236/trunk@215093 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
axel%pike.org
2006-11-10 15:53:44 +00:00
parent f31a42d169
commit bd9c0fd33a
10 changed files with 676 additions and 0 deletions

View 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 = coverage
XPI_NAME = coverage
#INSTALL_EXTENSION_ID = coverage@l10n.mozilla.com
XPI_PKGNAME = coverage-$(EXTENSION_VERSION)
EXTENSION_VERSION = 0.5
USE_EXTENSION_MANIFEST = 1
DIST_FILES = install.rdf
PREF_JS_EXPORTS = $(srcdir)/coverage-extension-prefs.js
DEFINES += -DEXTENSION_VERSION=$(EXTENSION_VERSION)
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,104 @@
/* ***** 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 ***** */
/**
* Item to close a menu popup
*
* Used by OpenMenuObj.
*/
function CloseMenuObj(aPopup) {
this.args = [aPopup];
}
CloseMenuObj.prototype = {
args: null,
method: function _openMenu(aPopup) {
aPopup.hidePopup();
}
};
/**
* Item to open a menu popup
*
* Adds a CloseMenuObj item as well as potentially child popups to
* Stack
*/
function OpenMenuObj(aPopup) {
this.args = [aPopup];
}
OpenMenuObj.prototype = {
args: null,
method: function _openMenu(aPopup) {
aPopup.showPopup();
Stack.push(new CloseMenuObj(aPopup));
for (var i = aPopup.childNodes.length - 1; i>=0; --i) {
var c = aPopup.childNodes[i];
if (c.nodeName != 'menu' || c.childNodes.length == 0) {
continue;
}
for each (var childpop in c.childNodes) {
if (childpop.localName == "menupopup") {
Stack.push(new OpenMenuObj(childpop));
}
}
}
}
};
/**
* Item to kick off menu coverage testing
*
* Pretty similar to OpenMenuObj, just that it works on the main-menubar
* instead of a given popup.
*/
function RootMenu(aWindow) {
this._w = aWindow;
};
RootMenu.prototype = {
args: [],
method: function() {
var mb = this._w.document.getElementById('main-menubar');
for (var i = mb.childNodes.length - 1; i>=0; --i) {
var m = mb.childNodes[i];
Stack.push(new OpenMenuObj(m.firstChild));
}
},
_w: null
};
toRun.push(new TestDone('MENUS'));
toRun.push(new RootMenu(wins[0]));
toRun.push(new TestStart('MENUS'));

View File

@@ -0,0 +1,113 @@
/* ***** 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 ***** */
var SBS = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
var bundle = SBS.createBundle("chrome://global/locale/appstrings.properties");
/**
* Item to wait on asynchronous loads
*/
var loadAction = {
isLoaded: false,
args: [],
method: function() {
if (!this.isLoaded) {
Stack.push(this);
}
}
};
// onLoad handler for the iframe, sibling of loadAction
function onFrameLoad(aEvent) {
aEvent.stopPropagation();
loadAction.isLoaded = true;
return false;
};
/**
* Item to load the next error page
*
* Uses the loadAction object to wait for asynchronous loading.
*/
function ErrPageLoad(aFrame, aProperty) {
this.args = [aFrame, aProperty.key, aProperty.value];
};
ErrPageLoad.prototype = {
args: null,
method: function(aFrame, aErr, aDesc) {
loadAction.isLoaded = false;
var q = 'e=' + encodeURIComponent(aErr);
q += '&u=' + encodeURIComponent('http://foo.bar');
// Simple replacement, replace anything that's %s with aURL,
// see http://lxr.mozilla.org/mozilla1.8/source/docshell/base/nsDocShell.cpp#2907
// on how to do this right. But that requires knowledge on each and
// every error, too much work for now.
aDesc = aDesc.replace('%S', 'http://foo.bar');
q += '&d=' + encodeURIComponent(aDesc);
Stack.push(loadAction);
aFrame.setAttribute('src', 'about:neterror?' + q);
}
};
/**
* Item to start the neterror tests
*
* This item collects all the neterror pages we intend to test
* and adds them to the Stack.
*/
function RootNeterror() {
this.args = [];
};
RootNeterror.prototype = {
args: null,
method: function(aIFrame) {
var frame = document.getElementById('neterror-pane');
var nErrors =
[err for (err in SimpleGenerator(bundle.getSimpleEnumeration(),
Ci.nsIPropertyElement))];
nErrors.sort(function(aPl, aPr) {
return aPl.key > aPr.key ? 1 :
aPl.key < aPr.key ? -1 : 0;
});
for each (err in nErrors) {
Stack.push(new ErrPageLoad(frame, err));
}
}
};
toRun.push(new TestDone('NETERROR'));
toRun.push(new RootNeterror());
toRun.push(new TestStart('NETERROR'));

View File

@@ -0,0 +1,138 @@
/* ***** 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 ***** */
/**
* Item to show the next pane in a prefs window
*/
function ShowPaneObj(aPane, aLoader) {
this.args = [aPane, aLoader];
}
ShowPaneObj.prototype = {
args: null,
method: function _openMenu(aPane, aLoader) {
Stack.push(aLoader);
aPane.parentNode.showPane(aPane);
}
};
/**
* Item to close the preferences window once the tests are done
*/
function ClosePreferences() {
this.args = [];
};
ClosePreferences.prototype = {
args: [],
method: function() {
var pWin = WM.getMostRecentWindow("Browser:Preferences");
if (pWin) {
pWin.close();
}
else {
Components.utils.reportError("prefwindow not found, trying again");
}
}
};
/**
* Item to wait for a preference pane to load
*/
function PrefPaneLoader() {
};
PrefPaneLoader.prototype = {
_currentPane: null,
args: [],
method: function() {
if (!this._currentPane) {
// The pane we're waiting for hasn't been loaded yet, do me again
Stack.push(this);
return;
}
// the pane is loaded, kick off the load of the next one, if available
pane = this._currentPane.nextSibling;
this._currentPane = null;
while (pane) {
if (pane.nodeName == 'prefpane') {
Stack.push(new ShowPaneObj(pane, this));
return;
}
pane = pane.nextSibling;
}
},
// nsIDOMEventListener
handleEvent: function _hv(aEvent) {
this._currentPane = aEvent.target;
}
};
/**
* Item to start the preference dialog tests
*
* This item expects to have 'paneMain' as the ID of the first pane.
* That may be an over-simplification, but it guarantees to load
* the panes from left to right, and that all are not loaded yet.
* WFM.
*/
function RootPreference(aWindow) {
this.args = [aWindow];
};
RootPreference.prototype = {
args: [],
method: function(aWindow) {
WM.addListener(this);
aWindow.openPreferences('paneMain');
},
// nsIWindowMediatorListener
onWindowTitleChange: function(aWindow, newTitle){},
onOpenWindow: function(aWindow) {
WM.removeListener(this);
// ensure the timer runs in the modal window, too
Stack._timer.initWithCallback({notify:function (aTimer) {Stack.pop();}},
Stack._time, 1);
Stack.push(new ClosePreferences());
var ppl = new PrefPaneLoader();
aWindow.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
var DOMwin = aWindow.docShell.getInterface(Ci.nsIDOMWindow);
DOMwin.addEventListener('paneload', ppl, false);
Stack.push(ppl);
},
onCloseWindow: function(aWindow){}
};
toRun.push(new TestDone('PREFERENCES'));
toRun.push(new RootPreference(wins[0]));
toRun.push(new TestStart('PREFERENCES'));

View File

@@ -0,0 +1,130 @@
/* ***** 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 ***** */
/**
* Basic architecture for UI exposure tests
*
* Details on http://wiki.mozilla.org/SoftwareTesting:Tools:L10n:Coverage
*/
var Ci = Components.interfaces;
var Cc = Components.classes;
var Cr = Components.results;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var ds = Cc[NS_DIRECTORY_SERVICE_CONTRACTID].getService(Ci.nsIProperties);
const WM = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
/**
* Global Stack object
*
* This object keeps the tests running with some time for visual inspection.
*/
var Stack = {
_stack: [],
_time: 250,
_timer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
notify: function _notify(aTimer) {
this.pop();
},
push: function _push(aItem) {
this._stack.push(aItem);
if (this._stack.length == 1) {
this._timer.initWithCallback({notify:function (aTimer) {Stack.pop();}},
this._time, 1);
}
},
pop: function _pop() {
var obj = this._stack.pop();
try {
obj.method.apply(obj, obj.args);
} catch (e) {
Components.utils.reportError(e);
}
if (!this._stack.length) {
this._timer.cancel();
}
}
};
/**
* Add your test set to toRun.
* The onload handler will add them to the Stack and kick off the
* testing.
*/
var toRun = [];
/**
* Utility to get array of xpcom objects from a nsISimpleEnumerator
* Requires JS1.7
*/
function SimpleGenerator(enumr, interface) {
while (enumr.hasMoreElements()) {
yield enumr.getNext().QueryInterface(interface);
}
}
var wins = [w for (w in SimpleGenerator(WM.getEnumerator(null), Ci.nsIDOMWindow))];
/**
* Helper items to log start and end of testing to the Error Console
*/
function MsgBase() {
}
MsgBase.prototype = {
args: [],
method: function() {
Components.utils.reportError(this._msg);
}
};
function TestStart(aCat) {
this._msg = 'TESTING:START:COVERAGE:' + aCat;
}
TestStart.prototype = new MsgBase;
function TestDone(aCat) {
this._msg = 'TESTING:DONE:COVERAGE:' + aCat;
}
TestDone.prototype = new MsgBase;
/**
* onload handler for the entry page.
* Copy the toRun items over to the stack and kick things off.
*/
function onLoad() {
for each (var obj in toRun) {
Stack.push(obj);
}
}

View File

@@ -0,0 +1,48 @@
<?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="coverage"
title="Coverage Tool"
onload="return onLoad(event)"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript;version=1.7" src="coverage.js"/>
<script type="application/javascript;version=1.7" src="coverage-prefs.js"/>
<script type="application/javascript;version=1.7" src="coverage-menu.js"/>
<label value="test"/>
</window>

View File

@@ -0,0 +1,48 @@
<?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="neterror-coverage"
title="NetError Coverage Tool"
onload="return onLoad(event)"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript;version=1.7" src="coverage.js"/>
<script type="application/javascript;version=1.7" src="coverage-neterror.js"/>
<label value="Neterror page tests"/>
<iframe flex="1" onload="return onFrameLoad(event);" id="neterror-pane"/>
</window>

View File

@@ -0,0 +1,3 @@
pref('javascript.options.showInConsole', true);
pref('testing.extensions.l10n.coverage', 'chrome://coverage/content/');
pref('testing.extensions.l10n.neterror-coverage', 'chrome://coverage/content/neterror-coverage.xul');

View 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>coverage@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.0</em:minVersion>
<em:maxVersion>2.0.*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Coverage tester</em:name>
<em:description>Triggers lots of UI to see if errors pop up.</em:description>
<em:creator>Axel Hecht &lt;l10n@mozilla.com&gt;</em:creator>
<em:homepageURL>http://wiki.mozilla.org/SoftwareTesting:Tools:L10n:Coverage</em:homepageURL>
</Description>
</RDF>

View File

@@ -0,0 +1,8 @@
coverage.jar:
% content coverage %content/
content/coverage.xul (chrome/content/coverage.xul)
content/coverage.js (chrome/content/coverage.js)
content/coverage-menu.js (chrome/content/coverage-menu.js)
content/coverage-prefs.js (chrome/content/coverage-prefs.js)
content/neterror-coverage.xul (chrome/content/neterror-coverage.xul)
content/coverage-neterror.js (chrome/content/coverage-neterror.js)