Joining with Delegation File with Bad Values
Here we try to create an IG in the delegation-option-DIRECTIVE.privacy-sandbox-testing-one.com origin from the www subdomain, where directive gets replaced with badTrue, badJson, blankResponse, badStatus, and badMimeType. The server side delegation service code is set up to extract the DIRECTIVE and return a slightly different delegation file based on it:
- badTrue: will result in an intentionally misspelled value for true.
- badJson: will return a response that does not decode to
- blankResponse: will return a blank response
- badStatus: will return a http status code of 500
- badmimetype: will return a non app/json mime type
The joins fail as expected; what I'm not sure how to do is debug this, given no "issues" or console logs show up (see image below or your own console log if you're looking at this).
Client Side Code
Client side code will simply try to join an IG owned by one of the "bad sumdomains".
window.onload = async function() {
const originTemplate = 'https://delegation-option-REPLACEME.privacy-sandbox-testing-one.com/';
["badTrue", "badJson", "blankResponse", "badStatus", "badmimetype"].forEach(indicator => {
var origin = originTemplate;
origin = origin.replace('REPLACEME', indicator);
navigator.clearOriginJoinedAdInterestGroups(origin);
joinUsingOriginAndConsoleLogResult(origin);
});
}
Well Known Delegation Logic
The delegation file returned will depend on the directive extracted
function finalizeDelegationResponse(host, val, reply) {
let optionValue = extractDelegationDirective(host);
let fullResponseDirectives = {"blankresponse": "", "badjson": '{"grrr"'};
let modifyValDirectives = {"intone": '1', "stringone": '"1"', 'stringtrue': '"true"', 'badtrue': 'true_missplld'};
var fullResponse = null;
if (optionValue !== null) {
optionValue.toLowerCase();
console.log("got value " + optionValue);
if (optionValue in fullResponseDirectives) {
fullResponse = fullResponseDirectives[optionValue];
} else if (optionValue in modifyValDirectives) {
val = modifyValDirectives[optionValue];
} else if (optionValue == 'badstatus') {
console.log('setting bad status');
reply.status(500);
} else if (optionValue == 'badmimetype') {
console.log('setting bad mime type');
reply.type('not/athing');
}
}
if (fullResponse === null) {
fullResponse = '{"joinAdInterestGroup": ' + val + ', "leaveAdInterestGroup": ' + val + '}';
}
console.log(fullResponse);
return fullResponse;
}
function extractDelegationDirective(host) {
let match = host.match(/delegation-option-([^.]+)\.privacy-sandbox-testing-one\.com/);
let optionValue = match ? match[1] : null;
return optionValue;
}
Expected Result
You should see roughly the following in dev tools.
Not visible in the page (from what I can tell) is the response, here is a shot of what was logged on a run in node: