shared-storage-surface-context-id.https.html (2213B)
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="/private-aggregation/resources/util.js"></script> 7 <script src="/fenced-frame/resources/utils.js"></script> 8 9 <body> 10 <script> 11 'use strict'; 12 13 promise_test(async () => { 14 await addModuleOnce("/private-aggregation/resources/shared-storage-helper-module.js"); 15 16 const data = { 17 contributions: [{bucket: 1n, value: 2}] 18 }; 19 const privateAggregationConfig = { 20 contextId: "example_context_id" 21 }; 22 23 await sharedStorage.run("contribute-to-histogram", 24 {data, privateAggregationConfig, keepAlive: true}); 25 }, 'set context ID'); 26 27 promise_test(async () => { 28 await addModuleOnce("/private-aggregation/resources/shared-storage-helper-module.js"); 29 30 const data = { 31 contributions: [{bucket: 1n, value: 2}] 32 }; 33 const privateAggregationConfig = { 34 contextId: "" 35 }; 36 37 await sharedStorage.run("contribute-to-histogram", 38 {data, privateAggregationConfig, keepAlive: true}); 39 }, 'set empty context ID'); 40 41 promise_test(async () => { 42 await addModuleOnce("/private-aggregation/resources/shared-storage-helper-module.js"); 43 44 const data = { 45 contributions: [{bucket: 1n, value: 2}] 46 }; 47 const privateAggregationConfig = { 48 contextId: "an_example_of_a_context_id_with_the_exact_maximum_allowed_length" 49 }; 50 51 await sharedStorage.run("contribute-to-histogram", 52 {data, privateAggregationConfig, keepAlive: true}); 53 }, 'set max length context ID'); 54 55 promise_test(async (test) => { 56 await addModuleOnce("/private-aggregation/resources/shared-storage-helper-module.js"); 57 58 const data = { 59 contributions: [{bucket: 1n, value: 2}] 60 }; 61 const privateAggregationConfig = { 62 contextId: "this_is_an_example_of_a_context_id_that_is_too_long_to_be_allowed" 63 }; 64 65 return promise_rejects_dom( 66 test, "DataError", 67 sharedStorage.run("contribute-to-histogram", 68 {data, privateAggregationConfig, keepAlive: true})); 69 }, 'set too long context ID'); 70 71 72 </script> 73 </body>