select-url-keep-alive.tentative.https.sub.html (2175B)
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/resources/util.js"></script> 6 <script src="/fenced-frame/resources/utils.js"></script> 7 8 <body> 9 <script> 10 'use strict'; 11 12 promise_test(async () => { 13 const ancestor_key = token(); 14 let url0 = generateURL("/shared-storage/resources/frame0.html", 15 [ancestor_key]); 16 let url1 = generateURL("/shared-storage/resources/frame1.html", 17 [ancestor_key]); 18 19 await addModuleOnce("/shared-storage/resources/simple-module.js"); 20 21 let select_url_result0 = await sharedStorage.selectURL( 22 "test-url-selection-operation", [{url: url0}, {url: url1}], 23 {data: {'mockResult': 0}, resolveToConfig: true, keepAlive: true}); 24 assert_true(validateSelectURLResult(select_url_result0, true)); 25 attachFencedFrame(select_url_result0, 'opaque-ads'); 26 const result0 = await nextValueFromServer(ancestor_key); 27 assert_equals(result0, "frame0_loaded"); 28 29 let select_url_result1 = await sharedStorage.selectURL( 30 "test-url-selection-operation", [{url: url0}, {url: url1}], 31 {data: {'mockResult': 1}, resolveToConfig: true, keepAlive: false}); 32 assert_true(validateSelectURLResult(select_url_result1, true)); 33 attachFencedFrame(select_url_result1, 'opaque-ads'); 34 const result1 = await nextValueFromServer(ancestor_key); 35 assert_equals(result1, "frame1_loaded"); 36 37 try { 38 let select_url_result2 = await sharedStorage.selectURL( 39 "test-url-selection-operation", [{url: url0}, {url: url1}], 40 {data: {'mockResult': 0}, resolveToConfig: true}); 41 } catch (e) { 42 assert_equals(e.name, 'OperationError'); 43 assert_equals(e.message, 'The sharedStorage worklet cannot execute' + 44 ' further operations because the previous' + 45 ' operation did not include the option' + 46 ' \'keepAlive: true\'.'); 47 return; 48 } 49 assert_unreached("did not reject"); 50 }, 'selectURL() with keepAlive: true, then keepAlive: false, then error'); 51 52 </script> 53 </body>