Bug 1241930: Part 4 - convert all assertion methods used inside content tasks to the Assert.* family in docshell tests. r=mconley

This commit is contained in:
Mike de Boer 2016-03-04 14:32:29 +01:00
parent 7a4941b3e4
commit 2f562a286b
6 changed files with 30 additions and 30 deletions

View File

@ -5,12 +5,12 @@ add_task(function* test() {
function checkContentProcess(uri) {
yield ContentTask.spawn(newBrowser, uri, function* (uri) {
var prin = content.document.nodePrincipal;
isnot(prin, null, "Loaded principal must not be null when adding " + uri);
isnot(prin, undefined, "Loaded principal must not be undefined when loading " + uri);
Assert.notEqual(prin, null, "Loaded principal must not be null when adding " + uri);
Assert.notEqual(prin, undefined, "Loaded principal must not be undefined when loading " + uri);
const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
is(secMan.isSystemPrincipal(prin), false,
Assert.equal(secMan.isSystemPrincipal(prin), false,
"Loaded principal must not be system when loading " + uri);
});
}

View File

@ -2,13 +2,13 @@ add_task(function* test() {
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (newBrowser) {
yield ContentTask.spawn(newBrowser, null, function* () {
var prin = content.document.nodePrincipal;
isnot(prin, null, "Loaded principal must not be null");
isnot(prin, undefined, "Loaded principal must not be undefined");
Assert.notEqual(prin, null, "Loaded principal must not be null");
Assert.notEqual(prin, undefined, "Loaded principal must not be undefined");
const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
is(secMan.isSystemPrincipal(prin), false,
"Loaded principal must not be system");
Assert.equal(secMan.isSystemPrincipal(prin), false,
"Loaded principal must not be system");
});
});
});

View File

@ -26,7 +26,7 @@ add_task(function* test() {
addEventListener("load", function onLoad() {
removeEventListener("load", onLoad, true);
ok(history.index < history.count, "history.index is valid");
Assert.ok(history.index < history.count, "history.index is valid");
testDone.resolve();
}, true);

View File

@ -39,7 +39,7 @@ function test() {
.getInterface(Ci.nsIWebNavigation)
.sessionHistory;
is(shistory.count, 1, 'shistory count should be 1.');
Assert.equal(shistory.count, 1, "shistory count should be 1.");
resolve();
}, true);
});

View File

@ -4,12 +4,12 @@
function testContent(text) {
return ContentTask.spawn(gBrowser.selectedBrowser, text, text => {
is(content.document.getElementById("testpar").innerHTML, text,
"<p> contains expected text");
is(content.document.getElementById("testtextarea").innerHTML, text,
"<textarea> contains expected text");
is(content.document.getElementById("testinput").value, text,
"<input> contains expected text");
Assert.equal(content.document.getElementById("testpar").innerHTML, text,
"<p> contains expected text");
Assert.equal(content.document.getElementById("testtextarea").innerHTML, text,
"<textarea> contains expected text");
Assert.equal(content.document.getElementById("testinput").value, text,
"<input> contains expected text");
});
}

View File

@ -92,14 +92,14 @@ function step3() {
// Tab 2's window _and_ its iframes should be inactive
ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
ContentTask.spawn(ctx.tab2Browser, null, function* () {
is(content.frames.length, 2, "Tab 2 should have 2 iframes");
Assert.equal(content.frames.length, 2, "Tab 2 should have 2 iframes");
for (var i = 0; i < content.frames.length; i++) {
info("step 3, frame " + i + " info: " + content.frames[i].location);
let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
}
}).then(() => {
// Navigate tab 2 to a different page
@ -122,14 +122,14 @@ function step4() {
}
let active = expected ? "active" : "inactive";
is(content.frames.length, 2, "Tab 2 should have 2 iframes");
Assert.equal(content.frames.length, 2, "Tab 2 should have 2 iframes");
for (var i = 0; i < content.frames.length; i++)
info("step 4, frame " + i + " info: " + content.frames[i].location);
is(content.frames[0].frames.length, 1, "Tab 2 iframe 0 should have 1 iframes");
is(isActive(content.frames[0]), expected, `Tab2 iframe 0 should be ${active}`);
is(isActive(content.frames[0].frames[0]), expected,
Assert.equal(content.frames[0].frames.length, 1, "Tab 2 iframe 0 should have 1 iframes");
Assert.equal(isActive(content.frames[0]), expected, `Tab2 iframe 0 should be ${active}`);
Assert.equal(isActive(content.frames[0].frames[0]), expected,
`Tab2 iframe 0 subiframe 0 should be ${active}`);
is(isActive(content.frames[1]), expected, `Tab2 iframe 1 should be ${active}`);
Assert.equal(isActive(content.frames[1]), expected, `Tab2 iframe 1 should be ${active}`);
});
}
@ -169,7 +169,7 @@ function step5() {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
ok(docShell.isActive, `Tab2 iframe ${i} should be active`);
Assert.ok(docShell.isActive, `Tab2 iframe ${i} should be active`);
}
}).then(() => {
// Switch to tab 1
@ -197,9 +197,9 @@ function step6() {
return docshell.isActive;
}
ok(isActive(content.frames[0]), "Tab1 iframe 0 should be active");
ok(isActive(content.frames[0].frames[0]), "Tab1 iframe 0 subiframe 0 should be active");
ok(isActive(content.frames[1]), "Tab1 iframe 1 should be active");
Assert.ok(isActive(content.frames[0]), "Tab1 iframe 0 should be active");
Assert.ok(isActive(content.frames[0].frames[0]), "Tab1 iframe 0 subiframe 0 should be active");
Assert.ok(isActive(content.frames[1]), "Tab1 iframe 1 should be active");
}).then(() => {
ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
return ContentTask.spawn(ctx.tab2Browser, null, function* () {
@ -208,7 +208,7 @@ function step6() {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
}
});
}).then(() => {
@ -230,11 +230,11 @@ function step7() {
}
let activestr = active ? "active" : "inactive";
is(isActive(content.frames[0]), active,
Assert.equal(isActive(content.frames[0]), active,
`Tab${tabNum} iframe 0 should be ${activestr}`);
is(isActive(content.frames[0].frames[0]), active,
Assert.equal(isActive(content.frames[0].frames[0]), active,
`Tab${tabNum} iframe 0 subiframe 0 should be ${activestr}`);
is(isActive(content.frames[1]), active,
Assert.equal(isActive(content.frames[1]), active,
`Tab${tabNum} iframe 1 should be ${activestr}`);
});
}