зеркало из https://github.com/mozilla/pjs.git
Bug 678726 Improved diagnostics to try to figure out what this random orange is r=ted
This commit is contained in:
Родитель
63a94da72f
Коммит
8154b4f46f
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Import common SimpleTest methods so that they're usable in this window.
|
||||
*/
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror", "todo",
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ise", "ok", "onerror", "todo",
|
||||
"todo_is", "todo_isnot" ];
|
||||
for each (var name in imports) {
|
||||
window[name] = window.opener.wrappedJSObject[name];
|
||||
|
|
|
@ -281,7 +281,7 @@ Tester.prototype = {
|
|||
this.currentTest.scope.gTestPath = this.currentTest.path;
|
||||
|
||||
// Override SimpleTest methods with ours.
|
||||
["ok", "is", "isnot", "todo", "todo_is", "todo_isnot", "info"].forEach(function(m) {
|
||||
["ok", "is", "isnot", "ise", "todo", "todo_is", "todo_isnot", "info"].forEach(function(m) {
|
||||
this.SimpleTest[m] = this[m];
|
||||
}, this.currentTest.scope);
|
||||
|
||||
|
@ -421,6 +421,10 @@ function testScope(aTester, aTest) {
|
|||
self.ok(a != b, name, "Didn't expect " + a + ", but got it", false,
|
||||
Components.stack.caller);
|
||||
};
|
||||
this.ise = function test_ise(a, b, name) {
|
||||
self.ok(a === b, name, "Got " + a + ", strictly expected " + b, false,
|
||||
Components.stack.caller);
|
||||
};
|
||||
this.todo = function test_todo(condition, name, diag, stack) {
|
||||
aTest.addResult(new testResult(!condition, name, diag, true,
|
||||
stack ? stack : Components.stack.caller));
|
||||
|
|
|
@ -252,6 +252,16 @@ SimpleTest.isnot = function (a, b, name) {
|
|||
SimpleTest.ok(pass, name, diag);
|
||||
};
|
||||
|
||||
/**
|
||||
* Roughly equivalent to ok(a===b, name)
|
||||
**/
|
||||
SimpleTest.ise = function (a, b, name) {
|
||||
var pass = (a === b);
|
||||
var diag = pass ? repr(a) + " should strictly equal " + repr(b)
|
||||
: "got " + repr(a) + ", strictly expected " + repr(b)
|
||||
SimpleTest.ok(pass, name, diag);
|
||||
};
|
||||
|
||||
// --------------- Test.Builder/Test.More todo() -----------------
|
||||
|
||||
SimpleTest.todo = function(condition, name, diag) {
|
||||
|
@ -961,6 +971,7 @@ SimpleTest.isa = function (object, clas) {
|
|||
var ok = SimpleTest.ok;
|
||||
var is = SimpleTest.is;
|
||||
var isnot = SimpleTest.isnot;
|
||||
var ise = SimpleTest.ise;
|
||||
var todo = SimpleTest.todo;
|
||||
var todo_is = SimpleTest.todo_is;
|
||||
var todo_isnot = SimpleTest.todo_isnot;
|
||||
|
|
|
@ -2,11 +2,12 @@ function test() {
|
|||
ok(true, "pass ok");
|
||||
is(true, true, "pass is");
|
||||
isnot(false, true, "pass isnot");
|
||||
ise(true, true, "pass ise");
|
||||
todo(false, "pass todo");
|
||||
todo_is(false, true, "pass todo_is");
|
||||
todo_isnot(true, true, "pass todo_isnot");
|
||||
info("info message");
|
||||
|
||||
var func = is;
|
||||
func(true, true, "pass indirect is");
|
||||
func(true, 1, "pass indirect is");
|
||||
}
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// ise - is exact - compares using ===
|
||||
function ise(left, right, name) { SimpleTest.ok(left === right, name); }
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var testtag_notificationbox_buttons = [
|
||||
|
@ -40,10 +37,10 @@ function testtag_notificationbox(nb)
|
|||
{
|
||||
testtag_notificationbox_State(nb, "initial", null, 0);
|
||||
|
||||
ise(nb.notificationsHidden, false, "initial notificationsHidden");
|
||||
ise(nb.removeAllNotifications(false), undefined, "initial removeAllNotifications");
|
||||
SimpleTest.ise(nb.notificationsHidden, false, "initial notificationsHidden");
|
||||
SimpleTest.ise(nb.removeAllNotifications(false), undefined, "initial removeAllNotifications");
|
||||
testtag_notificationbox_State(nb, "initial removeAllNotifications", null, 0);
|
||||
ise(nb.removeAllNotifications(true), undefined, "initial removeAllNotifications immediate");
|
||||
SimpleTest.ise(nb.removeAllNotifications(true), undefined, "initial removeAllNotifications immediate");
|
||||
testtag_notificationbox_State(nb, "initial removeAllNotifications immediate", null, 0);
|
||||
|
||||
runTimedTests(tests, -1, nb, null);
|
||||
|
@ -74,7 +71,7 @@ var tests =
|
|||
// append a new notification
|
||||
var ntf = nb.appendNotification("Notification", "note", "happy.png",
|
||||
nb.PRIORITY_INFO_LOW, testtag_notificationbox_buttons);
|
||||
ise(ntf && ntf.localName == "notification", true, "append notification");
|
||||
SimpleTest.ise(ntf && ntf.localName == "notification", true, "append notification");
|
||||
return ntf;
|
||||
},
|
||||
result: function(nb, ntf) {
|
||||
|
@ -84,10 +81,10 @@ var tests =
|
|||
|
||||
// check the getNotificationWithValue method
|
||||
var ntf_found = nb.getNotificationWithValue("note");
|
||||
ise(ntf, ntf_found, "getNotificationWithValue note");
|
||||
SimpleTest.ise(ntf, ntf_found, "getNotificationWithValue note");
|
||||
|
||||
var none_found = nb.getNotificationWithValue("notenone");
|
||||
ise(none_found, null, "getNotificationWithValue null");
|
||||
SimpleTest.ise(none_found, null, "getNotificationWithValue null");
|
||||
return ntf;
|
||||
}
|
||||
},
|
||||
|
@ -105,7 +102,7 @@ var tests =
|
|||
try {
|
||||
nb.removeNotification(ntf);
|
||||
} catch (ex) { exh = true; }
|
||||
ise(exh, true, "removeNotification again");
|
||||
SimpleTest.ise(exh, true, "removeNotification again");
|
||||
testtag_notificationbox_State(nb, "removeNotification again", null, 0);
|
||||
|
||||
}
|
||||
|
@ -117,7 +114,7 @@ var tests =
|
|||
nb.PRIORITY_INFO_LOW,
|
||||
testtag_notificationbox_buttons,
|
||||
notification_eventCallback);
|
||||
ise(ntf && ntf.localName == "notification", true, "append notification with callback");
|
||||
SimpleTest.ise(ntf && ntf.localName == "notification", true, "append notification with callback");
|
||||
return ntf;
|
||||
},
|
||||
result: function(nb, ntf) {
|
||||
|
@ -148,7 +145,7 @@ var tests =
|
|||
// append a new notification
|
||||
ntf = nb.appendNotification("Notification", "note", "happy.png",
|
||||
nb.PRIORITY_INFO_LOW, testtag_notificationbox_buttons);
|
||||
ise(ntf && ntf.localName == "notification", true, "append notification");
|
||||
SimpleTest.ise(ntf && ntf.localName == "notification", true, "append notification");
|
||||
|
||||
// Test persistence
|
||||
ntf.persistence++;
|
||||
|
@ -169,14 +166,14 @@ var tests =
|
|||
testtag_notificationbox_State(nb, "notification added", ntf, 1);
|
||||
testtag_notification_State(nb, ntf, "append", "Notification", "note",
|
||||
"happy.png", nb.PRIORITY_INFO_LOW);
|
||||
ise(ntf.persistence, 1, "persistence is 1");
|
||||
SimpleTest.ise(ntf.persistence, 1, "persistence is 1");
|
||||
|
||||
return [++idx, ntf];
|
||||
case 2:
|
||||
testtag_notificationbox_State(nb, "first removeTransientNotifications", ntf, 1);
|
||||
testtag_notification_State(nb, ntf, "append", "Notification", "note",
|
||||
"happy.png", nb.PRIORITY_INFO_LOW);
|
||||
ise(ntf.persistence, 0, "persistence is now 0");
|
||||
SimpleTest.ise(ntf.persistence, 0, "persistence is now 0");
|
||||
|
||||
return [++idx, ntf];
|
||||
case 3:
|
||||
|
@ -191,7 +188,7 @@ var tests =
|
|||
// append another notification
|
||||
var ntf = nb.appendNotification("Notification", "note", "happy.png",
|
||||
nb.PRIORITY_INFO_MEDIUM, testtag_notificationbox_buttons);
|
||||
ise(ntf && ntf.localName == "notification", true, "append notification again");
|
||||
SimpleTest.ise(ntf && ntf.localName == "notification", true, "append notification again");
|
||||
return ntf;
|
||||
},
|
||||
result: function(nb, ntf) {
|
||||
|
@ -221,9 +218,9 @@ var tests =
|
|||
result: function(nb, ntf) {
|
||||
// test the removeAllNotifications method
|
||||
testtag_notificationbox_State(nb, "append info_high", ntf, 1);
|
||||
ise(ntf.priority, nb.PRIORITY_INFO_HIGH,
|
||||
SimpleTest.ise(ntf.priority, nb.PRIORITY_INFO_HIGH,
|
||||
"notification.priority " + nb.PRIORITY_INFO_HIGH);
|
||||
ise(nb.removeAllNotifications(false), undefined, "removeAllNotifications");
|
||||
SimpleTest.ise(nb.removeAllNotifications(false), undefined, "removeAllNotifications");
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -242,7 +239,7 @@ var tests =
|
|||
return ntf;
|
||||
},
|
||||
result: function(nb, ntf) {
|
||||
ise(nb.currentNotification == ntf ?
|
||||
SimpleTest.ise(nb.currentNotification == ntf ?
|
||||
nb.currentNotification.value : null, "10", "appendNotification order");
|
||||
return 1;
|
||||
}
|
||||
|
@ -274,8 +271,8 @@ var tests =
|
|||
},
|
||||
result: function(nb, arr) {
|
||||
// arr is [testindex, expectedvalue]
|
||||
ise(nb.currentNotification.value, "" + arr[1], "close order " + arr[0]);
|
||||
ise(nb.allNotifications.length, 10 - arr[0], "close order " + arr[0] + " count");
|
||||
SimpleTest.ise(nb.currentNotification.value, "" + arr[1], "close order " + arr[0]);
|
||||
SimpleTest.ise(nb.allNotifications.length, 10 - arr[0], "close order " + arr[0] + " count");
|
||||
if (arr[0] == 6)
|
||||
this.repeat = false;
|
||||
return ++arr[0];
|
||||
|
@ -287,13 +284,13 @@ var tests =
|
|||
try {
|
||||
nb.appendNotification("no", "no", "no", 0, null);
|
||||
} catch (ex) { exh = true; }
|
||||
ise(exh, true, "appendNotification priority too low");
|
||||
SimpleTest.ise(exh, true, "appendNotification priority too low");
|
||||
|
||||
exh = false;
|
||||
try {
|
||||
nb.appendNotification("no", "no", "no", 11, null);
|
||||
} catch (ex) { exh = true; }
|
||||
ise(exh, true, "appendNotification priority too high");
|
||||
SimpleTest.ise(exh, true, "appendNotification priority too high");
|
||||
|
||||
// check that the other priority types work properly
|
||||
runTimedTests(appendPriorityTests, -1, nb, nb.PRIORITY_WARNING_LOW);
|
||||
|
@ -306,11 +303,11 @@ var appendPriorityTests = [
|
|||
test: function(nb, priority) {
|
||||
var ntf = nb.appendNotification("Notification", "note", "happy.png",
|
||||
priority, testtag_notificationbox_buttons);
|
||||
ise(ntf && ntf.localName == "notification", true, "append notification " + priority);
|
||||
SimpleTest.ise(ntf && ntf.localName == "notification", true, "append notification " + priority);
|
||||
return [ntf, priority];
|
||||
},
|
||||
result: function(nb, obj) {
|
||||
ise(obj[0].priority, obj[1], "notification.priority " + obj[1]);
|
||||
SimpleTest.ise(obj[0].priority, obj[1], "notification.priority " + obj[1]);
|
||||
return obj[1];
|
||||
}
|
||||
},
|
||||
|
@ -334,18 +331,18 @@ var appendPriorityTests = [
|
|||
|
||||
function testtag_notificationbox_State(nb, testid, expecteditem, expectedcount)
|
||||
{
|
||||
ise(nb.currentNotification, expecteditem, testid + " currentNotification");
|
||||
ise(nb.allNotifications ? nb.allNotifications.length : "no value",
|
||||
SimpleTest.ise(nb.currentNotification, expecteditem, testid + " currentNotification");
|
||||
SimpleTest.ise(nb.allNotifications ? nb.allNotifications.length : "no value",
|
||||
expectedcount, testid + " allNotifications");
|
||||
}
|
||||
|
||||
function testtag_notification_State(nb, ntf, testid, label, value, image, priority)
|
||||
{
|
||||
ise(ntf.control, nb, testid + " notification.control");
|
||||
ise(ntf.label, label, testid + " notification.label");
|
||||
ise(ntf.value, value, testid + " notification.value");
|
||||
ise(ntf.image, image, testid + " notification.image");
|
||||
ise(ntf.priority, priority, testid + " notification.priority");
|
||||
SimpleTest.ise(ntf.control, nb, testid + " notification.control");
|
||||
SimpleTest.ise(ntf.label, label, testid + " notification.label");
|
||||
SimpleTest.ise(ntf.value, value, testid + " notification.value");
|
||||
SimpleTest.ise(ntf.image, image, testid + " notification.image");
|
||||
SimpleTest.ise(ntf.priority, priority, testid + " notification.priority");
|
||||
|
||||
var type;
|
||||
switch (priority) {
|
||||
|
@ -367,7 +364,7 @@ function testtag_notification_State(nb, ntf, testid, label, value, image, priori
|
|||
break;
|
||||
}
|
||||
|
||||
ise(ntf.type, type, testid + " notification.type");
|
||||
SimpleTest.ise(ntf.type, type, testid + " notification.type");
|
||||
}
|
||||
|
||||
function checkPopupTest(nb, ntf)
|
||||
|
|
|
@ -17,36 +17,33 @@
|
|||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// ise - is exact - compares using ===
|
||||
function ise(left, right, name) { SimpleTest.ok(left === right, name); }
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function doTests() {
|
||||
var n1 = document.getElementById("n1");
|
||||
var n2 = document.getElementById("n2");
|
||||
|
||||
ise(n1.mode, "", "mode determined");
|
||||
ise(n2.mode, "undetermined", "mode undetermined");
|
||||
SimpleTest.ise(n1.mode, "", "mode determined");
|
||||
SimpleTest.ise(n2.mode, "undetermined", "mode undetermined");
|
||||
|
||||
ise(n1.value, "0", "determined value");
|
||||
ise(n2.value, "0", "undetermined value");
|
||||
SimpleTest.ise(n1.value, "0", "determined value");
|
||||
SimpleTest.ise(n2.value, "0", "undetermined value");
|
||||
|
||||
// values can only be incremented in multiples of 4
|
||||
n1.value = 2;
|
||||
ise(n1.value, "0", "determined value set 2");
|
||||
SimpleTest.ise(n1.value, "0", "determined value set 2");
|
||||
n1.value = -1;
|
||||
ise(n1.value, "0", "determined value set -1");
|
||||
SimpleTest.ise(n1.value, "0", "determined value set -1");
|
||||
n1.value = 125;
|
||||
ise(n1.value, "100", "determined value set 125");
|
||||
SimpleTest.ise(n1.value, "100", "determined value set 125");
|
||||
n1.value = 7;
|
||||
ise(n1.value, "7", "determined value set 7");
|
||||
SimpleTest.ise(n1.value, "7", "determined value set 7");
|
||||
n1.value = "17";
|
||||
ise(n1.value, "17", "determined value set 17 string");
|
||||
SimpleTest.ise(n1.value, "17", "determined value set 17 string");
|
||||
n1.value = 18;
|
||||
ise(n1.value, "17", "determined value set 18");
|
||||
SimpleTest.ise(n1.value, "17", "determined value set 18");
|
||||
n1.value = "Cat";
|
||||
ise(n1.value, "17", "determined value set invalid");
|
||||
SimpleTest.ise(n1.value, "17", "determined value set invalid");
|
||||
|
||||
n1.max = 200;
|
||||
is(n1.max, 200, "max changed");
|
||||
|
@ -55,19 +52,19 @@ function doTests() {
|
|||
is(n1.value, 120, "max lowered below value");
|
||||
|
||||
n2.value = 2;
|
||||
ise(n2.value, "0", "undetermined value set 2");
|
||||
SimpleTest.ise(n2.value, "0", "undetermined value set 2");
|
||||
n2.value = -1;
|
||||
ise(n2.value, "0", "undetermined value set -1");
|
||||
SimpleTest.ise(n2.value, "0", "undetermined value set -1");
|
||||
n2.value = 125;
|
||||
ise(n2.value, "100", "undetermined value set 125");
|
||||
SimpleTest.ise(n2.value, "100", "undetermined value set 125");
|
||||
n2.value = 7;
|
||||
ise(n2.value, "7", "undetermined value set 7");
|
||||
SimpleTest.ise(n2.value, "7", "undetermined value set 7");
|
||||
n2.value = "17";
|
||||
ise(n2.value, "17", "undetermined value set 17 string");
|
||||
SimpleTest.ise(n2.value, "17", "undetermined value set 17 string");
|
||||
n2.value = 18;
|
||||
ise(n2.value, "17", "undetermined value set 18");
|
||||
SimpleTest.ise(n2.value, "17", "undetermined value set 18");
|
||||
n2.value = "Cat";
|
||||
ise(n2.value, "17", "determined value set invalid");
|
||||
SimpleTest.ise(n2.value, "17", "determined value set invalid");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
@ -36,11 +36,6 @@
|
|||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// ise - is exact - compares using ===
|
||||
function ise(left, right, name) {
|
||||
SimpleTest.ok(left === right, name, "got " + left + ", expected " + right);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// ---- NOTE: the numbers used in these tests are carefully chosen to avoid
|
||||
|
@ -66,14 +61,14 @@ function doTests() {
|
|||
ok(n1.spinButtons != null && n1.spinButtons.localName == "spinbuttons", "spinButtons set");
|
||||
isnot(n1.decimalSymbol, "", "n1.decimalSymbol is set to something");
|
||||
n1.decimalSymbol = ".";
|
||||
ise(n1.decimalSymbol, ".", "n1.decimalSymbol set to '.'");
|
||||
ise(n1.wrapAround, false, "wrapAround defaults to false");
|
||||
ise(n1.increment, 1, "increment defaults to 1");
|
||||
ise(n1.decimalPlaces, 0, "decimalPlaces defaults to 0");
|
||||
SimpleTest.ise(n1.decimalSymbol, ".", "n1.decimalSymbol set to '.'");
|
||||
SimpleTest.ise(n1.wrapAround, false, "wrapAround defaults to false");
|
||||
SimpleTest.ise(n1.increment, 1, "increment defaults to 1");
|
||||
SimpleTest.ise(n1.decimalPlaces, 0, "decimalPlaces defaults to 0");
|
||||
|
||||
ise(n2.wrapAround, true, "wrapAround when set to true");
|
||||
ise(n3.increment, 3, "increment when set to 1");
|
||||
ise(n7.decimalPlaces, 2, "decimalPlaces when set to 2");
|
||||
SimpleTest.ise(n2.wrapAround, true, "wrapAround when set to true");
|
||||
SimpleTest.ise(n3.increment, 3, "increment when set to 1");
|
||||
SimpleTest.ise(n7.decimalPlaces, 2, "decimalPlaces when set to 2");
|
||||
|
||||
// test changing the value
|
||||
n1.value = "1700";
|
||||
|
@ -144,7 +139,7 @@ function doTests() {
|
|||
n7.min = 2.7;
|
||||
n7.value = 10.1;
|
||||
n7.increment = 4.3;
|
||||
ise(n7.increment, 4.3, "increment changed");
|
||||
SimpleTest.ise(n7.increment, 4.3, "increment changed");
|
||||
testIncreaseDecrease(n7, "integer with increment", 4.3, 2, 2.7, 10.1);
|
||||
|
||||
n2.value = n2.min;
|
||||
|
@ -154,7 +149,7 @@ function doTests() {
|
|||
testVals(n2, "integer wraparound decrease method", n2.min);
|
||||
|
||||
n7.wrapAround = true;
|
||||
ise(n7.wrapAround, true, "change wrapAround");
|
||||
SimpleTest.ise(n7.wrapAround, true, "change wrapAround");
|
||||
n7.value = n7.min + 0.01;
|
||||
n7.decrease();
|
||||
testVals(n7, "decimal wraparound decrease method", n7.max, n7.max.toFixed(2));
|
||||
|
@ -173,12 +168,12 @@ function doTests() {
|
|||
testVals(n1, "set decimalPlaces Infinity set value,", 10.678123);
|
||||
|
||||
n1.decimalSymbol = ",";
|
||||
ise(n1.decimalSymbol, ",", "n1.decimalSymbol set to ','");
|
||||
SimpleTest.ise(n1.decimalSymbol, ",", "n1.decimalSymbol set to ','");
|
||||
n1.value = "9.67";
|
||||
testVals(n1, "set decimalPlaces set value,", 9.67);
|
||||
|
||||
n1.decimalSymbol = ".";
|
||||
ise(n1.decimalSymbol, ".", "n1.decimalSymbol set back to '.'");
|
||||
SimpleTest.ise(n1.decimalSymbol, ".", "n1.decimalSymbol set back to '.'");
|
||||
n1.decimalPlaces = 0;
|
||||
|
||||
// UI tests
|
||||
|
@ -290,19 +285,19 @@ function testVals(nb, name, valueNumber, valueFieldNumber) {
|
|||
if (valueFieldNumber === undefined)
|
||||
valueFieldNumber = "" + valueNumber;
|
||||
|
||||
ise(nb.value, "" + valueNumber, name + " value is '" + valueNumber + "'");
|
||||
ise(nb.valueNumber, valueNumber, name + " valueNumber is " + valueNumber);
|
||||
SimpleTest.ise(nb.value, "" + valueNumber, name + " value is '" + valueNumber + "'");
|
||||
SimpleTest.ise(nb.valueNumber, valueNumber, name + " valueNumber is " + valueNumber);
|
||||
|
||||
// This value format depends on the localized decimal symbol.
|
||||
var localizedValue = valueFieldNumber.replace(/\./, nb.decimalSymbol);
|
||||
ise(nb.inputField.value, localizedValue,
|
||||
SimpleTest.ise(nb.inputField.value, localizedValue,
|
||||
name + " inputField value is '" + localizedValue + "'");
|
||||
}
|
||||
|
||||
function testValsMinMax(nb, name, valueNumber, min, max, valueFieldNumber) {
|
||||
testVals(nb, name, valueNumber, valueFieldNumber);
|
||||
ise(nb.min, min, name + " min is " + min);
|
||||
ise(nb.max, max, name + " max is " + max);
|
||||
SimpleTest.ise(nb.min, min, name + " min is " + min);
|
||||
SimpleTest.ise(nb.max, max, name + " max is " + max);
|
||||
}
|
||||
|
||||
function testIncreaseDecrease(nb, testid, increment, fixedCount, min, max)
|
||||
|
|
Загрузка…
Ссылка в новой задаче