aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-pageMod.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-04-28 13:28:55 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-04-28 18:26:14 +0200
commit32af48e442a960b8c3f199f5ffad28a34590fcda (patch)
treec291cb97627bd2cfb65167347261d5ef8f521bfd /tests/test-pageMod.js
parent2382ba19afc84e9b747a7981ebf72aaa704f08b6 (diff)
downloadbugzilla-triage-32af48e442a960b8c3f199f5ffad28a34590fcda.tar.gz
Reformatting to MoFo coding style
Diffstat (limited to 'tests/test-pageMod.js')
-rw-r--r--tests/test-pageMod.js195
1 files changed, 95 insertions, 100 deletions
diff --git a/tests/test-pageMod.js b/tests/test-pageMod.js
index 5434bbd..31cb3dd 100644
--- a/tests/test-pageMod.js
+++ b/tests/test-pageMod.js
@@ -13,126 +13,121 @@ var testURL = self.data.url('tests/change-more-bugs01.html');
var JSONifiedMessage = '{"cmd":"testMessage","data":{"a":"first","b":"second"}}';
exports.ensureMessagesWork = function(test) {
- var msg = new utilMod.Message("testMessage", { a: "first", b: "second" } );
+ var msg = new utilMod.Message("testMessage", {
+ a : "first",
+ b : "second"
+ });
test.assertEqual(msg.cmd, "testMessage",
- "msg.cmd comes over well");
+ "msg.cmd comes over well");
test.assertEqual(msg.data.a, "first",
- "msg.data.a comes over well");
+ "msg.data.a comes over well");
test.assertEqual(msg.data.b, "second",
- "msg.data.b comes over well");
+ "msg.data.b comes over well");
test.assertEqual(JSON.stringify(msg), JSONifiedMessage,
- "JSONification of Message works as well");
+ "JSONification of Message works as well");
};
/*
+ *
+ * var theURL = main.theURL; var testURL =
+ * self.data.url('tests/change-more-bugs01.html');
+ *
+ * var contentScriptLibraries = { "bugzilla.redhat.com": [
+ * self.data.url("util.js"), self.data.url("color.js"),
+ * self.data.url("rhbzpage.js"), self.data.url("bzpage.js") ] };
+ *
+ * libbz.initialize(libbz.config, function () { pageMod.PageMod({ include: [
+ * "https://bugzilla.redhat.com/show_bug.cgi?id=*" ], contentScriptWhen:
+ * 'ready', contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
+ * onAttach: function onAttach(worker, msg) { console.log("worker: " + worker);
+ * worker.on('message', function (msg) { messageHandler(worker, msg); }); } });
+ * });
+ *
+ * pageMod.PageMod({ include: [ "https://bugzilla.redhat.com/process_bug.cgi" ],
+ * contentScriptWhen: 'ready', contentScriptFile: self.data.url("skip-bug.js")
+ * });
+ */
-var theURL = main.theURL;
-var testURL = self.data.url('tests/change-more-bugs01.html');
-
-var contentScriptLibraries = {
- "bugzilla.redhat.com": [
- self.data.url("util.js"),
- self.data.url("color.js"),
- self.data.url("rhbzpage.js"),
- self.data.url("bzpage.js")
- ]
-};
-
-libbz.initialize(libbz.config, function () {
- pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/show_bug.cgi?id=*"
- ],
- contentScriptWhen: 'ready',
- contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
- onAttach: function onAttach(worker, msg) {
- console.log("worker: " + worker);
- worker.on('message', function (msg) {
- messageHandler(worker, msg);
- });
+var ensureSimplePageLoad = function(test) {
+ console.log("testURL = " + testURL);
+ testPageMod(test, testURL, [
+ {
+ include : [
+ "*"
+ ],
+ contentScriptWhen : 'ready',
+ contentScriptFile : [
+ self.data.url("libPW.js"),
+ self.data.url("simplePageWorker.js")
+ ],
+ onAttach : function onAttach(worker) {
+ worker.on('message', function(msg) {
+ switch (msg.cmd) {
+ case "LogMessage":
+ log(msg.data);
+ break;
+ case "CallBack":
+ worker
+ .postMessage(new utilMod.Message("Main", null));
+ break;
+ default:
+ console.error(msg);
+ }
+ });
+ }
}
+ ], function(win, done) {
+ test.assertNotEqual(win.document
+ .getElementsByTagName("form")[0], null,
+ "test of loading the page");
+ done();
});
-});
-
-pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/process_bug.cgi"
- ],
- contentScriptWhen: 'ready',
- contentScriptFile: self.data.url("skip-bug.js")
-});
- */
-
-var ensureSimplePageLoad = function (test) {
- console.log("testURL = " + testURL);
- testPageMod(test, testURL, [{
- include: ["*"],
- contentScriptWhen: 'ready',
- contentScriptFile: [
- self.data.url("libPW.js"),
- self.data.url("simplePageWorker.js")
- ],
- onAttach: function onAttach(worker) {
- worker.on('message', function (msg) {
- switch (msg.cmd) {
- case "LogMessage":
- log(msg.data);
- break;
- case "CallBack":
- worker.postMessage(new utilMod.Message("Main", null));
- break;
- default:
- console.error(msg);
- }
- });
- }
- }],
- function (win, done) {
- test.assertNotEqual(win.document.getElementsByTagName("form")[0],
- null, "test of loading the page");
- done();
- });
};
-var ensurePageLoadsWell = function (test) {
+var ensurePageLoadsWell = function(test) {
var wm = Cc['@mozilla.org/appshell/window-mediator;1']
- .getService(Ci.nsIWindowMediator);
- var browserWindow = wm.getMostRecentWindow("navigator:browser");
+ .getService(Ci.nsIWindowMediator);
+ var browserWindow = wm
+ .getMostRecentWindow("navigator:browser");
if (!browserWindow) {
- test.fail("page-mod tests: could not find the browser window, so " +
- "will not run. Use -a firefox to run the pagemod tests.");
- return null;
+ test
+ .fail("page-mod tests: could not find the browser window, so "
+ + "will not run. Use -a firefox to run the pagemod tests.");
+ return null;
}
var loader = test.makeSandboxedLoader();
var pageMod = loader.require("page-mod");
- var testDoc = {}, b = {}, tabBrowser = {}, newTab = {};
+ var testDoc = {}, b = {}, tabBrowser = {}, newTab = {};
pageMod.PageMod({
- include: ["*"],
- contentScriptWhen: 'ready',
- contentScriptFile: [
- self.data.url("libPW.js"),
- self.data.url("pageWorker.js")
- ],
- onAttach: function onAttach(worker) {
- worker.on('message', function (msg) {
- switch (msg.cmd) {
- case "testReady":
- testDoc = b.contentWindow.wrappedJSObject.document;
- test.assertNotEqual(testDoc.getElementById("dupeid_action"),
- null, "test of DOM modifications of the page");
- pageMod.destroy();
- tabBrowser.removeTab(newTab);
- test.done();
- // the test itself
- break;
- default:
- main.messageHandler(worker, msg);
- }
- });
- }
- });
+ include : [
+ "*"
+ ],
+ contentScriptWhen : 'ready',
+ contentScriptFile : [
+ self.data.url("libPW.js"),
+ self.data.url("pageWorker.js")
+ ],
+ onAttach : function onAttach(worker) {
+ worker.on('message', function(msg) {
+ switch (msg.cmd) {
+ case "testReady":
+ testDoc = b.contentWindow.wrappedJSObject.document;
+ test.assertNotEqual(testDoc
+ .getElementById("dupeid_action"), null,
+ "test of DOM modifications of the page");
+ pageMod.destroy();
+ tabBrowser.removeTab(newTab);
+ test.done();
+ // the test itself
+ break;
+ default:
+ main.messageHandler(worker, msg);
+ }
+ });
+ }
+ });
tabBrowser = browserWindow.gBrowser;
newTab = tabBrowser.addTab(testURL);