Bug 673104 - Use ES5 strict mode for Panorama; r=dao

This commit is contained in:
Tim Taubert 2011-07-23 17:07:39 +02:00
parent cc196f79ad
commit 2f0418164f
13 changed files with 39 additions and 36 deletions

View File

@ -35,6 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
"use strict";
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
@ -164,8 +166,8 @@ function tabEventListener(event) {
function observer(subject, topic, data) {
switch (topic) {
case "domwindowopened":
subject.addEventListener("load", function() {
subject.removeEventListener("load", arguments.callee, false);
subject.addEventListener("load", function onLoad() {
subject.removeEventListener("load", onLoad, false);
// Now that the window has loaded, only register on browser windows
let doc = subject.document.documentElement;

View File

@ -45,6 +45,8 @@
*
* ***** END LICENSE BLOCK ***** */
"use strict";
// **********
// Title: utils.js
@ -369,10 +371,11 @@ Range.prototype = {
// little graph. It goes from near 0 at x=0 to near 1 at x=1
// smoothly and beautifully.
// http://www.wolframalpha.com/input/?i=.5+%2B+.5+*+tanh%28%284+*+x%29+-+2%29
function tanh(x) {
let tanh = function tanh(x) {
var e = Math.exp(x);
return (e - 1/e) / (e + 1/e);
}
};
return .5 - .5 * tanh(2 - 4 * proportion);
}

View File

@ -585,8 +585,7 @@ function ensureSearchShown(activatedByKeypress) {
// NOTE: when this function is called by keydown handler, next keypress
// event or composition events of IME will be fired on the focused editor.
function dispatchTabViewSearchEnabledEvent() {
let dispatchTabViewSearchEnabledEvent = function dispatchTabViewSearchEnabledEvent() {
let newEvent = document.createEvent("Events");
newEvent.initEvent("tabviewsearchenabled", false, false);
dispatchEvent(newEvent);
@ -595,7 +594,7 @@ function ensureSearchShown(activatedByKeypress) {
if (activatedByKeypress) {
// set the focus so key strokes are entered into the textbox.
$searchbox[0].focus();
dispatchTabViewSearchEnabledEvent();
dispatchTabViewSearchEnabledEvent();
} else {
// marshal the focusing, otherwise it ends up with searchbox[0].focus gets
// called before the search button gets the focus after being pressed.

View File

@ -482,6 +482,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// closing tab doesn't belong to a group and no empty group, create a new
// one for the new tab.
if (!groupClose && gBrowser.tabs.length == 1) {
let group;
if (this.tab._tabViewTabItem.parent) {
group = this.tab._tabViewTabItem.parent;
} else {

View File

@ -1,3 +1,5 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;

View File

@ -105,8 +105,8 @@ let ThumbnailStorage = {
};
if (browser.contentDocument.readyState != "complete" ||
browser.webProgress.isLoadingDocument) {
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
checkAndAddToList(browser);
}, true);
} else {

View File

@ -861,8 +861,8 @@ let UI = {
if (this.restoredClosedTab) {
// when the tab view UI is being displayed, update the thumb for the
// restored closed tab after the page load
tab.linkedBrowser.addEventListener("load", function (event) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
tab.linkedBrowser.addEventListener("load", function onLoad(event) {
tab.linkedBrowser.removeEventListener("load", onLoad, true);
TabItems._update(tab);
}, true);
}

View File

@ -71,12 +71,12 @@ function part2(win) {
// switch the selected tab to new tab
win.gBrowser.selectedTab = newTab;
win.addEventListener("tabviewhidden", function () {
win.removeEventListener("tabviewhidden", arguments.callee, false);
whenTabViewIsHidden(function () {
is(win.gBrowser.selectedTab, newTab, "The seleted tab should be the same as before (new tab)");
win.close();
finish();
}, false);
});
// show tabview
EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, win);
// hide tabview

View File

@ -9,8 +9,8 @@ function test() {
// open a new window and setup the window state.
newWin = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
newWin.addEventListener("load", function(event) {
this.removeEventListener("load", arguments.callee, false);
newWin.addEventListener("load", function onLoad(event) {
this.removeEventListener("load", onLoad, false);
let newState = {
windows: [{

View File

@ -55,8 +55,8 @@ function onTabViewWindowLoaded(win, tab) {
contentWindow.performSearch();
// prepare to finish when the main window gets focus back
window.addEventListener('focus', function () {
window.removeEventListener('focus', arguments.callee, true);
window.addEventListener('focus', function onFocus() {
window.removeEventListener('focus', onFocus, true);
assertSearchIsDisabled();
// check that the right tab is active

View File

@ -11,12 +11,10 @@ function onTabViewShown(win) {
let contentWindow = win.TabView.getContentWindow();
let finishTest = function () {
win.addEventListener('tabviewhidden', function () {
win.removeEventListener('tabviewhidden', arguments.callee, false);
hideTabView(function () {
win.close();
finish();
}, false);
win.TabView.hide();
}, win);
}
// do not let the group arrange itself

View File

@ -8,16 +8,14 @@ function test() {
let windowOne = openDialog(location, "", "chrome,all,dialog=no", "data:text/html,");
let windowTwo;
windowOne.addEventListener("load", function() {
windowOne.removeEventListener("load", arguments.callee, false);
windowOne.gBrowser.selectedBrowser.addEventListener("load", function() {
windowOne.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
whenWindowLoaded(windowOne, function () {
windowOne.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
windowOne.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
windowTwo = openDialog(location, "", "chrome,all,dialog=no", "http://mochi.test:8888/");
windowTwo.addEventListener("load", function() {
windowTwo.removeEventListener("load", arguments.callee, false);
windowTwo.gBrowser.selectedBrowser.addEventListener("load", function() {
windowTwo.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
whenWindowLoaded(windowTwo, function () {
windowTwo.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
windowTwo.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
newWindows = [ windowOne, windowTwo ];
@ -26,9 +24,9 @@ function test() {
ok(!TabView.isVisible(), "Tab View is hidden");
TabView.toggle();
}, true);
}, false);
});
}, true);
}, false);
});
}
function onTabViewWindowLoaded() {

View File

@ -168,8 +168,8 @@ function whenTabViewIsHidden(callback, win) {
return;
}
win.addEventListener('tabviewhidden', function () {
win.removeEventListener('tabviewhidden', arguments.callee, false);
win.addEventListener('tabviewhidden', function onHidden() {
win.removeEventListener('tabviewhidden', onHidden, false);
callback();
}, false);
}
@ -183,8 +183,8 @@ function whenTabViewIsShown(callback, win) {
return;
}
win.addEventListener('tabviewshown', function () {
win.removeEventListener('tabviewshown', arguments.callee, false);
win.addEventListener('tabviewshown', function onShown() {
win.removeEventListener('tabviewshown', onShown, false);
callback();
}, false);
}