mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
de2e79da4d
(Based on patch from Sean Dunn <seanedunn@yahoo.com>.)
94 lines
2.7 KiB
JavaScript
94 lines
2.7 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
function test() {
|
|
let cw;
|
|
let tab;
|
|
|
|
let testReconnectWithSameUrl = function () {
|
|
tab = gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
|
|
|
|
afterAllTabsLoaded(function () {
|
|
let tabItem = tab._tabViewTabItem;
|
|
let data = tabItem.getStorageData(true);
|
|
gBrowser.removeTab(tab);
|
|
|
|
cw.TabItems.pauseReconnecting();
|
|
tab = gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
|
|
cw.Storage.saveTab(tab, data);
|
|
|
|
whenTabAttrModified(tab, function () {
|
|
tabItem = tab._tabViewTabItem;
|
|
|
|
// Hook into loadedCachedImageData since loading cached thumbnails
|
|
// is asynchronous.
|
|
tabItem.addSubscriber(tabItem, "loadedCachedImageData", function(item) {
|
|
item.removeSubscriber(item, "loadedCachedImageData");
|
|
|
|
ok(tabItem.isShowingCachedData(), 'tabItem shows cached data');
|
|
|
|
testChangeUrlAfterReconnect();
|
|
});
|
|
|
|
cw.TabItems.resumeReconnecting();
|
|
});
|
|
});
|
|
}
|
|
|
|
let testChangeUrlAfterReconnect = function () {
|
|
tab.linkedBrowser.loadURI('http://mochi.test:8888/browser/');
|
|
|
|
whenTabAttrModified(tab, function () {
|
|
cw.TabItems._update(tab);
|
|
|
|
let tabItem = tab._tabViewTabItem;
|
|
let currentLabel = tabItem.$tabTitle.text();
|
|
|
|
is(currentLabel, 'mochitest index /browser/', 'tab label is up-to-date');
|
|
testReconnectWithNewUrl();
|
|
});
|
|
}
|
|
|
|
let testReconnectWithNewUrl = function () {
|
|
let tabItem = tab._tabViewTabItem;
|
|
let data = tabItem.getStorageData(true);
|
|
gBrowser.removeTab(tab);
|
|
|
|
cw.TabItems.pauseReconnecting();
|
|
tab = gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
|
|
cw.Storage.saveTab(tab, data);
|
|
|
|
whenTabAttrModified(tab, function () {
|
|
tabItem = tab._tabViewTabItem;
|
|
cw.TabItems.resumeReconnecting();
|
|
ok(!tabItem.isShowingCachedData(), 'tabItem does not show cached data');
|
|
|
|
gBrowser.removeTab(tab);
|
|
hideTabView(finish);
|
|
});
|
|
}
|
|
|
|
waitForExplicitFinish();
|
|
|
|
showTabView(function () {
|
|
cw = TabView.getContentWindow();
|
|
testReconnectWithSameUrl();
|
|
});
|
|
}
|
|
|
|
// ----------
|
|
function whenTabAttrModified(tab, callback) {
|
|
let onModified = function (event) {
|
|
if (tab === event.target) {
|
|
container.removeEventListener('TabAttrModified', onModified, false);
|
|
// we need executeSoon here because the tabItem also listens for the
|
|
// onTabAttrModified event. so this is to make sure the tabItem logic
|
|
// is executed before the test logic.
|
|
executeSoon(callback);
|
|
}
|
|
}
|
|
|
|
let container = gBrowser.tabContainer;
|
|
container.addEventListener('TabAttrModified', onModified, false);
|
|
}
|