Bug 575561 - External links from within app tabs should always open in new tabs instead of replacing the app tab's page (Tests). r=gavin, a=blocking-beta7

This commit is contained in:
Margaret Leibovic 2010-10-28 15:00:50 -07:00
Родитель dd63205961
Коммит 40c768a7e3
5 изменённых файлов: 111 добавлений и 0 удалений

Просмотреть файл

@ -145,6 +145,7 @@ _BROWSER_FILES = \
browser_bug561636.js \ browser_bug561636.js \
browser_bug562649.js \ browser_bug562649.js \
browser_bug563588.js \ browser_bug563588.js \
browser_bug575561.js \
browser_bug577121.js \ browser_bug577121.js \
browser_bug579872.js \ browser_bug579872.js \
browser_bug580956.js \ browser_bug580956.js \
@ -218,6 +219,8 @@ _BROWSER_FILES = \
file_bug550565_favicon.ico \ file_bug550565_favicon.ico \
browser_overLinkInLocationBar.js \ browser_overLinkInLocationBar.js \
browser_aboutHome.js \ browser_aboutHome.js \
app_bug575561.html \
app_subframe_bug575561.html \
$(NULL) $(NULL)
# compartment-disabled # compartment-disabled

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=575561
-->
<head>
<title>Test for links in app tabs</title>
</head>
<body>
<a href="http://example.com/browser/browser/base/content/test/dummy_page.html">same domain</a>
<a href="http://test1.example.com/browser/browser/base/content/test/dummy_page.html">same domain (different subdomain)</a>
<a href="http://example.org/browser/browser/base/content/test/dummy_page.html">different domain</a>
<a href="http://example.org/browser/browser/base/content/test/dummy_page.html" target="foo">different domain (with target)</a>
<iframe src="app_subframe_bug575561.html"></iframe>
</body>
</html>

Просмотреть файл

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=575561
-->
<head>
<title>Test for links in app tab subframes</title>
</head>
<body>
<a href="http://example.org/browser/browser/base/content/test/dummy_page.html">different domain</a>
</body>
</html>

Просмотреть файл

@ -0,0 +1,77 @@
function test() {
waitForExplicitFinish();
// Pinned: Link to the same domain should not open a new tab
// Tests link to http://example.com/browser/browser/base/content/test/dummy_page.html
testLink(0, true, false, function() {
// Pinned: Link to the same domain should not open a new tab
// Tests link to http://test1.example.com/browser/browser/base/content/test/dummy_page.html
testLink(1, true, false, function() {
// Pinned: Link to a different domain should open a new tab
// Tests link to http://example.org/browser/browser/base/content/test/dummy_page.html
testLink(2, true, true, function() {
// Not Pinned: Link to a different domain should not open a new tab
// Tests link to http://example.org/browser/browser/base/content/test/dummy_page.html
testLink(2, false, false, function() {
// Pinned: Targetted link should open a new tab
// Tests link to http://example.org/browser/browser/base/content/test/dummy_page.html with target="foo"
testLink(3, true, true, function() {
// Pinned: Link in a subframe should not open a new tab
// Tests link to http://example.org/browser/browser/base/content/test/dummy_page.html in subframe
testLink(0, true, false, finish, true);
});
});
});
});
});
}
function testLink(aLinkIndex, pinTab, expectNewTab, nextTest, testSubFrame) {
let appTab = gBrowser.addTab("http://example.com/browser/browser/base/content/test/app_bug575561.html", {skipAnimation: true});
if (pinTab)
gBrowser.pinTab(appTab);
gBrowser.selectedTab = appTab;
appTab.linkedBrowser.addEventListener("load", onLoad, true);
let loadCount = 0;
function onLoad() {
loadCount++;
if (loadCount < 2)
return;
appTab.linkedBrowser.removeEventListener("load", onLoad, true);
let browser = gBrowser.getBrowserForTab(appTab);
if (testSubFrame)
browser = browser.contentDocument.getElementsByTagName("iframe")[0];
let links = browser.contentDocument.getElementsByTagName("a");
if (expectNewTab)
gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, true);
else
browser.addEventListener("load", onPageLoad, true);
info("Clicking " + links[aLinkIndex].textContent);
EventUtils.sendMouseEvent({type:"click"}, links[aLinkIndex], browser.contentWindow);
function onPageLoad() {
browser.removeEventListener("load", onPageLoad, true);
is(browser.contentDocument.location.href, links[aLinkIndex].href, "Link should not open in a new tab");
executeSoon(function(){
gBrowser.removeTab(appTab);
nextTest();
});
}
function onTabOpen(event) {
gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, true);
ok(true, "Link should open a new tab");
executeSoon(function(){
gBrowser.removeTab(appTab);
gBrowser.removeCurrentTab();
nextTest();
});
}
}
}

Просмотреть файл

@ -50,6 +50,7 @@ function checkServices() {
checkService("prefs", Ci.nsIPrefService); checkService("prefs", Ci.nsIPrefService);
checkService("contentPrefs", Ci.nsIContentPrefService); checkService("contentPrefs", Ci.nsIContentPrefService);
checkService("wm", Ci.nsIWindowMediator); checkService("wm", Ci.nsIWindowMediator);
checkService("obs", Ci.nsIObserverService);
checkService("perms", Ci.nsIPermissionManager); checkService("perms", Ci.nsIPermissionManager);
checkService("io", Ci.nsIIOService); checkService("io", Ci.nsIIOService);
checkService("io", Ci.nsIIOService2); checkService("io", Ci.nsIIOService2);
@ -66,6 +67,8 @@ function checkServices() {
checkService("scriptloader", Ci.mozIJSSubScriptLoader); checkService("scriptloader", Ci.mozIJSSubScriptLoader);
checkService("ww", Ci.nsIWindowWatcher); checkService("ww", Ci.nsIWindowWatcher);
checkService("tm", Ci.nsIThreadManager); checkService("tm", Ci.nsIThreadManager);
checkService("droppedLinkHandler", Ci.nsIDroppedLinkHandler);
checkService("strings", Ci.nsIStringBundleService); checkService("strings", Ci.nsIStringBundleService);
checkService("urlFormatter", Ci.nsIURLFormatter); checkService("urlFormatter", Ci.nsIURLFormatter);
checkService("eTLD", Ci.nsIEffectiveTLDService);
} }