abort.https.window.js (3289B)
1 // META: script=/resources/testdriver.js 2 // META: script=/resources/testdriver-vendor.js 3 // META: script=/common/utils.js 4 // META: script=resources/fledge-util.sub.js 5 // META: timeout=long 6 7 "use strict"; 8 9 promise_test(async test => { 10 const uuid = generateUuid(test); 11 12 // To minimize the risk of the auction completing before the abort signal, 13 // make the bid script hand, and increase the per-buyer script timeout. 14 await joinInterestGroup( 15 test, uuid, 16 createBiddingScriptURL({generateBid: 'while(1);'})); 17 18 let abortController = new AbortController(); 19 let promise = runBasicFledgeAuction( 20 test, uuid, 21 { signal: abortController.signal, 22 perBuyerTimeouts: {'*': 1000} 23 }); 24 abortController.abort('reason'); 25 try { 26 await promise; 27 } catch (e) { 28 assert_equals(e, 'reason'); 29 return; 30 } 31 throw 'Exception unexpectedly not thrown'; 32 }, 'Abort auction.'); 33 34 promise_test(async test => { 35 const uuid = generateUuid(test); 36 37 await joinInterestGroup(test, uuid); 38 39 let abortController = new AbortController(); 40 abortController.abort('reason'); 41 try { 42 await runBasicFledgeAuction(test, uuid, {signal: abortController.signal}); 43 } catch (e) { 44 assert_equals(e, 'reason'); 45 return; 46 } 47 throw 'Exception unexpectedly not thrown'; 48 }, 'Abort triggered before auction started.'); 49 50 promise_test(async test => { 51 const uuid = generateUuid(test); 52 53 // This doesn't have the header to be loaded in a fenced frame, but can still 54 // check that it was requested, which is all this test needs. 55 let trackingRenderURL = 56 createTrackerURL(origin, uuid, `track_get`, `tracking_render_url`); 57 58 await joinInterestGroup( 59 test, uuid, 60 {ads: [{renderURL: trackingRenderURL}]}); 61 62 let abortController = new AbortController(); 63 let fencedFrameConfig = await runBasicFledgeTestExpectingWinner( 64 test, uuid, {signal: abortController.signal}); 65 66 // Aborting now should have no effect - in particular, it should still be 67 // possible to navigate to the winning ad, and it should still send reports. 68 abortController.abort('reason'); 69 70 // Load the fencedFrameConfig in a fenced frame, and make sure reports are 71 // still sent and the render URL still loaded. 72 createAndNavigateFencedFrame(test, fencedFrameConfig); 73 await waitForObservedRequests( 74 uuid, 75 [trackingRenderURL, createBidderReportURL(uuid), createSellerReportURL(uuid)]); 76 }, 'Abort signalled after auction completes.'); 77 78 promise_test(async test => { 79 const uuid = generateUuid(test); 80 81 await joinInterestGroup( 82 test, uuid, 83 { biddingLogicURL: createBiddingScriptURL( 84 { allowComponentAuction: true })}); 85 86 87 let abortController = new AbortController(); 88 let componentAuctionConfig = { 89 seller: window.location.origin, 90 decisionLogicURL: createDecisionScriptURL(uuid), 91 interestGroupBuyers: [window.location.origin], 92 signal: abortController.signal 93 }; 94 95 let auctionConfigOverrides = { 96 decisionLogicURL: createDecisionScriptURL(uuid), 97 interestGroupBuyers: [], 98 componentAuctions: [componentAuctionConfig] 99 }; 100 101 abortController.abort(); 102 // Aborting a component auction has no effect. 103 await runBasicFledgeTestExpectingWinner(test, uuid, auctionConfigOverrides); 104 }, 'Abort component auction.');