зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1369303 - Part 3: Add a test case for making sure that performance APIs have been correctly spoofed. r=arthuredelstein,baku
This test case will open a content tab and access performance API in that tab to check whether or not performance APIs are correctly spoofed. MozReview-Commit-ID: KdG6xzQFmv6 --HG-- extra : rebase_source : d064d5a90d525190402107c22bac9ed2dfd4c085
This commit is contained in:
Родитель
7d1c0f2d14
Коммит
46fc5b47a0
|
@ -4,6 +4,7 @@ support-files =
|
|||
file_dummy.html
|
||||
head.js
|
||||
|
||||
[browser_performanceAPI.js]
|
||||
[browser_roundedWindow_dialogWindow.js]
|
||||
[browser_roundedWindow_newWindow.js]
|
||||
[browser_roundedWindow_open_max.js]
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* Bug 1369303 - A test for making sure that performance APIs have been correctly
|
||||
* spoofed or disabled.
|
||||
*/
|
||||
|
||||
const TEST_PATH = "http://example.net/browser/browser/" +
|
||||
"components/resistfingerprinting/test/browser/"
|
||||
|
||||
const PERFORMANCE_TIMINGS = [
|
||||
"navigationStart",
|
||||
"unloadEventStart",
|
||||
"unloadEventEnd",
|
||||
"redirectStart",
|
||||
"redirectEnd",
|
||||
"fetchStart",
|
||||
"domainLookupStart",
|
||||
"domainLookupEnd",
|
||||
"connectStart",
|
||||
"connectEnd",
|
||||
"requestStart",
|
||||
"responseStart",
|
||||
"responseEnd",
|
||||
"domLoading",
|
||||
"domInteractive",
|
||||
"domContentLoadedEventStart",
|
||||
"domContentLoadedEventEnd",
|
||||
"domComplete",
|
||||
"loadEventStart",
|
||||
"loadEventEnd",
|
||||
];
|
||||
|
||||
add_task(async function runTests() {
|
||||
await SpecialPowers.pushPrefEnv({"set":
|
||||
[["privacy.resistFingerprinting", true]]
|
||||
});
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser, TEST_PATH + "file_dummy.html");
|
||||
|
||||
await ContentTask.spawn(tab.linkedBrowser, PERFORMANCE_TIMINGS, async function(list) {
|
||||
// Check that whether the performance timing API is correctly spoofed.
|
||||
for (let time of list) {
|
||||
is(content.performance.timing[time], 0, `The timing(${time}) is correctly spoofed.`);
|
||||
}
|
||||
|
||||
// Try to add some entries.
|
||||
content.performance.mark("Test");
|
||||
content.performance.mark("Test-End");
|
||||
content.performance.measure("Test-Measure", "Test", "Test-End");
|
||||
|
||||
// Check that no entries for performance.getEntries/getEntriesByType/getEntriesByName.
|
||||
is(content.performance.getEntries().length, 0, "No entries for performance.getEntries()");
|
||||
is(content.performance.getEntriesByType("resource").length, 0, "No entries for performance.getEntriesByType()");
|
||||
is(content.performance.getEntriesByName("Test", "mark").length, 0, "No entries for performance.getEntriesByName()");
|
||||
|
||||
});
|
||||
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
Загрузка…
Ссылка в новой задаче