選択範囲のリンクをタブで開く機能を廃止
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5483 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
042f624f75
commit
a0df924943
@ -190,9 +190,6 @@
|
||||
|
||||
<prefpane id="prefpane-menu" label="&config.tabs.menu;">
|
||||
<preferences>
|
||||
<preference id="extensions.treestyletab.show.openSelectionLinks"
|
||||
name="extensions.treestyletab.show.openSelectionLinks"
|
||||
type="bool"/>
|
||||
<preference id="extensions.treestyletab.show.context-item-reloadTabSubTree"
|
||||
name="extensions.treestyletab.show.context-item-reloadTabSubTree"
|
||||
type="bool"/>
|
||||
@ -264,9 +261,6 @@
|
||||
label="&context.bookmarkTabSubTree.label;"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
<checkbox id="extensions.treestyletab.show.openSelectionLinks-check"
|
||||
preference="extensions.treestyletab.show.openSelectionLinks"
|
||||
label="&config.show.openSelectionLinks;"/>
|
||||
|
||||
</vbox>
|
||||
|
||||
|
@ -396,7 +396,7 @@ var TreeStyleTabService = {
|
||||
null ;
|
||||
},
|
||||
|
||||
readyToOpenDivertedTab : function(aFrameOrTabBrowser)
|
||||
readyToOpenDivertedTab : function(aFrameOrTabBrowser)
|
||||
{
|
||||
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
||||
if (!frame) return;
|
||||
@ -1436,7 +1436,6 @@ var TreeStyleTabService = {
|
||||
|
||||
window.removeEventListener('load', this, false);
|
||||
window.addEventListener('unload', this, false);
|
||||
document.getElementById('contentAreaContextMenu').addEventListener('popupshowing', this, false);
|
||||
document.addEventListener('popupshowing', this, false);
|
||||
document.addEventListener('popuphiding', this, false);
|
||||
|
||||
@ -2080,7 +2079,6 @@ catch(e) {
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
||||
|
||||
document.getElementById('contentAreaContextMenu').removeEventListener('popupshowing', this, false);
|
||||
document.removeEventListener('popupshowing', this, false);
|
||||
document.removeEventListener('popuphiding', this, false);
|
||||
|
||||
@ -2123,10 +2121,6 @@ catch(e) {
|
||||
return;
|
||||
|
||||
case 'popupshowing':
|
||||
if (aEvent.currentTarget.id == 'contentAreaContextMenu' &&
|
||||
aEvent.target == aEvent.currentTarget) {
|
||||
this.initContextMenu();
|
||||
}
|
||||
if (!this.evaluateXPath(
|
||||
'local-name() = "tooltip" or local-name() ="panel" or '+
|
||||
'parent::*/ancestor-or-self::*[local-name()="popup" or local-name()="menupopup"]',
|
||||
@ -2326,20 +2320,6 @@ catch(e) {
|
||||
).booleanValue;
|
||||
},
|
||||
|
||||
initContextMenu : function()
|
||||
{
|
||||
var item = document.getElementById('context-treestyletab-openSelectionLinks');
|
||||
var sep = document.getElementById('context-treestyletab-openSelectionLinks-separator');
|
||||
if (this.getTreePref('show.openSelectionLinks') && this.getSelectionLinks().length) {
|
||||
item.removeAttribute('hidden');
|
||||
sep.removeAttribute('hidden');
|
||||
}
|
||||
else {
|
||||
item.setAttribute('hidden', true);
|
||||
sep.setAttribute('hidden', true);
|
||||
}
|
||||
},
|
||||
|
||||
showHideSubTreeMenuItem : function(aMenuItem, aTabs)
|
||||
{
|
||||
if (!aMenuItem ||
|
||||
@ -2561,7 +2541,8 @@ catch(e) {
|
||||
}
|
||||
}, 0, this);
|
||||
},
|
||||
canCreateSubTree : function(aTabs)
|
||||
|
||||
canCreateSubTree : function(aTabs)
|
||||
{
|
||||
aTabs = this.getRootTabs(aTabs);
|
||||
if (aTabs.length < 2) return false;
|
||||
@ -2575,7 +2556,8 @@ catch(e) {
|
||||
}
|
||||
return this.getChildTabs(lastParent).length != aTabs.length;
|
||||
},
|
||||
getRootTabs : function(aTabs)
|
||||
|
||||
getRootTabs : function(aTabs)
|
||||
{
|
||||
var roots = [];
|
||||
if (!aTabs || !aTabs.length) return roots;
|
||||
@ -2587,129 +2569,7 @@ catch(e) {
|
||||
}, this);
|
||||
return roots;
|
||||
},
|
||||
|
||||
openSelectionLinks : function(aFrame)
|
||||
{
|
||||
aFrame = this.getCurrentFrame(aFrame);
|
||||
|
||||
var b = this.browser;
|
||||
var links = this.getSelectionLinks(aFrame);
|
||||
if (!links.length) return;
|
||||
|
||||
var referrer = this.makeURIFromSpec(aFrame.location.href);
|
||||
|
||||
this.readyToOpenChildTab(aFrame, true);
|
||||
links.forEach(function(aLink, aIndex) {
|
||||
var tab = b.addTab(aLink.href, referrer);
|
||||
if (aIndex == 0 && !this.getPref('browser.tabs.loadInBackground'))
|
||||
b.selectedTab = tab;
|
||||
}, this);
|
||||
this.stopToOpenChildTab(aFrame);
|
||||
},
|
||||
|
||||
getCurrentFrame : function(aFrame)
|
||||
{
|
||||
if (aFrame) return aFrame;
|
||||
var targetWindow = document.commandDispatcher.focusedWindow;
|
||||
if (!targetWindow || targetWindow.top == window)
|
||||
targetWindow = this.browser.contentWindow;
|
||||
return targetWindow;
|
||||
},
|
||||
|
||||
getSelectionLinks : function(aFrame)
|
||||
{
|
||||
aFrame = this.getCurrentFrame(aFrame);
|
||||
|
||||
var links = [];
|
||||
|
||||
var selection = aFrame.getSelection();
|
||||
if (!selection || !selection.rangeCount)
|
||||
return links;
|
||||
|
||||
for (var i = 0, maxi = selection.rangeCount; i < maxi; i++)
|
||||
{
|
||||
links = links.concat(this.getLinksInRange(selection.getRangeAt(i)));
|
||||
}
|
||||
|
||||
var visited = {};
|
||||
var uniqueLinks = [];
|
||||
links.forEach(function(aLink) {
|
||||
if (aLink.href in visited) return;
|
||||
visited[aLink.href] = true;
|
||||
uniqueLinks.push(aLink);
|
||||
});
|
||||
return uniqueLinks;
|
||||
},
|
||||
|
||||
getLinksInRange : function(aRange)
|
||||
{
|
||||
// http://nanto.asablo.jp/blog/2008/10/18/3829312
|
||||
var links = [];
|
||||
if (aRange.collapsed) return links;
|
||||
|
||||
var startCountExpression = 'count(preceding::*[@href])';
|
||||
var startNode = aRange.startContainer;
|
||||
if (startNode.nodeType == Node.ELEMENT_NODE) {
|
||||
if (aRange.startOffset < startNode.childNodes.length) {
|
||||
startNode = startNode.childNodes[aRange.startOffset];
|
||||
}
|
||||
else {
|
||||
startCountExpression += ' + count(descendant::*[@href])';
|
||||
}
|
||||
}
|
||||
var startCount = this.evaluateXPath(
|
||||
startCountExpression,
|
||||
startNode,
|
||||
XPathResult.NUMBER_TYPE
|
||||
).numberValue;
|
||||
|
||||
var linksExpression = 'ancestor::*[@href] | preceding::*[@href]';
|
||||
var endNode = aRange.endContainer;
|
||||
if (endNode.nodeType == Node.ELEMENT_NODE) {
|
||||
if (aRange.endOffset < endNode.childNodes.length) {
|
||||
endNode = endNode.childNodes[aRange.endOffset];
|
||||
}
|
||||
else {
|
||||
linksExpression += ' | descendant-or-self::*[@href]';
|
||||
}
|
||||
}
|
||||
var linksResult = this.evaluateXPath(linksExpression, endNode);
|
||||
|
||||
var allLinksCount = linksResult.snapshotLength;
|
||||
var contentRange = startNode.ownerDocument.createRange();
|
||||
if (startCount < allLinksCount) {
|
||||
var lastNode = this.evaluateXPath(
|
||||
'descendant-or-self::node()[not(child::node()) and not(following-sibling::node())]',
|
||||
linksResult.snapshotItem(startCount),
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE
|
||||
).singleNodeValue;
|
||||
contentRange.selectNodeContents(lastNode);
|
||||
contentRange.setStart(aRange.startContainer, aRange.startOffset);
|
||||
if (contentRange.collapsed) {
|
||||
startCount++;
|
||||
}
|
||||
}
|
||||
if (startCount < allLinksCount) {
|
||||
var firstNode = this.evaluateXPath(
|
||||
'descendant-or-self::node()[not(child::node()) and not(preceding-sibling::node())]',
|
||||
linksResult.snapshotItem(allLinksCount-1),
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE
|
||||
).singleNodeValue;
|
||||
contentRange.selectNodeContents(firstNode);
|
||||
contentRange.setEnd(aRange.endContainer, aRange.endOffset);
|
||||
if (contentRange.collapsed) {
|
||||
allLinksCount--;
|
||||
}
|
||||
}
|
||||
contentRange.detach();
|
||||
|
||||
for (var i = startCount; i < allLinksCount; i++)
|
||||
{
|
||||
links.push(linksResult.snapshotItem(i));
|
||||
}
|
||||
return links;
|
||||
},
|
||||
|
||||
|
||||
collapseExpandAllSubtree : function(aCollapse)
|
||||
{
|
||||
this.ObserverService.notifyObservers(
|
||||
|
@ -39,16 +39,6 @@
|
||||
]]></script>
|
||||
|
||||
|
||||
<popup id="contentAreaContextMenu">
|
||||
<menuseparator id="context-treestyletab-openSelectionLinks-separator"
|
||||
insertafter="context-sep-open"/>
|
||||
<menuitem id="context-treestyletab-openSelectionLinks"
|
||||
insertafter="context-sep-open"
|
||||
label="&context.openSelectionLinks.label;"
|
||||
accesskey="&context.openSelectionLinks.accesskey;"
|
||||
oncommand="TreeStyleTabService.openSelectionLinks();"/>
|
||||
</popup>
|
||||
|
||||
<menupopup id="multipletab-selection-menu">
|
||||
<menuitem id="multipletab-selection-item-removeTabSubTree"
|
||||
insertafter="multipletab-selection-removeTabs"
|
||||
|
@ -62,7 +62,6 @@ pref("extensions.treestyletab.twisty.expandSensitiveArea", true);
|
||||
pref("extensions.treestyletab.clickOnIndentSpaces.enabled", true);
|
||||
pref("extensions.treestyletab.tooltip.includeChildren", true);
|
||||
|
||||
pref("extensions.treestyletab.show.openSelectionLinks", true);
|
||||
pref("extensions.treestyletab.show.context-item-reloadTabSubTree", true);
|
||||
pref("extensions.treestyletab.show.context-item-reloadDescendantTabs", false);
|
||||
pref("extensions.treestyletab.show.context-item-removeTabSubTree", true);
|
||||
|
@ -152,9 +152,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "Alle Links in der Auswahl in Tabs öffnen">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "l">
|
||||
|
||||
<!ENTITY selection.removeTabSubTree.label "Ausgewählte Zweige schließen">
|
||||
<!ENTITY selection.removeTabSubTree.accesskey "s">
|
||||
<!ENTITY selection.createSubTree.label "Zweig auf oberste Ebene verschieben">
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "Menu">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "Add following items to the context menu on tabs">
|
||||
<!ENTITY config.show.openSelectionLinks "Add "Open Selection Links in Tabs" to the context menu">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "New Tabs">
|
||||
@ -152,8 +151,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "Open Selection Links in Tabs">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "l">
|
||||
<!ENTITY selection.createSubTree.label "Gather to a New Tree">
|
||||
<!ENTITY selection.createSubTree.accesskey "g">
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "Menú">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "Añadir los siguientes items al menú contextual de las pestañas">
|
||||
<!ENTITY config.show.openSelectionLinks "Añadir "Abrir selección de enlaces en pestañas" al menú contextual">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "New Tabs">
|
||||
@ -156,9 +155,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "Abrir selección de enlaces en pestañas">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "l">
|
||||
|
||||
<!ENTITY selection.removeTabSubTree.label "Cerrar árboles seleccionados">
|
||||
<!ENTITY selection.removeTabSubTree.accesskey "s">
|
||||
<!ENTITY selection.createSubTree.label "Gather to a New Tree">
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "Menu contestuale">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "Voci da aggiungere al menu contestuale delle schede">
|
||||
<!ENTITY config.show.openSelectionLinks "Aggiungi la voce "Apri collegamenti selezionati in schede" al menu contestuale">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "New Tabs">
|
||||
@ -156,9 +155,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "Apri collegamenti selezionati in schede">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "z">
|
||||
|
||||
<!ENTITY selection.removeTabSubTree.label "Chiudi i sottoalberi selezionati">
|
||||
<!ENTITY selection.removeTabSubTree.accesskey "s">
|
||||
<!ENTITY selection.createSubTree.label "Gather to a New Tree">
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "メニュー">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "タブのコンテキストメニューに以下の項目を追加する">
|
||||
<!ENTITY config.show.openSelectionLinks "コンテキストメニューに「選択したリンクをすべてタブで開く」を加える">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "新しいタブ">
|
||||
@ -151,9 +150,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "選択したリンクをすべてタブで開く">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "l">
|
||||
|
||||
<!ENTITY selection.removeTabSubTree.label "すべてのツリーを閉じる">
|
||||
<!ENTITY selection.removeTabSubTree.accesskey "s">
|
||||
<!ENTITY selection.createSubTree.label "ひとつのツリーに集める">
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "Menu">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "Wyświetlaj w menu kontekstowym kart następujące elementy:">
|
||||
<!ENTITY config.show.openSelectionLinks "Wyświetlaj w menu kontekstowym element „Otwórz zaznaczone odnośniki w kartach”">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "New Tabs">
|
||||
@ -155,9 +154,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "Otwórz wybrane odnośniki w kartach">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "O">
|
||||
|
||||
<!ENTITY selection.removeTabSubTree.label "Zamknij wybrane drzewa">
|
||||
<!ENTITY selection.removeTabSubTree.accesskey "M">
|
||||
<!ENTITY selection.createSubTree.label "Gather to a New Tree">
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "Меню">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "Добавить следующие элементы в контекстное меню вкладок">
|
||||
<!ENTITY config.show.openSelectionLinks "Добавить "Открыть выбранные ссылки во вкладках" в контекстное меню">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "New Tabs">
|
||||
@ -155,9 +154,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "Открыть выбранные ссылки во вкладках">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "l">
|
||||
|
||||
<!ENTITY selection.removeTabSubTree.label "Закрыть выбранные деревья">
|
||||
<!ENTITY selection.removeTabSubTree.accesskey "s">
|
||||
<!ENTITY selection.createSubTree.label "Gather to a New Tree">
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "菜单">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "在标签的右键菜单中添加以下项目">
|
||||
<!ENTITY config.show.openSelectionLinks "在页面右键菜单中添加“在新标签中打开选中链接”">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "新标签">
|
||||
@ -152,8 +151,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "在新标签中打开选中链接">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "l">
|
||||
<!ENTITY selection.createSubTree.label "以选中标签建立新标签树">
|
||||
<!ENTITY selection.createSubTree.accesskey "g">
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
<!ENTITY config.tabs.menu "選單">
|
||||
|
||||
<!ENTITY config.show.tabContextMenu.caption "新增以下項目到分頁的內容功能表">
|
||||
<!ENTITY config.show.openSelectionLinks "新增「用新分頁開啟所有選取的鏈結」到內容功能表">
|
||||
|
||||
|
||||
<!ENTITY config.tabs.tab "New Tabs">
|
||||
@ -153,9 +152,6 @@
|
||||
|
||||
|
||||
|
||||
<!ENTITY context.openSelectionLinks.label "用新分頁開啟所有選取的鏈結">
|
||||
<!ENTITY context.openSelectionLinks.accesskey "l">
|
||||
|
||||
<!ENTITY selection.removeTabSubTree.label "關閉所有選取的樹">
|
||||
<!ENTITY selection.removeTabSubTree.accesskey "s">
|
||||
<!ENTITY selection.createSubTree.label "收容到一新樹">
|
||||
|
@ -1,202 +0,0 @@
|
||||
var win;
|
||||
var sv;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
utils.setPref('browser.tabs.warnOnClose', false);
|
||||
|
||||
yield utils.setUpTestWindow();
|
||||
win = utils.getTestWindow();
|
||||
sv = win.TreeStyleTabService;
|
||||
|
||||
yield Do(utils.addTab('../fixtures/links.html'));
|
||||
var tabs = gBrowser.mTabs;
|
||||
gBrowser.removeAllTabsBut(tabs[tabs.length-1]);
|
||||
assert.equals(1, tabs.length);
|
||||
}
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
win = null;
|
||||
utils.tearDownTestWindow();
|
||||
}
|
||||
|
||||
function $(aId)
|
||||
{
|
||||
return content.document.getElementById(aId);
|
||||
}
|
||||
|
||||
function test_getCurrentFrame()
|
||||
{
|
||||
yield Do(utils.addTab('../fixtures/frameTest.html'));
|
||||
yield Do(utils.addTab('../fixtures/frameTestInline.html'));
|
||||
var tabs = gBrowser.mTabs;
|
||||
assert.equals(3, tabs.length);
|
||||
|
||||
var frame;
|
||||
|
||||
frame = gBrowser.contentWindow;
|
||||
assert.equals(frame, sv.getCurrentFrame());
|
||||
assert.equals(frame, sv.getCurrentFrame(frame));
|
||||
|
||||
frame = tabs[1].linkedBrowser.contentWindow.frames[1];
|
||||
assert.equals(frame, sv.getCurrentFrame(frame));
|
||||
|
||||
frame = tabs[2].linkedBrowser.contentWindow.frames[0];
|
||||
assert.equals(frame, sv.getCurrentFrame(frame));
|
||||
}
|
||||
|
||||
function test_getLinksInRange()
|
||||
{
|
||||
var range = content.document.createRange();
|
||||
|
||||
range.setStartBefore($('item2'));
|
||||
range.setEndAfter($('item4'));
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4')],
|
||||
sv.getLinksInRange(range)
|
||||
);
|
||||
|
||||
range.setStartBefore($('link2'));
|
||||
range.setEndAfter($('link4'));
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4')],
|
||||
sv.getLinksInRange(range)
|
||||
);
|
||||
|
||||
range.setStartBefore($('em2'));
|
||||
range.setEndAfter($('em4'));
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4')],
|
||||
sv.getLinksInRange(range)
|
||||
);
|
||||
|
||||
range.setStart($('em2').firstChild, 2);
|
||||
range.setEnd($('em4').firstChild, 2);
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4')],
|
||||
sv.getLinksInRange(range)
|
||||
);
|
||||
|
||||
range.setStartAfter($('em1'));
|
||||
range.setEndBefore($('em5'));
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4')],
|
||||
sv.getLinksInRange(range)
|
||||
);
|
||||
|
||||
range.setStartAfter($('em1').firstChild);
|
||||
range.setEndBefore($('em5').firstChild);
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4')],
|
||||
sv.getLinksInRange(range)
|
||||
);
|
||||
}
|
||||
|
||||
function test_getSelectionLinks()
|
||||
{
|
||||
var selection = content.getSelection();
|
||||
assert.equals(0, selection.rangeCount);
|
||||
|
||||
var range1 = content.document.createRange();
|
||||
range1.setStartBefore($('link2'));
|
||||
range1.setEndAfter($('link4'));
|
||||
selection.addRange(range1);
|
||||
|
||||
assert.equals(1, selection.rangeCount);
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4')],
|
||||
sv.getSelectionLinks(content)
|
||||
);
|
||||
|
||||
var range2 = content.document.createRange();
|
||||
range2.setStartBefore($('link6'));
|
||||
range2.setEndAfter($('link8'));
|
||||
selection.addRange(range2);
|
||||
|
||||
var range3 = content.document.createRange();
|
||||
range3.setStartBefore($('link12'));
|
||||
range3.setEndAfter($('link14'));
|
||||
selection.addRange(range3);
|
||||
|
||||
assert.equals(3, selection.rangeCount);
|
||||
assert.equals(
|
||||
[$('link2'), $('link3'), $('link4'),
|
||||
$('link6'), $('link7'), $('link8'),
|
||||
$('link12'), $('link13'), $('link14')],
|
||||
sv.getSelectionLinks(content)
|
||||
);
|
||||
|
||||
selection.removeAllRanges();
|
||||
range1.detach();
|
||||
range2.detach();
|
||||
range3.detach();
|
||||
}
|
||||
|
||||
function test_openSelectionLinks()
|
||||
{
|
||||
function assert_openSelectionLinksInFrame(aFrame)
|
||||
{
|
||||
function $(aId)
|
||||
{
|
||||
return aFrame.document.getElementById(aId);
|
||||
}
|
||||
|
||||
gBrowser.removeAllTabsBut(gBrowser.selectedTab);
|
||||
assert.equals(1, gBrowser.mTabs.length);
|
||||
|
||||
var selection = aFrame.getSelection();
|
||||
assert.equals(0, selection.rangeCount);
|
||||
|
||||
var range1 = aFrame.document.createRange();
|
||||
range1.setStartBefore($('link2'));
|
||||
range1.setEndAfter($('link4'));
|
||||
selection.addRange(range1);
|
||||
assert.equals(1, selection.rangeCount);
|
||||
|
||||
var tabs = gBrowser.mTabs;
|
||||
assert.equals(1, tabs.length);
|
||||
|
||||
sv.openSelectionLinks(aFrame);
|
||||
assert.equals(4, tabs.length);
|
||||
assert.equals(
|
||||
[tabs[1], tabs[2], tabs[3]],
|
||||
sv.getChildTabs(tabs[0])
|
||||
);
|
||||
|
||||
gBrowser.removeAllTabsBut(tabs[0]);
|
||||
assert.equals(1, tabs.length);
|
||||
|
||||
var range2 = aFrame.document.createRange();
|
||||
range2.setStartBefore($('link6'));
|
||||
range2.setEndAfter($('link8'));
|
||||
selection.addRange(range2);
|
||||
|
||||
var range3 = aFrame.document.createRange();
|
||||
range3.setStartBefore($('link12'));
|
||||
range3.setEndAfter($('link14'));
|
||||
selection.addRange(range3);
|
||||
|
||||
sv.openSelectionLinks(aFrame);
|
||||
assert.equals(10, tabs.length);
|
||||
assert.equals(
|
||||
[tabs[1], tabs[2], tabs[3],
|
||||
tabs[4], tabs[5], tabs[6],
|
||||
tabs[7], tabs[8], tabs[9]],
|
||||
sv.getChildTabs(tabs[0])
|
||||
);
|
||||
|
||||
selection.removeAllRanges();
|
||||
range1.detach();
|
||||
range2.detach();
|
||||
range3.detach();
|
||||
}
|
||||
|
||||
assert_openSelectionLinksInFrame(content);
|
||||
|
||||
yield Do(utils.addTab('../fixtures/frameTest.html', { selected : true }));
|
||||
assert_openSelectionLinksInFrame(content.frames[2]);
|
||||
|
||||
yield Do(utils.addTab('../fixtures/frameTestInline.html', { selected : true }));
|
||||
assert_openSelectionLinksInFrame(content.frames[1]);
|
||||
}
|
Loading…
Reference in New Issue
Block a user