Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug 682681 tab.title should never be empty #492

Merged
merged 5 commits into from

3 participants

@erikvold
Owner

update to #236

packages/api-utils/lib/tabs/tab.js
@@ -101,8 +101,8 @@ const TabTrait = Trait.compose(EventEmitter, {
* Changing this property changes an actual title.
* @type {String}
*/
- get title() this._contentDocument.title,
- set title(value) this._contentDocument.title = String(value),
+ get title() this._contentDocument.title || this._tab.label,
+ set title(value) this._tab.label = String(value),
@Gozala Owner
Gozala added a note

Could you please add getTabTitle(tab) function to tab/utils and use that from here ?

P.S.: tab is actual tab node not trait or something alike.

@erikvold Owner

k got it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Gozala Gozala merged commit 3ac1e78 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 1, 2011
  1. @autonome

    bug 682681 - tab.title should never be empty (use xul tab label inste…

    autonome authored
    …ad of content document title, also makes e10s compat)
Commits on Jul 13, 2012
  1. @erikvold
  2. @erikvold

    adding tests for bug 682681

    erikvold authored
  3. @erikvold
Commits on Jul 14, 2012
  1. @erikvold
This page is out of date. Refresh to see the latest.
View
2  packages/addon-kit/docs/tabs.md
@@ -171,7 +171,7 @@ passed the `Tab` object that triggered the event.
<api name="title">
@property {string}
-The title of the page currently loaded in the tab.
+The title of the tab (usually the title of the page currently loaded in the tab)
This property can be set to change the tab title.
</api>
View
48 packages/addon-kit/tests/test-tabs.js
@@ -29,6 +29,54 @@ exports.testActiveTab_getter = function(test) {
});
};
+// Bug 682681 - tab.title should never be empty
+exports.testBug682681_aboutURI = function(test) {
+ test.waitUntilDone();
+
+ openBrowserWindow(function(window, browser) {
+ let tabs = require("tabs");
+
+ tabs.on('ready', function onReady(tab) {
+ tabs.removeListener('ready', onReady);
+
+ test.assertEqual(tab.title, "New Tab", "title of about: tab is not blank");
+
+ // end of test
+ closeBrowserWindow(window, function() test.done());
+ });
+
+ // open a about: url
+ tabs.open({
+ url: "about:blank",
+ inBackground: true
+ });
+ });
+};
+
+// related to Bug 682681
+exports.testTitleForDataURI = function(test) {
+ test.waitUntilDone();
+
+ openBrowserWindow(function(window, browser) {
+ let tabs = require("tabs");
+
+ tabs.on('ready', function onReady(tab) {
+ tabs.removeListener('ready', onReady);
+
+ test.assertEqual(tab.title, "tab", "data: title is not Connecting...");
+
+ // end of test
+ closeBrowserWindow(window, function() test.done());
+ });
+
+ // open a about: url
+ tabs.open({
+ url: "data:text/html;charset=utf-8,<title>tab</title>",
+ inBackground: true
+ });
+ });
+};
+
// test 'BrowserWindow' instance creation on tab 'activate' event
// See bug 648244: there was a infinite loop.
exports.testBrowserWindowCreationOnActivate = function(test) {
View
14 packages/api-utils/lib/tabs/tab.js
@@ -11,7 +11,11 @@ const { defer } = require("../functional");
const { EVENTS } = require("./events");
const { getThumbnailURIForWindow } = require("../utils/thumbnail");
const { getFaviconURIForLocation } = require("../utils/data");
-
+const {
+ getOwnerWindow,
+ getBrowserForTab,
+ getTabTitle
+} = require("./utils");
// Array of the inner instances of all the wrapped tabs.
@@ -82,11 +86,11 @@ const TabTrait = Trait.compose(EventEmitter, {
/**
* Browser DOM element where page of this tab is currently loaded.
*/
- get _browser() this._window.gBrowser.getBrowserForTab(this._tab),
+ get _browser() getBrowserForTab(this._tab),
/**
* Window DOM element containing this tab.
*/
- get _window() this._tab.ownerDocument.defaultView,
+ get _window() getOwnerWindow(this._tab),
/**
* Document object of the page that is currently loaded in this tab.
*/
@@ -101,8 +105,8 @@ const TabTrait = Trait.compose(EventEmitter, {
* Changing this property changes an actual title.
* @type {String}
*/
- get title() this._contentDocument.title,
- set title(value) this._contentDocument.title = String(value),
+ get title() getTabTitle(this._tab),
+ set title(value) this._tab.label = String(value),
/**
* Location of the page currently loaded in this tab.
* Changing this property will loads page under under the specified location.
View
19 packages/api-utils/lib/tabs/utils.js
@@ -49,12 +49,12 @@ function isTabOpen(tab) {
exports.isTabOpen = isTabOpen;
function closeTab(tab) {
- return getOwnerWindow(tab).gBrowser.removeTab(tab);
+ return getGBrowserForTab(tab).removeTab(tab);
}
exports.closeTab = closeTab;
function activateTab(tab) {
- getOwnerWindow(tab).gBrowser.selectedTab = tab;
+ getGBrowserForTab(tab).selectedTab = tab;
}
exports.activateTab = activateTab;
@@ -62,3 +62,18 @@ function getURI(tab) {
return tab.linkedBrowser.currentURI.spec;
}
exports.getURI = getURI;
+
+function getGBrowserForTab(tab) {
+ return getOwnerWindow(tab).gBrowser;
+}
+exports.getGBrowserForTab = getGBrowserForTab;
+
+function getBrowserForTab(tab) {
+ return getGBrowserForTab(tab).getBrowserForTab(tab);
+}
+exports.getBrowserForTab = getBrowserForTab;
+
+function getTabTitle(tab) {
+ return getBrowserForTab(tab).contentDocument.title || tab.label;
+}
+exports.getTabTitle = getTabTitle;
Something went wrong with that request. Please try again.