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 2f562a286b
commit c326e059de
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 // Test that the frame DID NOT load
var test = this.contentDocument.getElementById("test"); var test = this.contentDocument.getElementById("test");
is(test, null, "should be about:blank"); Assert.equal(test, null, "should be about:blank");
deferred.resolve(); deferred.resolve();
}, true); }, true);

View File

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

View File

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

View File

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