select-url-on-two-worklets.tentative.https.sub.html (1965B)
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 let worklet0 = await sharedStorage.createWorklet("/shared-storage/resources/simple-module.js"); 20 let worklet1 = await sharedStorage.createWorklet("/shared-storage/resources/simple-module.js"); 21 22 let select_url_result0 = await worklet0.selectURL( 23 "increment-global-variable-and-return-original-value-operation", 24 [{url: url0}, {url: url1}], {resolveToConfig: true, keepAlive: true}); 25 assert_true(validateSelectURLResult(select_url_result0, true)); 26 attachFencedFrame(select_url_result0, 'opaque-ads'); 27 const result0 = await nextValueFromServer(ancestor_key); 28 assert_equals(result0, "frame0_loaded"); 29 30 let select_url_result1 = await worklet1.selectURL( 31 "increment-global-variable-and-return-original-value-operation", 32 [{url: url0}, {url: url1}], {resolveToConfig: true, keepAlive: true}); 33 assert_true(validateSelectURLResult(select_url_result1, true)); 34 attachFencedFrame(select_url_result1, 'opaque-ads'); 35 const result1 = await nextValueFromServer(ancestor_key); 36 37 // This indicates that the prior worklet0.selectURL and worklet1.selectURL ran 38 // in two different worklet environments, as they did not share the global 39 // variable. 40 assert_equals(result1, "frame0_loaded"); 41 42 }, 'selectURL() on two explicitly created SharedStorageWorklet. The two ' + 43 'calls should run in two different worklet environments.'); 44 45 </script> 46 </body>