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

This commit is contained in:
Mike de Boer 2016-03-04 14:32:32 +01:00
parent 6eb50a298c
commit 86fc8c7fb0
4 changed files with 28 additions and 33 deletions

View File

@ -60,7 +60,7 @@ function testXFOFrameInContent(newBrowser) {
// Test that the frame DID NOT load
var test = this.contentDocument.getElementById("test");
is(test, null, "should be about:blank");
Assert.equal(test, null, "should be about:blank");
deferred.resolve();
}, true);

View File

@ -60,11 +60,9 @@ function MixedTest1B() {
function MixedTest1C() {
ContentTask.spawn(gTestBrowser, null, function() {
return content.location.href;
}).then(url => {
ok(gTestBrowser.contentWindow.location == "http://example.com/", "Navigating to insecure domain through target='_top' failed.")
MixedTestsCompleted();
});
Assert.equal(content.location.href, "http://example.com/",
"Navigating to insecure domain through target='_top' failed.")
}).then(MixedTestsCompleted);
}

View File

@ -52,14 +52,12 @@ add_task(function* () {
yield promiseTabLoad(pluginTab, gTestRoot + "plugin_test.html");
yield promiseTabLoad(prefTab, "about:preferences");
let result = yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return !!plugin;
Assert.ok(!!plugin, "plugin is loaded");
});
is(result, true, "plugin is loaded");
let ppromise = promiseWaitForEvent(window, "MozAfterPaint");
gBrowser.selectedTab = prefTab;
yield ppromise;
@ -80,24 +78,23 @@ add_task(function* () {
EventUtils.synthesizeMouseAtCenter(tabStripContainer.childNodes[1], {}, window);
yield ppromise;
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
Assert.ok(XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(),
"plugin is visible");
});
is(result, true, "plugin is visible");
ppromise = promiseWaitForEvent(window, "MozAfterPaint");
EventUtils.synthesizeMouseAtCenter(tabStripContainer.childNodes[2], {}, window);
yield ppromise;
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
Assert.ok(!XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(),
"plugin is hidden");
});
is(result, false, "plugin is hidden");
}
gBrowser.removeTab(prefTab);

View File

@ -37,32 +37,32 @@ function startTests() {
info("Checking top window");
let gWindow = content;
is (gWindow.top, gWindow, "gWindow is top");
is (gWindow.parent, gWindow, "gWindow is parent");
Assert.equal(gWindow.top, gWindow, "gWindow is top");
Assert.equal(gWindow.parent, gWindow, "gWindow is parent");
info("Checking about:blank iframe");
let iframeBlank = gWindow.document.querySelector("#iframe-blank");
ok (iframeBlank, "Iframe exists on page");
Assert.ok(iframeBlank, "Iframe exists on page");
let iframeBlankUtils = getWindowUtils(iframeBlank.contentWindow);
is (iframeBlankUtils.containerElement, iframeBlank, "Container element for iframe window is iframe");
is (iframeBlank.contentWindow.top, gWindow, "gWindow is top");
is (iframeBlank.contentWindow.parent, gWindow, "gWindow is parent");
Assert.equal(iframeBlankUtils.containerElement, iframeBlank, "Container element for iframe window is iframe");
Assert.equal(iframeBlank.contentWindow.top, gWindow, "gWindow is top");
Assert.equal(iframeBlank.contentWindow.parent, gWindow, "gWindow is parent");
info("Checking iframe with data url src");
let iframeDataUrl = gWindow.document.querySelector("#iframe-data-url");
ok (iframeDataUrl, "Iframe exists on page");
Assert.ok(iframeDataUrl, "Iframe exists on page");
let iframeDataUrlUtils = getWindowUtils(iframeDataUrl.contentWindow);
is (iframeDataUrlUtils.containerElement, iframeDataUrl, "Container element for iframe window is iframe");
is (iframeDataUrl.contentWindow.top, gWindow, "gWindow is top");
is (iframeDataUrl.contentWindow.parent, gWindow, "gWindow is parent");
Assert.equal(iframeDataUrlUtils.containerElement, iframeDataUrl, "Container element for iframe window is iframe");
Assert.equal(iframeDataUrl.contentWindow.top, gWindow, "gWindow is top");
Assert.equal(iframeDataUrl.contentWindow.parent, gWindow, "gWindow is parent");
info("Checking object with data url data attribute");
let objectDataUrl = gWindow.document.querySelector("#object-data-url");
ok (objectDataUrl, "Object exists on page");
Assert.ok(objectDataUrl, "Object exists on page");
let objectDataUrlUtils = getWindowUtils(objectDataUrl.contentWindow);
is (objectDataUrlUtils.containerElement, objectDataUrl, "Container element for object window is the object");
is (objectDataUrl.contentWindow.top, gWindow, "gWindow is top");
is (objectDataUrl.contentWindow.parent, gWindow, "gWindow is parent");
Assert.equal(objectDataUrlUtils.containerElement, objectDataUrl, "Container element for object window is the object");
Assert.equal(objectDataUrl.contentWindow.top, gWindow, "gWindow is top");
Assert.equal(objectDataUrl.contentWindow.parent, gWindow, "gWindow is parent");
}
function* mozBrowserTests(browser) {
@ -75,9 +75,9 @@ function* mozBrowserTests(browser) {
let mozBrowserFrame = content.document.createElement("iframe");
mozBrowserFrame.setAttribute("mozbrowser", "");
content.document.body.appendChild(mozBrowserFrame);
is (mozBrowserFrame.contentWindow.top, mozBrowserFrame.contentWindow,
Assert.equal(mozBrowserFrame.contentWindow.top, mozBrowserFrame.contentWindow,
"Mozbrowser top == iframe window");
is (mozBrowserFrame.contentWindow.parent, mozBrowserFrame.contentWindow,
Assert.equal(mozBrowserFrame.contentWindow.parent, mozBrowserFrame.contentWindow,
"Mozbrowser parent == iframe window");
});