summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fledge/tentative/abort.https.window.js
blob: b99d60dd5282cd252b932f9d1ae1fe99230a5f8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// META: script=/resources/testdriver.js
// META: script=/common/utils.js
// META: script=resources/fledge-util.sub.js
// META: timeout=long

"use strict;"

promise_test(async test => {
  const uuid = generateUuid(test);

  // To minimize the risk of the auction completing before the abort signal,
  // make the bid script hand, and increase the per-buyer script timeout.
  await joinInterestGroup(
      test, uuid,
      createBiddingScriptURL({generateBid: 'while(1);'}));

  let abortController = new AbortController();
  let promise = runBasicFledgeAuction(
      test, uuid,
      { signal: abortController.signal,
        perBuyerTimeouts: {'*': 1000}
      });
  abortController.abort('reason');
  try {
    await promise;
  } catch (e) {
    assert_equals(e, 'reason');
    return;
  }
  throw 'Exception unexpectedly not thrown';
}, 'Abort auction.');

promise_test(async test => {
  const uuid = generateUuid(test);

  await joinInterestGroup(test, uuid);

  let abortController = new AbortController();
  abortController.abort('reason');
  try {
    await runBasicFledgeAuction(test, uuid, {signal: abortController.signal});
  } catch (e) {
    assert_equals(e, 'reason');
    return;
  }
  throw 'Exception unexpectedly not thrown';
}, 'Abort triggered before auction started.');

promise_test(async test => {
  const uuid = generateUuid(test);

  // This doesn't have the header to be loaded in a fenced frame, but can still
  // check that it was requested, which is all this test needs.
  let trackingRenderURL =
      createTrackerURL(origin, uuid, `track_get`, `tracking_render_url`);

  await joinInterestGroup(
      test, uuid,
      {ads: [{renderURL: trackingRenderURL}]});

  let abortController = new AbortController();
  let fencedFrameConfig = await runBasicFledgeTestExpectingWinner(
      test, uuid, {signal: abortController.signal});

  // Aborting now should have no effect - in particular, it should still be
  // possible to navigate to the winning ad, and it should still send reports.
  abortController.abort('reason');

  // Load the fencedFrameConfig in a fenced frame, and make sure reports are
  // still sent and the render URL still loaded.
  createAndNavigateFencedFrame(test, fencedFrameConfig);
  await waitForObservedRequests(
      uuid,
      [trackingRenderURL, createBidderReportURL(uuid), createSellerReportURL(uuid)]);
}, 'Abort signalled after auction completes.');

promise_test(async test => {
  const uuid = generateUuid(test);

  await joinInterestGroup(
    test, uuid,
    { biddingLogicURL: createBiddingScriptURL(
          { allowComponentAuction: true })});


  let abortController = new AbortController();
  let componentAuctionConfig = {
    seller: window.location.origin,
    decisionLogicURL: createDecisionScriptURL(uuid),
    interestGroupBuyers: [window.location.origin],
    signal: abortController.signal
  };

  let auctionConfigOverrides = {
    decisionLogicURL: createDecisionScriptURL(uuid),
    interestGroupBuyers: [],
    componentAuctions: [componentAuctionConfig]
  };

  abortController.abort();
  // Aborting a component auction has no effect.
  await runBasicFledgeTestExpectingWinner(test, uuid, auctionConfigOverrides);
}, 'Abort component auction.');