File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,15 +116,28 @@ var TabGuard = (() => {
116116 tab . _externalUrl = tab . url ;
117117 tab . _isExplicitOrigin = true ;
118118 try {
119- tab . url = await browser . tabs . executeScript ( tab . id , {
119+ tab . url = await browser . tabs . executeScript ( tab . id , {
120120 runAt : "document_start" ,
121121 code : "window.origin === 'null' ? window.location.href : window.origin"
122122 } ) ;
123123 } catch ( e ) {
124+ // We don't have permissions to run in this tab, probably because it has been left empty.
124125 debug ( e ) ;
125126 }
126- debug ( `Real origin for ${ tab . _externalUrl } (tab ${ tab . id } ) is ${ tab . url } .` ) ;
127- if ( ! ns . policy . can ( tab . url , "script" ) ) return ;
127+ // If it's about:blank and it has got an opener, let's assume the opener
128+ // is the real origin and it's using the empty tab to run scripts.
129+ if ( tab . url === "about:blank" ) {
130+ if ( tab . openerTabId > 0 ) {
131+ let openerTab = TabCache . get ( tab . openerTabId ) ;
132+ if ( openerTab ) {
133+ tab . url = openerTab . url ;
134+ }
135+ }
136+ }
137+ if ( tab . url !== "about:blank" ) {
138+ debug ( `Real origin for ${ tab . _externalUrl } (tab ${ tab . id } ) is ${ tab . url } .` ) ;
139+ if ( ! ns . policy . can ( tab . url , "script" ) ) return ;
140+ }
128141 }
129142 suspiciousDomains . push ( getDomain ( tab . url ) ) ;
130143 } ) ) ;
You can’t perform that action at this time.
0 commit comments