run-url-selection-operation-limit.tentative.https.sub.html (1838B)
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 const perOriginBitLimit = 3; 16 const numUrls = 8; 17 const urls = generateUrls(numUrls, "/shared-storage/resources/frame", 18 [ancestorKey]); 19 const bitsPerCall = Math.log2(numUrls); 20 21 await sharedStorage.worklet.addModule( 22 "/shared-storage/resources/simple-module.js"); 23 24 25 for (let i = 0; i < Math.floor(perOriginBitLimit / bitsPerCall); ++i) { 26 let config = await sharedStorage.selectURL( 27 "test-url-selection-operation", urls, 28 {data: {'mockResult': 1}, keepAlive: true, resolveToConfig: true}); 29 assert_true(config instanceof FencedFrameConfig); 30 attachFencedFrame(config, 'opaque-ads'); 31 const result = await nextValueFromServer(ancestorKey); 32 assert_equals(result, "frame1_loaded", 33 `for index ${i} when budget should remain;`); 34 } 35 36 // The per-origin per-pageload bit limit for `selectURL()` has been 37 // reached. The next call should return the default URL. 38 let config = await sharedStorage.selectURL( 39 "test-url-selection-operation", urls, 40 {data: {'mockResult': 1}, resolveToConfig: true}); 41 assert_true(config instanceof FencedFrameConfig); 42 attachFencedFrame(config, 'opaque-ads'); 43 const result = await nextValueFromServer(ancestorKey); 44 assert_equals(result, "frame0_loaded", 'when budget should be exhausted;'); 45 46 }, 'selectURL() with per-origin per-pageload limit'); 47 </script> 48 </body>