Permalink
Browse files

Merge pull request #585 from erikvold/793055

Fix Bug 793055 addon-page tests now pass on fennec r=@gozala
  • Loading branch information...
2 parents b58d016 + cd0b11c commit af174a326d7caec6230531f01e040794651cabc8 @erikvold erikvold committed Oct 6, 2012
@@ -28,6 +28,7 @@ and `cfx xpi` when targeting Firefox Mobile.
Right now only the following modules are fully functional:
+* [addon-page](packages/addon-kit/addon-page.html)
* [page-mod](packages/addon-kit/page-mod.html)
* [page-worker](packages/addon-kit/page-worker.html)
* [passwords](packages/addon-kit/passwords.html)
@@ -13,6 +13,8 @@ such as a guide to using your add-on, in a browser tab.
You can supply the content in an HTML file in your add-on's
"data" directory.
+***Note:*** This module has no effect on Fennec.
+
For pages like this, navigational elements such as the
[Awesome Bar](http://support.mozilla.org/en-US/kb/Location%20bar%20autocomplete),
[Search Bar](http://support.mozilla.org/en-US/kb/Search%20bar), or
@@ -1,15 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
'use strict';
module.metadata = {
- "stability": "experimental"
+ 'stability': 'experimental'
};
const { WindowTracker } = require('api-utils/window-utils');
-const { isBrowser } = require('api-utils/window/utils');
+const { isXULBrowser } = require('api-utils/window/utils');
const { add, remove } = require('api-utils/array');
const { getTabs, closeTab, getURI } = require('api-utils/tabs/utils');
const { data } = require('self');
@@ -18,18 +17,22 @@ const addonURL = data.url('index.html');
WindowTracker({
onTrack: function onTrack(window) {
- if (isBrowser(window))
+ if (isXULBrowser(window))
add(window.XULBrowserWindow.inContentWhitelist, addonURL);
},
onUntrack: function onUntrack(window) {
- if (isBrowser(window))
- getTabs(window).
- filter(function(tab) { return getURI(tab) === addonURL; }).
- forEach(function(tab) {
- // Note: `onUntrack` will be called for all windows on add-on unloads,
- // so we want to clean them up from these URLs.
- remove(window.XULBrowserWindow.inContentWhitelist, addonURL);
- closeTab(tab);
- });
+ if (isXULBrowser(window))
+ getTabs(window).filter(tabFilter).forEach(untrackTab.bind(null, window));
}
});
+
+function tabFilter(tab) {
+ return getURI(tab) === addonURL;
+}
+
+function untrackTab(window, tab) {
+ // Note: `onUntrack` will be called for all windows on add-on unloads,
+ // so we want to clean them up from these URLs.
+ remove(window.XULBrowserWindow.inContentWhitelist, addonURL);
+ closeTab(tab);
+}
@@ -8,11 +8,15 @@ const { isTabOpen, activateTab, openTab, closeTab, getURI } = require('api-utils
const windows = require('api-utils/window-utils');
const { Loader } = require('test-harness/loader');
const { setTimeout } = require('api-utils/timer');
+const { is } = require('api-utils/xul-app');
+const tabs = require('tabs');
let uri = require('self').data.url('index.html');
-function isChromeVisible(window)
- window.document.documentElement.getAttribute('disablechrome') !== 'true'
+function isChromeVisible(window) {
+ let x = window.document.documentElement.getAttribute('disablechrome')
+ return x !== 'true';
+}
exports['test that add-on page has no chrome'] = function(assert, done) {
let loader = Loader(module);
@@ -28,7 +32,7 @@ exports['test that add-on page has no chrome'] = function(assert, done) {
setTimeout(function() {
activateTab(tab);
- assert.ok(!isChromeVisible(window), 'chrome is not visible for addon page');
+ assert.equal(isChromeVisible(window), is('Fennec'), 'chrome is not visible for addon page');
closeTab(tab);
assert.ok(isChromeVisible(window), 'chrome is visible again');
@@ -41,20 +45,19 @@ exports['test that add-on pages are closed on unload'] = function(assert, done)
let loader = Loader(module);
loader.require('addon-kit/addon-page');
- let tab = openTab(windows.activeBrowserWindow, uri);
-
// Wait for addon page document to be loaded
- tab.addEventListener("load", function listener() {
+ tabs.once("ready", function listener(tab) {
// Ignore loading of about:blank document
- if (getURI(tab) != uri)
+ if (tab.url != uri)
return;
- tab.removeEventListener("load", listener, false);
loader.unload();
assert.ok(!isTabOpen(tab), 'add-on page tabs are closed on unload');
done();
}, false);
+
+ tabs.open(uri);
};
@@ -92,7 +92,8 @@ function openTab(window, url, options) {
exports.openTab = openTab;
function isTabOpen(tab) {
- return !!tab.linkedBrowser;
+ // try normal case then fennec case
+ return !!((tab.linkedBrowser) || getWindowHoldingTab(tab));
}
exports.isTabOpen = isTabOpen;
@@ -191,3 +191,8 @@ function getWindowTitle(window) {
return window && window.document ? window.document.title : null;
}
exports.getWindowTitle = getWindowTitle;
+
+function isXULBrowser(window) {
+ return !!(isBrowser(window) && window.XULBrowserWindow);
+}
+exports.isXULBrowser = isXULBrowser;

0 comments on commit af174a3

Please sign in to comment.