tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

no-winner.https.window.js (3718B)


      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: script=/common/subset-tests.js
      6 // META: timeout=long
      7 // META: variant=?1-5
      8 // META: variant=?6-10
      9 // META: variant=?11-15
     10 // META: variant=?16-20
     11 // META: variant=?21-25
     12 // META: variant=?26-30
     13 // META: variant=?31-35
     14 // META: variant=?36-40
     15 // META: variant=?41-45
     16 // META: variant=?46-last
     17 
     18 "use strict";
     19 
     20 // The tests in this file focus on simple auctions (one bidder, one seller, one
     21 // origin, one frame) which have no winning bid, either due to errors or due to
     22 // there being no bids, except where tests fit better with another set of tests.
     23 
     24 // Errors common to Protected Audiences network requests. These strings will be
     25 // appended to URLs to make the Python scripts that generate responses respond
     26 // with errors.
     27 const COMMON_NETWORK_ERRORS = [
     28  'error=close-connection',
     29  'error=http-error',
     30  'error=no-content-type',
     31  'error=wrong-content-type',
     32  'error=bad-allow-fledge',
     33  'error=fledge-not-allowed',
     34  'error=no-allow-fledge',
     35  'error=no-body',
     36 ];
     37 
     38 const BIDDING_LOGIC_SCRIPT_ERRORS = [
     39  ...COMMON_NETWORK_ERRORS,
     40  'error=no-generateBid',
     41  'generateBid=throw 1;',
     42  'generateBid=This does not compile',
     43  // Default timeout test. Doesn't check how long timing out takes.
     44  'generateBid=while(1);',
     45  // Bad return values:
     46  'generateBid=return 5;',
     47  'generateBid=return "Foo";',
     48  'generateBid=return interestGroup.ads[0].renderURL;',
     49  'generateBid=return {bid: 1, render: "https://not-in-ads-array.test/"};',
     50  'generateBid=return {bid: 1};',
     51  'generateBid=return {render: interestGroup.ads[0].renderURL};',
     52  // These are not bidding rather than errors.
     53  'generateBid=return {bid:0, render: interestGroup.ads[0].renderURL};',
     54  'generateBid=return {bid:-1, render: interestGroup.ads[0].renderURL};'
     55 ];
     56 
     57 const DECISION_LOGIC_SCRIPT_ERRORS = [
     58  ...COMMON_NETWORK_ERRORS,
     59  'error=no-scoreAd',
     60  'scoreAd=throw 1;',
     61  'scoreAd=This does not compile',
     62  // Default timeout test. Doesn't check how long timing out takes.
     63  'scoreAd=while(1);',
     64  // Bad return values:
     65  'scoreAd=return "Foo";',
     66  'scoreAd=return {desirability: "Foo"};',
     67  // These are rejecting the bid rather than errors.
     68  'scoreAd=return 0;',
     69  'scoreAd=return -1;',
     70  'scoreAd=return {desirability: 0};',
     71  'scoreAd=return {desirability: -1};'
     72 ];
     73 
     74 const BIDDING_WASM_HELPER_ERRORS = [
     75  ...COMMON_NETWORK_ERRORS,
     76  'error=not-wasm'
     77 ];
     78 
     79 for (let error of BIDDING_LOGIC_SCRIPT_ERRORS) {
     80  subsetTest(promise_test, (async (error, test) => {
     81    let biddingLogicURL = `${BASE_URL}resources/bidding-logic.sub.py?${error}`;
     82    await joinGroupAndRunBasicFledgeTestExpectingNoWinner(
     83      test,
     84      {interestGroupOverrides: {biddingLogicURL: biddingLogicURL}}
     85    );
     86  }).bind(undefined, error), `Bidding logic script: ${error}`);
     87 }
     88 
     89 for (let error of DECISION_LOGIC_SCRIPT_ERRORS) {
     90  subsetTest(promise_test, (async (error, test) => {
     91    let decisionLogicURL =
     92        `${BASE_URL}resources/decision-logic.sub.py?${error}`;
     93    await joinGroupAndRunBasicFledgeTestExpectingNoWinner(
     94      test, { auctionConfigOverrides: { decisionLogicURL: decisionLogicURL } }
     95    );
     96  }).bind(undefined, error), `Decision logic script: ${error}`);
     97 }
     98 
     99 for (let error of BIDDING_WASM_HELPER_ERRORS) {
    100  subsetTest(promise_test, (async (error, test) => {
    101    let biddingWasmHelperURL =
    102        `${BASE_URL}resources/wasm-helper.py?${error}`;
    103    await joinGroupAndRunBasicFledgeTestExpectingNoWinner(
    104      test, { interestGroupOverrides: { biddingWasmHelperURL: biddingWasmHelperURL } }
    105    );
    106  }).bind(undefined, error), `Bidding WASM helper: ${error}`);
    107 }