Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Bug 885221 - Page hide event does not update window status if persist…
Browse files Browse the repository at this point in the history
…ed is true. r=hskupin
  • Loading branch information
cosmin-malutan authored and whimboo committed Sep 19, 2013
1 parent 2f85a34 commit 05f859f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
22 changes: 10 additions & 12 deletions mozmill/mozmill/extension/resource/modules/windows.js
Expand Up @@ -228,20 +228,18 @@ function attachEventListeners(aWindow) {
};

var pageHideHandler = function (aEvent) {
// If event.persisted is false, the beforeUnloadHandler should fire
// and there is no need for this event handler.
if (aEvent.persisted) {
var doc = aEvent.originalTarget;

// Only update the flag if we have a document as target
if ("defaultView" in doc) {
var id = utils.getWindowId(doc.defaultView);
// dump("*** 'pagehide' event: id=" + id + ", baseURI=" + doc.baseURI + "\n");
map.updatePageLoadStatus(id, false);
}
var doc = aEvent.originalTarget;

aWindow.removeEventListener("beforeunload", beforeUnloadHandler, true);
// Only update the flag if we have a document as target
if ("defaultView" in doc) {
var id = utils.getWindowId(doc.defaultView);
// dump("*** 'pagehide' event: id=" + id + ", baseURI=" + doc.baseURI + "\n");
map.updatePageLoadStatus(id, false);
}
// If event.persisted is true the beforeUnloadHandler would never fire
// and we have to remove the event handler here to avoid memory leaks.
if (aEvent.persisted)
aWindow.removeEventListener("beforeunload", beforeUnloadHandler, true);
};

var onWindowLoaded = function (aEvent) {
Expand Down
15 changes: 15 additions & 0 deletions mutt/mutt/tests/data/no_bfcache.html
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" >
function unloadHandler() {
window.removeEventListener('unload', unloadHandler, false);
};
window.addEventListener('unload', unloadHandler, false);
</script>
<title>Page not Back-Forward Cached</title>
</head>
<body>
<h1>Page not Back-Forward Cached</h1>
</body>
</html>
1 change: 1 addition & 0 deletions mutt/mutt/tests/js/testUtils/manifest.ini
Expand Up @@ -3,4 +3,5 @@ type = javascript

[testPageLoad.js]
[testPageLoadBfCache.js]
[testReloadPage.js]
[testSaveScreenshot.js]
34 changes: 34 additions & 0 deletions mutt/mutt/tests/js/testUtils/testReloadPage.js
@@ -0,0 +1,34 @@
/* 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";

const BASE_URL = collector.addHttpResource("../../data/");
const TEST_DATA = [
BASE_URL + "link.html",
BASE_URL + "no_bfcache.html",
"about:blank",
"about:blocked",
"about:addons",
"about:config",
"about:newtab"
];

var setupModule = function (aModule) {
aModule.controller = mozmill.getBrowserController();
}

var testReloadPageAfterTabChange = function () {
TEST_DATA.forEach(function (aUrl) {
controller.open(aUrl);
controller.waitForPageLoad();

// Open a new tab and close it
controller.mainMenu.click("#menu_newNavigatorTab");
controller.mainMenu.click("#menu_close");

controller.open(aUrl);
controller.waitForPageLoad();
});
}

0 comments on commit 05f859f

Please sign in to comment.