Source code
Revision control
Copy as Markdown
Other Tools
const kFetchPriorityLowRequestFileNameAndSuffix = "dummy.js?1";
const kFetchPriorityHighRequestFileNameAndSuffix = "dummy.js?2";
const kFetchPriorityAutoRequestFileNameAndSuffix = "dummy.js?3";
const kNoFetchPriorityRequestFileNameAndSuffix = "dummy.js?4";
// Mapping fetchpriority's values to internal priorities is specified as
// 15). For web-compatibility, Chromium's desired mapping is chosen, see
// Exceptions are commented below.
const kExpectedRequestsForScriptsInHead = [
{ fileNameAndSuffix: kFetchPriorityLowRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
},
{ fileNameAndSuffix: kFetchPriorityHighRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGH
},
{ fileNameAndSuffix: kFetchPriorityAutoRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: kNoFetchPriorityRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
}
];
const kExpectedRequestsForScriptsInHeadDisabled = [
{ fileNameAndSuffix: kFetchPriorityLowRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: kFetchPriorityHighRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: kFetchPriorityAutoRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: kNoFetchPriorityRequestFileNameAndSuffix,
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
}
];
const kExpectedRequestsForScriptsInBody = [
{ fileNameAndSuffix: "dummy.js?1",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
},
{ fileNameAndSuffix: "dummy.js?2",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGH
},
{ fileNameAndSuffix: "dummy.js?3",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?4",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?5",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?6",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?7",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?8",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?9",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
},
{ fileNameAndSuffix: "dummy.js?10",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGH
},
{ fileNameAndSuffix: "dummy.js?11",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?12",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?13",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?14",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?15",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?16",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
]
const kExpectedRequestsForScriptsInBodyDisabled = [
{ fileNameAndSuffix: "dummy.js?1",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?2",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?3",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?4",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?5",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?6",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?7",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?8",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?9",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?10",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?11",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?12",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?13",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?14",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?15",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?16",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
]
export const kTestFolderName = "script-tests";
const kExpectedRequestsForNonModuleAsyncAndDeferredScripts = [
{ fileNameAndSuffix: "dummy.js?1",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
},
{ fileNameAndSuffix: "dummy.js?2",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGH
},
{ fileNameAndSuffix: "dummy.js?3",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?4",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?5",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?6",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?7",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?8",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
]
const kExpectedRequestsForNonModuleAsyncAndDeferredScriptsDisabled = [
{ fileNameAndSuffix: "dummy.js?1",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?2",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?3",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?4",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?5",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?6",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?7",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?8",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
]
// Chromium's desired behavior is under discussion:
const kExpectedRequestsForModuleScripts = [
{ fileNameAndSuffix: "dummy.js?1",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
},
{ fileNameAndSuffix: "dummy.js?2",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGH
},
{ fileNameAndSuffix: "dummy.js?3",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?4",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?5",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?6",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?7",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?8",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
]
const kExpectedRequestsForModuleScriptsDisabled = [
{ fileNameAndSuffix: "dummy.js?1",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?2",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?3",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?4",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?5",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?6",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?7",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
{ fileNameAndSuffix: "dummy.js?8",
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL
},
]
export const kTestData = [
{ testFileName: "script-initial-load-head.h2.html",
expectedRequests: kExpectedRequestsForScriptsInHead
},
{ testFileName: "script-initial-load-body.h2.html",
expectedRequests: kExpectedRequestsForScriptsInBody
},
{ testFileName: "async-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForNonModuleAsyncAndDeferredScripts
},
{ testFileName: "deferred-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForNonModuleAsyncAndDeferredScripts
},
{ testFileName: "module-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForModuleScripts
},
{ testFileName: "async-module-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForModuleScripts
},
// Dynamic insertion executes non-speculative-parsing
// code paths. Moreover such inserted scripts are loaded asynchronously.
{ testFileName: "script-dynamic-insertion.h2.html",
expectedRequests: kExpectedRequestsForNonModuleAsyncAndDeferredScripts
},
{ testFileName: "module-script-dynamic-insertion.h2.html",
expectedRequests: kExpectedRequestsForModuleScripts
}
];
export const kTestDataDisabled = [
{ testFileName: "script-initial-load-head.h2.html",
expectedRequests: kExpectedRequestsForScriptsInHeadDisabled
},
{ testFileName: "script-initial-load-body.h2.html",
expectedRequests: kExpectedRequestsForScriptsInBodyDisabled
},
{ testFileName: "async-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForNonModuleAsyncAndDeferredScriptsDisabled
},
{ testFileName: "deferred-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForNonModuleAsyncAndDeferredScriptsDisabled
},
{ testFileName: "module-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForModuleScriptsDisabled
},
{ testFileName: "async-module-script-initial-load.h2.html",
expectedRequests: kExpectedRequestsForModuleScriptsDisabled
},
{ testFileName: "script-dynamic-insertion.h2.html",
expectedRequests: kExpectedRequestsForNonModuleAsyncAndDeferredScriptsDisabled
},
{ testFileName: "module-script-dynamic-insertion.h2.html",
expectedRequests: kExpectedRequestsForModuleScriptsDisabled
}
];