forked from alice0775/userChrome.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patchForBug492358.uc.js
43 lines (41 loc) · 1.43 KB
/
patchForBug492358.uc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ==UserScript==
// @name patchForBug492358.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Bug 492358 - Loads triggered on unload incorrectly counted against next load's security state
// @author Alice0775
// @include main
// @compatibility 10-
// @version 2012/02/01
// ==/UserScript==
var patchForBug492358 = {
init: function(){
window.addEventListener('unload', this.uninit, false);
gBrowser.addEventListener('unload', this.unload, true);
},
uninit: function(){
window.removeEventListener('unload', this.uninit, false);
gBrowser.removeEventListener('unload', this.unload, true);
},
unload: function(event){
if (event.originalTarget instanceof HTMLDocument) {
var win = event.originalTarget.defaultView;
if (win.frameElement) {
// Frame within a tab was loaded. win should be the top window of
// the frameset. If you don't want do anything when frames/iframes
// are loaded in this web page, uncomment the following line:
return;
// Find the root document:
win = win.top;
}
var aTab = gBrowser._getTabForContentWindow(win);
if (!aTab )
return;
if (aTab.hasAttribute('busy') ||
aTab.hasAttribute('progless') ||
aTab.linkedBrowser.docShell.busyFlags) {
event.stopPropagation();
}
}
}
}
patchForBug492358.init();