select-url-saved-query-different-operation.tentative.https.sub.html (2077B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/common/utils.js"></script> 5 <script src="/shared-storage-selecturl-limit/resources/utils.js"></script> 6 <script src="/shared-storage/resources/util.js"></script> 7 <script src="/fenced-frame/resources/utils.js"></script> 8 9 <body> 10 <script> 11 'use strict'; 12 13 promise_test(async () => { 14 const ancestorKey = token(); 15 16 // Note that we have set the site page bit limit to 3 and the overall page 17 // bit limit to 6. A single saved query with 8 URLs (i.e. log2(8) = 3 bits) 18 // will be permitted by the site's page budget, plus re-uses of the saved 19 // query. 20 const numUrls = 8; 21 const urls = generateUrls(numUrls, "/shared-storage/resources/frame", 22 [ancestorKey]); 23 24 await sharedStorage.worklet.addModule( 25 "/shared-storage/resources/simple-module.js"); 26 27 let config = await sharedStorage.selectURL( 28 "test-url-selection-operation", urls, 29 {data: {'mockResult': 1}, keepAlive: true, resolveToConfig: true, 30 savedQuery: "query"}); 31 assert_true(config instanceof FencedFrameConfig); 32 attachFencedFrame(config, 'opaque-ads'); 33 const result = await nextValueFromServer(ancestorKey); 34 assert_equals(result, "frame1_loaded", 35 `when budget should remain;`); 36 37 // The per-site per-pageload bit limit for `selectURL()` has been 38 // reached. No previously saved query can be retrieved for operation 39 // "test-url-selection-operation-2". The following call should return 40 // the default URL. 41 let config1 = await sharedStorage.selectURL( 42 "test-url-selection-operation-2", urls, 43 {data: {'mockResult': 2}, resolveToConfig: true, savedQuery: "query"}); 44 assert_true(config1 instanceof FencedFrameConfig); 45 attachFencedFrame(config1, 'opaque-ads'); 46 const result1 = await nextValueFromServer(ancestorKey); 47 assert_equals(result1, "frame0_loaded", 'when budget should be exhausted;'); 48 }, 'selectURL() saved query not reused across different operations'); 49 </script> 50 </body>