зеркало из https://github.com/mozilla/pjs.git
Bug 593872 - Send events for when tabs become pinned/unpinned; r,a=gavin
This commit is contained in:
Родитель
9f461ad4eb
Коммит
eeb35cfe89
|
@ -185,6 +185,10 @@
|
|||
aTab.setAttribute("pinned", "true");
|
||||
this.tabContainer._positionPinnedTabs();
|
||||
this.tabContainer.adjustTabstrip();
|
||||
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("TabPin", true, false);
|
||||
aTab.dispatchEvent(event);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -200,6 +204,10 @@
|
|||
aTab.style.MozMarginStart = "";
|
||||
this.tabContainer._positionPinnedTabs();
|
||||
this.tabContainer.adjustTabstrip();
|
||||
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("TabUnpin", true, false);
|
||||
aTab.dispatchEvent(event);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
|
|
@ -11,6 +11,23 @@ function indexTest(tab, expectedIndex, msg) {
|
|||
is(index(tabs[tab]), expectedIndex, msg);
|
||||
}
|
||||
|
||||
function PinUnpinHandler(tab, eventName) {
|
||||
this.eventCount = 0;
|
||||
var self = this;
|
||||
tab.addEventListener(eventName, function() {
|
||||
tab.removeEventListener(eventName, arguments.callee, true);
|
||||
|
||||
self.eventCount++;
|
||||
}, true);
|
||||
gBrowser.tabContainer.addEventListener(eventName, function(e) {
|
||||
gBrowser.tabContainer.removeEventListener(eventName, arguments.callee, true);
|
||||
|
||||
if (e.originalTarget == tab) {
|
||||
self.eventCount++;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
function test() {
|
||||
tabs = [gBrowser.selectedTab, gBrowser.addTab(), gBrowser.addTab(), gBrowser.addTab()];
|
||||
indexTest(0, 0);
|
||||
|
@ -18,13 +35,17 @@ function test() {
|
|||
indexTest(2, 2);
|
||||
indexTest(3, 3);
|
||||
|
||||
var eh = new PinUnpinHandler(tabs[3], "TabPin");
|
||||
gBrowser.pinTab(tabs[3]);
|
||||
is(eh.eventCount, 2, "TabPin event should be fired");
|
||||
indexTest(0, 1);
|
||||
indexTest(1, 2);
|
||||
indexTest(2, 3);
|
||||
indexTest(3, 0);
|
||||
|
||||
eh = new PinUnpinHandler(tabs[1], "TabPin");
|
||||
gBrowser.pinTab(tabs[1]);
|
||||
is(eh.eventCount, 2, "TabPin event should be fired");
|
||||
indexTest(0, 2);
|
||||
indexTest(1, 1);
|
||||
indexTest(2, 3);
|
||||
|
@ -36,10 +57,14 @@ function test() {
|
|||
gBrowser.moveTabTo(tabs[2], 0);
|
||||
indexTest(2, 2, "shouldn't be able to mix a normal tab into pinned tabs");
|
||||
|
||||
eh = new PinUnpinHandler(tabs[1], "TabUnpin");
|
||||
gBrowser.unpinTab(tabs[1]);
|
||||
is(eh.eventCount, 2, "TabUnpin event should be fired");
|
||||
indexTest(1, 1, "unpinning a tab should move a tab to the start of normal tabs");
|
||||
|
||||
eh = new PinUnpinHandler(tabs[3], "TabUnpin");
|
||||
gBrowser.unpinTab(tabs[3]);
|
||||
is(eh.eventCount, 2, "TabUnpin event should be fired");
|
||||
indexTest(3, 0, "unpinning a tab should move a tab to the start of normal tabs");
|
||||
|
||||
gBrowser.removeTab(tabs[1]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче