diff --git a/browser/components/resistfingerprinting/test/browser/browser.ini b/browser/components/resistfingerprinting/test/browser/browser.ini index 8f6956cfbc2f..7646a5167ad5 100644 --- a/browser/components/resistfingerprinting/test/browser/browser.ini +++ b/browser/components/resistfingerprinting/test/browser/browser.ini @@ -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] diff --git a/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js b/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js new file mode 100644 index 000000000000..2bc06831d125 --- /dev/null +++ b/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.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); +});