@@ -271,11 +271,7 @@ const cacheService = Cc[
271
271
"@mozilla.org/netwerk/cache-storage-service;1"
272
272
] . getService ( nsICacheStorageService ) ;
273
273
274
- var loadContextInfo = Services . loadContextInfo . fromLoadContext (
275
- window . docShell . QueryInterface ( Ci . nsILoadContext ) ,
276
- false
277
- ) ;
278
- var diskStorage = cacheService . diskCacheStorage ( loadContextInfo ) ;
274
+ var diskStorage = null ;
279
275
280
276
const nsICookiePermission = Ci . nsICookiePermission ;
281
277
@@ -464,6 +460,20 @@ async function loadTab(args) {
464
460
let browsingContext = args ?. browsingContext ;
465
461
let browser = args ?. browser ;
466
462
463
+ // Check if diskStorage has not be created yet if it has not been, get
464
+ // partitionKey from content process and create diskStorage with said partitionKey
465
+ if ( ! diskStorage ) {
466
+ let oaWithPartitionKey = await getOaWithPartitionKey (
467
+ browsingContext ,
468
+ browser
469
+ ) ;
470
+ let loadContextInfo = Services . loadContextInfo . custom (
471
+ false ,
472
+ oaWithPartitionKey
473
+ ) ;
474
+ diskStorage = cacheService . diskCacheStorage ( loadContextInfo ) ;
475
+ }
476
+
467
477
/* Load the page info */
468
478
await loadPageInfo ( browsingContext , imageElement , browser ) ;
469
479
@@ -1170,3 +1180,16 @@ function checkProtocol(img) {
1170
1180
/ ^ ( h t t p s ? | f i l e | a b o u t | c h r o m e | r e s o u r c e ) : / . test ( url )
1171
1181
) ;
1172
1182
}
1183
+
1184
+ async function getOaWithPartitionKey ( browsingContext , browser ) {
1185
+ browser = browser || window . opener . gBrowser . selectedBrowser ;
1186
+ browsingContext = browsingContext || browser . browsingContext ;
1187
+
1188
+ let actor = browsingContext . currentWindowGlobal . getActor ( "PageInfo" ) ;
1189
+ let partitionKeyFromChild = await actor . sendQuery ( "PageInfo:getPartitionKey" ) ;
1190
+
1191
+ let oa = browser . contentPrincipal . originAttributes ;
1192
+ oa . partitionKey = partitionKeyFromChild . partitionKey ;
1193
+
1194
+ return oa ;
1195
+ }
0 commit comments