fune/browser/components/attribution/test/xpcshell/head_win.js
Ed Lee 663cf7242e Bug 1595063 - Support user agent attribution codes r=mixedpuppy,nanj
Add "ua" and increase allowed length for attribution codes. Allows asrouter devtools to set all keys.

Differential Revision: https://phabricator.services.mozilla.com/D57906

--HG--
extra : moz-landing-system : lando
2019-12-24 17:04:10 +00:00

63 lines
1.8 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
"use strict";
const { AttributionCode } = ChromeUtils.import(
"resource:///modules/AttributionCode.jsm"
);
let validAttrCodes = [
{
code:
"source%3Dgoogle.com%26medium%3Dorganic%26campaign%3D(not%20set)%26content%3D(not%20set)",
parsed: {
source: "google.com",
medium: "organic",
campaign: "(not%20set)",
content: "(not%20set)",
},
},
{
code: "source%3Dgoogle.com%26medium%3Dorganic%26campaign%3D%26content%3D",
parsed: { source: "google.com", medium: "organic" },
},
{
code: "source%3Dgoogle.com%26medium%3Dorganic%26campaign%3D(not%20set)",
parsed: {
source: "google.com",
medium: "organic",
campaign: "(not%20set)",
},
},
{
code: "source%3Dgoogle.com%26medium%3Dorganic",
parsed: { source: "google.com", medium: "organic" },
},
{ code: "source%3Dgoogle.com", parsed: { source: "google.com" } },
{ code: "medium%3Dgoogle.com", parsed: { medium: "google.com" } },
{ code: "campaign%3Dgoogle.com", parsed: { campaign: "google.com" } },
{ code: "content%3Dgoogle.com", parsed: { content: "google.com" } },
{
code: "experiment%3Dexperimental",
parsed: { experiment: "experimental" },
},
{ code: "variation%3Dvaried", parsed: { variation: "varied" } },
{
code: "ua%3DGoogle%20Chrome%20123",
parsed: { ua: "Google%20Chrome%20123" },
},
];
let invalidAttrCodes = [
// Empty string
"",
// Not escaped
"source=google.com&medium=organic&campaign=(not set)&content=(not set)",
// Too long
"campaign%3D" + "a".repeat(1000),
// Unknown key name
"source%3Dgoogle.com%26medium%3Dorganic%26large%3Dgeneticallymodified",
// Empty key name
"source%3Dgoogle.com%26medium%3Dorganic%26%3Dgeneticallymodified",
];