зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to mozilla-inbound. CLOSED TREE
This commit is contained in:
Коммит
0bee0de65c
|
@ -170,8 +170,6 @@ dom/base/test/unit_ipc/**
|
|||
dom/base/test/jsmodules/**
|
||||
dom/bindings/**
|
||||
dom/browser-element/**
|
||||
dom/cache/test/mochitest/**
|
||||
dom/cache/test/xpcshell/**
|
||||
dom/canvas/**
|
||||
dom/encoding/**
|
||||
dom/events/**
|
||||
|
@ -191,7 +189,6 @@ dom/network/**
|
|||
dom/payments/**
|
||||
dom/performance/**
|
||||
dom/permission/**
|
||||
dom/plugins/test/mochitest/**
|
||||
dom/plugins/test/unit/**
|
||||
dom/promise/**
|
||||
dom/push/**
|
||||
|
|
|
@ -453,7 +453,7 @@ var PlacesCommandHook = {
|
|||
});
|
||||
PlacesUIUtils.showBookmarkDialog({ action: "add",
|
||||
type: "bookmark",
|
||||
uri: makeURI(url),
|
||||
uri: Services.io.newURI(url),
|
||||
title,
|
||||
defaultInsertionPoint,
|
||||
hiddenRows: [ "location", "keyword" ],
|
||||
|
|
|
@ -386,11 +386,13 @@ window._gBrowser = {
|
|||
|
||||
_preopenPinnedTabs() {
|
||||
let numPinnedTabs = 0;
|
||||
let windows = browserWindows();
|
||||
windows.getNext();
|
||||
let isOnlyWindow = !windows.hasMoreElements();
|
||||
if (isOnlyWindow) {
|
||||
numPinnedTabs = Services.prefs.getIntPref("browser.tabs.firstWindowRestore.numPinnedTabs", 0);
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
let windows = browserWindows();
|
||||
windows.getNext();
|
||||
let isOnlyWindow = !windows.hasMoreElements();
|
||||
if (isOnlyWindow) {
|
||||
numPinnedTabs = Services.prefs.getIntPref("browser.tabs.firstWindowRestore.numPinnedTabs", 0);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < numPinnedTabs; i++) {
|
||||
|
@ -632,7 +634,8 @@ window._gBrowser = {
|
|||
},
|
||||
|
||||
_maybeUpdateNumPinnedTabsPref() {
|
||||
if (BrowserWindowTracker.getTopWindow() == window) {
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window) &&
|
||||
BrowserWindowTracker.getTopWindow() == window) {
|
||||
Services.prefs.setIntPref("browser.tabs.firstWindowRestore.numPinnedTabs",
|
||||
this._numPinnedTabs);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ add_task(async function() {
|
|||
|
||||
ok(!testWindow.gFindBarInitialized, "find bar is not initialized");
|
||||
|
||||
let findBarOpenPromise = promiseWaitForEvent(testWindow.gBrowser, "findbaropen");
|
||||
let findBarOpenPromise = BrowserTestUtils.waitForEvent(testWindow.gBrowser, "findbaropen");
|
||||
EventUtils.synthesizeKey("/", {}, testWindow);
|
||||
await findBarOpenPromise;
|
||||
|
||||
|
|
|
@ -12,3 +12,6 @@ support-files=
|
|||
[browser_sanitize-timespans.js]
|
||||
[browser_sanitizeDialog.js]
|
||||
[browser_cookiePermission.js]
|
||||
[browser_cookiePermission_aboutURL.js]
|
||||
[browser_cookiePermission_containers.js]
|
||||
[browser_cookiePermission_subDomains.js]
|
||||
|
|
|
@ -1,400 +1 @@
|
|||
const {Sanitizer} = ChromeUtils.import("resource:///modules/Sanitizer.jsm");
|
||||
const {SiteDataTestUtils} = ChromeUtils.import("resource://testing-common/SiteDataTestUtils.jsm");
|
||||
|
||||
function checkDataForAboutURL() {
|
||||
return new Promise(resolve => {
|
||||
let data = true;
|
||||
let uri = Services.io.newURI("about:newtab");
|
||||
let principal =
|
||||
Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||
let request = indexedDB.openForPrincipal(principal, "TestDatabase", 1);
|
||||
request.onupgradeneeded = function(e) {
|
||||
data = false;
|
||||
};
|
||||
request.onsuccess = function(e) {
|
||||
resolve(data);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createIndexedDB(host, originAttributes) {
|
||||
let uri = Services.io.newURI("https://" + host);
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, originAttributes);
|
||||
return SiteDataTestUtils.addToIndexedDB(principal.origin);
|
||||
}
|
||||
|
||||
function checkIndexedDB(host, originAttributes) {
|
||||
return new Promise(resolve => {
|
||||
let data = true;
|
||||
let uri = Services.io.newURI("https://" + host);
|
||||
let principal =
|
||||
Services.scriptSecurityManager.createCodebasePrincipal(uri,
|
||||
originAttributes);
|
||||
let request = indexedDB.openForPrincipal(principal, "TestDatabase", 1);
|
||||
request.onupgradeneeded = function(e) {
|
||||
data = false;
|
||||
};
|
||||
request.onsuccess = function(e) {
|
||||
resolve(data);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createHostCookie(host, originAttributes) {
|
||||
Services.cookies.add(host, "/test", "foo", "bar",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, originAttributes,
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
}
|
||||
|
||||
function createDomainCookie(host, originAttributes) {
|
||||
Services.cookies.add("." + host, "/test", "foo", "bar",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, originAttributes,
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
}
|
||||
|
||||
function checkCookie(host, originAttributes) {
|
||||
for (let cookie of Services.cookies.enumerator) {
|
||||
if (ChromeUtils.isOriginAttributesEqual(originAttributes,
|
||||
cookie.originAttributes) &&
|
||||
cookie.host.includes(host)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function deleteOnShutdown(opt) {
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", opt.lifetimePolicy],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Custom permission without considering OriginAttributes
|
||||
if (opt.cookiePermission !== undefined) {
|
||||
let uri = Services.io.newURI("https://www.example.com");
|
||||
Services.perms.add(uri, "cookie", opt.cookiePermission);
|
||||
}
|
||||
|
||||
// Let's create a tab with some data.
|
||||
await opt.createData((opt.fullHost ? "www." : "") + "example.org",
|
||||
opt.originAttributes);
|
||||
ok(await opt.checkData((opt.fullHost ? "www." : "") + "example.org",
|
||||
opt.originAttributes),
|
||||
"We have data for www.example.org");
|
||||
await opt.createData((opt.fullHost ? "www." : "") + "example.com",
|
||||
opt.originAttributes);
|
||||
ok(await opt.checkData((opt.fullHost ? "www." : "") + "example.com",
|
||||
opt.originAttributes),
|
||||
"We have data for www.example.com");
|
||||
|
||||
// Cleaning up.
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
// All gone!
|
||||
is(!!(await opt.checkData((opt.fullHost ? "www." : "") + "example.org",
|
||||
opt.originAttributes)),
|
||||
opt.expectedForOrg, "Do we have data for www.example.org?");
|
||||
is(!!(await opt.checkData((opt.fullHost ? "www." : "") + "example.com",
|
||||
opt.originAttributes)),
|
||||
opt.expectedForCom, "Do we have data for www.example.com?");
|
||||
|
||||
// Clean up.
|
||||
await Sanitizer.sanitize([ "cookies", "offlineApps" ]);
|
||||
|
||||
if (opt.cookiePermission !== undefined) {
|
||||
let uri = Services.io.newURI("https://www.example.com");
|
||||
Services.perms.remove(uri, "cookie");
|
||||
}
|
||||
}
|
||||
|
||||
let tests = [
|
||||
{ name: "IDB",
|
||||
createData: createIndexedDB,
|
||||
checkData: checkIndexedDB },
|
||||
{ name: "Host Cookie",
|
||||
createData: createHostCookie,
|
||||
checkData: checkCookie },
|
||||
{ name: "Domain Cookie",
|
||||
createData: createDomainCookie,
|
||||
checkData: checkCookie },
|
||||
];
|
||||
|
||||
let attributes = [
|
||||
{name: "default", oa: {}},
|
||||
{name: "container", oa: {userContextId: 1}},
|
||||
];
|
||||
|
||||
// Delete all, no custom permission, data in example.com, cookie permission set
|
||||
// for www.example.com
|
||||
tests.forEach(methods => {
|
||||
attributes.forEach(originAttributes => {
|
||||
add_task(async function deleteStorageOnShutdown() {
|
||||
info(methods.name + ": Delete all, no custom permission, data in example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: undefined,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: false,
|
||||
fullHost: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Delete all, no custom permission, data in www.example.com, cookie permission
|
||||
// set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
attributes.forEach(originAttributes => {
|
||||
add_task(async function deleteStorageOnShutdown() {
|
||||
info(methods.name + ": Delete all, no custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: undefined,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: false,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is session, but with ALLOW custom permission, data in example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
attributes.forEach(originAttributes => {
|
||||
add_task(async function deleteStorageWithCustomPermission() {
|
||||
info(methods.name + ": All is session, but with ALLOW custom permission, data in example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_ALLOW,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: true,
|
||||
fullHost: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is session, but with ALLOW custom permission, data in www.example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
attributes.forEach(originAttributes => {
|
||||
add_task(async function deleteStorageWithCustomPermission() {
|
||||
info(methods.name + ": All is session, but with ALLOW custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_ALLOW,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: true,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is default, but with SESSION custom permission, data in example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
attributes.forEach(originAttributes => {
|
||||
add_task(async function deleteStorageOnlyCustomPermission() {
|
||||
info(methods.name + ": All is default, but with SESSION custom permission, data in example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_NORMALLY,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_SESSION,
|
||||
expectedForOrg: true,
|
||||
// expected data just for example.com when using indexedDB because
|
||||
// QuotaManager deletes for principal.
|
||||
expectedForCom: false,
|
||||
fullHost: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is default, but with SESSION custom permission, data in www.example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
attributes.forEach(originAttributes => {
|
||||
add_task(async function deleteStorageOnlyCustomPermission() {
|
||||
info(methods.name + ": All is default, but with SESSION custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_NORMALLY,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_SESSION,
|
||||
expectedForOrg: true,
|
||||
expectedForCom: false,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Session mode, but with unsupported custom permission, data in
|
||||
// www.example.com, cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
attributes.forEach(originAttributes => {
|
||||
add_task(async function deleteStorageOnlyCustomPermission() {
|
||||
info(methods.name + ": All is session only, but with unsupported custom custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: 123, // invalid cookie permission
|
||||
expectedForOrg: false,
|
||||
expectedForCom: false,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function deleteStorageInAboutURL() {
|
||||
info("Test about:newtab");
|
||||
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", Ci.nsICookieService.ACCEPT_SESSION],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Let's create a tab with some data.
|
||||
await SiteDataTestUtils.addToIndexedDB("about:newtab", "foo", "bar", {});
|
||||
|
||||
ok(await checkDataForAboutURL(), "We have data for about:newtab");
|
||||
|
||||
// Cleaning up.
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
ok(await checkDataForAboutURL(), "about:newtab data is not deleted.");
|
||||
|
||||
// Clean up.
|
||||
await Sanitizer.sanitize([ "cookies", "offlineApps" ]);
|
||||
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("about:newtab");
|
||||
await new Promise(aResolve => {
|
||||
let req = Services.qms.clearStoragesForPrincipal(principal);
|
||||
req.callback = () => { aResolve(); };
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function deleteStorageOnlyCustomPermissionInAboutURL() {
|
||||
info("Test about:newtab + permissions");
|
||||
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", Ci.nsICookieService.ACCEPT_NORMALLY],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Custom permission without considering OriginAttributes
|
||||
let uri = Services.io.newURI("about:newtab");
|
||||
Services.perms.add(uri, "cookie", Ci.nsICookiePermission.ACCESS_SESSION);
|
||||
|
||||
// Let's create a tab with some data.
|
||||
await SiteDataTestUtils.addToIndexedDB("about:newtab", "foo", "bar", {});
|
||||
|
||||
ok(await checkDataForAboutURL(), "We have data for about:newtab");
|
||||
|
||||
// Cleaning up.
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
ok(await checkDataForAboutURL(), "about:newtab data is not deleted.");
|
||||
|
||||
// Clean up.
|
||||
await Sanitizer.sanitize([ "cookies", "offlineApps" ]);
|
||||
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("about:newtab");
|
||||
await new Promise(aResolve => {
|
||||
let req = Services.qms.clearStoragesForPrincipal(principal);
|
||||
req.callback = () => { aResolve(); };
|
||||
});
|
||||
|
||||
Services.perms.remove(uri, "cookie");
|
||||
});
|
||||
|
||||
// 2 domains: www.mozilla.org (session-only) mozilla.org (allowed) - after the
|
||||
// cleanp, mozilla.org must have data.
|
||||
add_task(async function subDomains() {
|
||||
info("Test subdomains and custom setting");
|
||||
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", Ci.nsICookieService.ACCEPT_NORMALLY ],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Domains and data
|
||||
let uriA = Services.io.newURI("https://www.mozilla.org");
|
||||
Services.perms.add(uriA, "cookie", Ci.nsICookiePermission.ACCESS_SESSION);
|
||||
|
||||
Services.cookies.add(uriA.host, "/test", "a", "b",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, {},
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
|
||||
await createIndexedDB(uriA.host, {});
|
||||
|
||||
let uriB = Services.io.newURI("https://mozilla.org");
|
||||
Services.perms.add(uriB, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW);
|
||||
|
||||
Services.cookies.add(uriB.host, "/test", "c", "d",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, {},
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
|
||||
await createIndexedDB(uriB.host, {});
|
||||
|
||||
// Check
|
||||
ok(await checkCookie(uriA.host, {}), "We have cookies for URI: " + uriA.host);
|
||||
ok(await checkIndexedDB(uriA.host, {}), "We have IDB for URI: " + uriA.host);
|
||||
ok(await checkCookie(uriB.host, {}), "We have cookies for URI: " + uriB.host);
|
||||
ok(await checkIndexedDB(uriB.host, {}), "We have IDB for URI: " + uriB.host);
|
||||
|
||||
// Cleaning up
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
// Check again
|
||||
ok(!(await checkCookie(uriA.host, {})), "We should not have cookies for URI: " + uriA.host);
|
||||
ok(!(await checkIndexedDB(uriA.host, {})), "We should not have IDB for URI: " + uriA.host);
|
||||
|
||||
// Note that cookies are stored per base domain...
|
||||
ok(!(await checkCookie(uriB.host, {})), "We should not have cookies for URI: " + uriB.host);
|
||||
ok(await checkIndexedDB(uriB.host, {}), "We should have IDB for URI: " + uriB.host);
|
||||
|
||||
// Cleaning up permissions
|
||||
Services.perms.remove(uriA, "cookie");
|
||||
Services.perms.remove(uriB, "cookie");
|
||||
});
|
||||
runAllCookiePermissionTests({name: "default", oa: {}});
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
const {Sanitizer} = ChromeUtils.import("resource:///modules/Sanitizer.jsm");
|
||||
const {SiteDataTestUtils} = ChromeUtils.import("resource://testing-common/SiteDataTestUtils.jsm");
|
||||
|
||||
function checkDataForAboutURL() {
|
||||
return new Promise(resolve => {
|
||||
let data = true;
|
||||
let uri = Services.io.newURI("about:newtab");
|
||||
let principal =
|
||||
Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||
let request = indexedDB.openForPrincipal(principal, "TestDatabase", 1);
|
||||
request.onupgradeneeded = function(e) {
|
||||
data = false;
|
||||
};
|
||||
request.onsuccess = function(e) {
|
||||
resolve(data);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function deleteStorageInAboutURL() {
|
||||
info("Test about:newtab");
|
||||
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", Ci.nsICookieService.ACCEPT_SESSION],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Let's create a tab with some data.
|
||||
await SiteDataTestUtils.addToIndexedDB("about:newtab", "foo", "bar", {});
|
||||
|
||||
ok(await checkDataForAboutURL(), "We have data for about:newtab");
|
||||
|
||||
// Cleaning up.
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
ok(await checkDataForAboutURL(), "about:newtab data is not deleted.");
|
||||
|
||||
// Clean up.
|
||||
await Sanitizer.sanitize([ "cookies", "offlineApps" ]);
|
||||
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("about:newtab");
|
||||
await new Promise(aResolve => {
|
||||
let req = Services.qms.clearStoragesForPrincipal(principal);
|
||||
req.callback = () => { aResolve(); };
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function deleteStorageOnlyCustomPermissionInAboutURL() {
|
||||
info("Test about:newtab + permissions");
|
||||
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", Ci.nsICookieService.ACCEPT_NORMALLY],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Custom permission without considering OriginAttributes
|
||||
let uri = Services.io.newURI("about:newtab");
|
||||
Services.perms.add(uri, "cookie", Ci.nsICookiePermission.ACCESS_SESSION);
|
||||
|
||||
// Let's create a tab with some data.
|
||||
await SiteDataTestUtils.addToIndexedDB("about:newtab", "foo", "bar", {});
|
||||
|
||||
ok(await checkDataForAboutURL(), "We have data for about:newtab");
|
||||
|
||||
// Cleaning up.
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
ok(await checkDataForAboutURL(), "about:newtab data is not deleted.");
|
||||
|
||||
// Clean up.
|
||||
await Sanitizer.sanitize([ "cookies", "offlineApps" ]);
|
||||
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("about:newtab");
|
||||
await new Promise(aResolve => {
|
||||
let req = Services.qms.clearStoragesForPrincipal(principal);
|
||||
req.callback = () => { aResolve(); };
|
||||
});
|
||||
|
||||
Services.perms.remove(uri, "cookie");
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
runAllCookiePermissionTests({name: "container", oa: {userContextId: 1}});
|
|
@ -0,0 +1,58 @@
|
|||
const {Sanitizer} = ChromeUtils.import("resource:///modules/Sanitizer.jsm");
|
||||
const {SiteDataTestUtils} = ChromeUtils.import("resource://testing-common/SiteDataTestUtils.jsm");
|
||||
|
||||
// 2 domains: www.mozilla.org (session-only) mozilla.org (allowed) - after the
|
||||
// cleanp, mozilla.org must have data.
|
||||
add_task(async function subDomains() {
|
||||
info("Test subdomains and custom setting");
|
||||
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", Ci.nsICookieService.ACCEPT_NORMALLY ],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Domains and data
|
||||
let uriA = Services.io.newURI("https://www.mozilla.org");
|
||||
Services.perms.add(uriA, "cookie", Ci.nsICookiePermission.ACCESS_SESSION);
|
||||
|
||||
Services.cookies.add(uriA.host, "/test", "a", "b",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, {},
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
|
||||
await createIndexedDB(uriA.host, {});
|
||||
|
||||
let uriB = Services.io.newURI("https://mozilla.org");
|
||||
Services.perms.add(uriB, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW);
|
||||
|
||||
Services.cookies.add(uriB.host, "/test", "c", "d",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, {},
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
|
||||
await createIndexedDB(uriB.host, {});
|
||||
|
||||
// Check
|
||||
ok(await checkCookie(uriA.host, {}), "We have cookies for URI: " + uriA.host);
|
||||
ok(await checkIndexedDB(uriA.host, {}), "We have IDB for URI: " + uriA.host);
|
||||
ok(await checkCookie(uriB.host, {}), "We have cookies for URI: " + uriB.host);
|
||||
ok(await checkIndexedDB(uriB.host, {}), "We have IDB for URI: " + uriB.host);
|
||||
|
||||
// Cleaning up
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
// Check again
|
||||
ok(!(await checkCookie(uriA.host, {})), "We should not have cookies for URI: " + uriA.host);
|
||||
ok(!(await checkIndexedDB(uriA.host, {})), "We should not have IDB for URI: " + uriA.host);
|
||||
|
||||
// Note that cookies are stored per base domain...
|
||||
ok(!(await checkCookie(uriB.host, {})), "We should not have cookies for URI: " + uriB.host);
|
||||
ok(await checkIndexedDB(uriB.host, {}), "We should have IDB for URI: " + uriB.host);
|
||||
|
||||
// Cleaning up permissions
|
||||
Services.perms.remove(uriA, "cookie");
|
||||
Services.perms.remove(uriB, "cookie");
|
||||
});
|
|
@ -5,5 +5,242 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
FormHistory: "resource://gre/modules/FormHistory.jsm",
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
Sanitizer: "resource:///modules/Sanitizer.jsm",
|
||||
SiteDataTestUtils: "resource://testing-common/SiteDataTestUtils.jsm",
|
||||
});
|
||||
|
||||
function createIndexedDB(host, originAttributes) {
|
||||
let uri = Services.io.newURI("https://" + host);
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, originAttributes);
|
||||
return SiteDataTestUtils.addToIndexedDB(principal.origin);
|
||||
}
|
||||
|
||||
function checkIndexedDB(host, originAttributes) {
|
||||
return new Promise(resolve => {
|
||||
let data = true;
|
||||
let uri = Services.io.newURI("https://" + host);
|
||||
let principal =
|
||||
Services.scriptSecurityManager.createCodebasePrincipal(uri,
|
||||
originAttributes);
|
||||
let request = indexedDB.openForPrincipal(principal, "TestDatabase", 1);
|
||||
request.onupgradeneeded = function(e) {
|
||||
data = false;
|
||||
};
|
||||
request.onsuccess = function(e) {
|
||||
resolve(data);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createHostCookie(host, originAttributes) {
|
||||
Services.cookies.add(host, "/test", "foo", "bar",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, originAttributes,
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
}
|
||||
|
||||
function createDomainCookie(host, originAttributes) {
|
||||
Services.cookies.add("." + host, "/test", "foo", "bar",
|
||||
false, false, false, Date.now() + 24000 * 60 * 60, originAttributes,
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
}
|
||||
|
||||
function checkCookie(host, originAttributes) {
|
||||
for (let cookie of Services.cookies.enumerator) {
|
||||
if (ChromeUtils.isOriginAttributesEqual(originAttributes,
|
||||
cookie.originAttributes) &&
|
||||
cookie.host.includes(host)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function deleteOnShutdown(opt) {
|
||||
// Let's clean up all the data.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.lifetimePolicy", opt.lifetimePolicy],
|
||||
["browser.sanitizer.loglevel", "All"],
|
||||
]});
|
||||
|
||||
// Custom permission without considering OriginAttributes
|
||||
if (opt.cookiePermission !== undefined) {
|
||||
let uri = Services.io.newURI("https://www.example.com");
|
||||
Services.perms.add(uri, "cookie", opt.cookiePermission);
|
||||
}
|
||||
|
||||
// Let's create a tab with some data.
|
||||
await opt.createData((opt.fullHost ? "www." : "") + "example.org",
|
||||
opt.originAttributes);
|
||||
ok(await opt.checkData((opt.fullHost ? "www." : "") + "example.org",
|
||||
opt.originAttributes),
|
||||
"We have data for www.example.org");
|
||||
await opt.createData((opt.fullHost ? "www." : "") + "example.com",
|
||||
opt.originAttributes);
|
||||
ok(await opt.checkData((opt.fullHost ? "www." : "") + "example.com",
|
||||
opt.originAttributes),
|
||||
"We have data for www.example.com");
|
||||
|
||||
// Cleaning up.
|
||||
await Sanitizer.runSanitizeOnShutdown();
|
||||
|
||||
// All gone!
|
||||
is(!!(await opt.checkData((opt.fullHost ? "www." : "") + "example.org",
|
||||
opt.originAttributes)),
|
||||
opt.expectedForOrg, "Do we have data for www.example.org?");
|
||||
is(!!(await opt.checkData((opt.fullHost ? "www." : "") + "example.com",
|
||||
opt.originAttributes)),
|
||||
opt.expectedForCom, "Do we have data for www.example.com?");
|
||||
|
||||
// Clean up.
|
||||
await Sanitizer.sanitize([ "cookies", "offlineApps" ]);
|
||||
|
||||
if (opt.cookiePermission !== undefined) {
|
||||
let uri = Services.io.newURI("https://www.example.com");
|
||||
Services.perms.remove(uri, "cookie");
|
||||
}
|
||||
}
|
||||
|
||||
function runAllCookiePermissionTests(originAttributes) {
|
||||
let tests = [
|
||||
{ name: "IDB",
|
||||
createData: createIndexedDB,
|
||||
checkData: checkIndexedDB },
|
||||
{ name: "Host Cookie",
|
||||
createData: createHostCookie,
|
||||
checkData: checkCookie },
|
||||
{ name: "Domain Cookie",
|
||||
createData: createDomainCookie,
|
||||
checkData: checkCookie },
|
||||
];
|
||||
|
||||
// Delete all, no custom permission, data in example.com, cookie permission set
|
||||
// for www.example.com
|
||||
tests.forEach(methods => {
|
||||
add_task(async function deleteStorageOnShutdown() {
|
||||
info(methods.name + ": Delete all, no custom permission, data in example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: undefined,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: false,
|
||||
fullHost: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Delete all, no custom permission, data in www.example.com, cookie permission
|
||||
// set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
add_task(async function deleteStorageOnShutdown() {
|
||||
info(methods.name + ": Delete all, no custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: undefined,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: false,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is session, but with ALLOW custom permission, data in example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
add_task(async function deleteStorageWithCustomPermission() {
|
||||
info(methods.name + ": All is session, but with ALLOW custom permission, data in example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_ALLOW,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: true,
|
||||
fullHost: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is session, but with ALLOW custom permission, data in www.example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
add_task(async function deleteStorageWithCustomPermission() {
|
||||
info(methods.name + ": All is session, but with ALLOW custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_ALLOW,
|
||||
expectedForOrg: false,
|
||||
expectedForCom: true,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is default, but with SESSION custom permission, data in example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
add_task(async function deleteStorageOnlyCustomPermission() {
|
||||
info(methods.name + ": All is default, but with SESSION custom permission, data in example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_NORMALLY,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_SESSION,
|
||||
expectedForOrg: true,
|
||||
// expected data just for example.com when using indexedDB because
|
||||
// QuotaManager deletes for principal.
|
||||
expectedForCom: false,
|
||||
fullHost: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// All is default, but with SESSION custom permission, data in www.example.com,
|
||||
// cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
add_task(async function deleteStorageOnlyCustomPermission() {
|
||||
info(methods.name + ": All is default, but with SESSION custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_NORMALLY,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: Ci.nsICookiePermission.ACCESS_SESSION,
|
||||
expectedForOrg: true,
|
||||
expectedForCom: false,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Session mode, but with unsupported custom permission, data in
|
||||
// www.example.com, cookie permission set for www.example.com
|
||||
tests.forEach(methods => {
|
||||
add_task(async function deleteStorageOnlyCustomPermission() {
|
||||
info(methods.name + ": All is session only, but with unsupported custom custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
|
||||
await deleteOnShutdown(
|
||||
{ lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
|
||||
createData: methods.createData,
|
||||
checkData: methods.checkData,
|
||||
originAttributes: originAttributes.oa,
|
||||
cookiePermission: 123, // invalid cookie permission
|
||||
expectedForOrg: false,
|
||||
expectedForCom: false,
|
||||
fullHost: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ add_task(async function searchbar_in_panel() {
|
|||
await document.getElementById("nav-bar").overflowable.show();
|
||||
|
||||
let searchbar = document.getElementById("searchbar");
|
||||
await waitForCondition(() => "value" in searchbar && searchbar.value === "");
|
||||
await TestUtils.waitForCondition(() => "value" in searchbar && searchbar.value === "");
|
||||
|
||||
// Focusing a non-empty searchbox will cause us to open the
|
||||
// autocomplete panel and search for suggestions, which would
|
||||
|
|
|
@ -287,6 +287,10 @@ var gConnectionsDialog = {
|
|||
}
|
||||
},
|
||||
|
||||
isDnsOverHttpsLocked() {
|
||||
return Services.prefs.prefIsLocked("network.trr.mode");
|
||||
},
|
||||
|
||||
isDnsOverHttpsEnabled() {
|
||||
// values outside 1:4 are considered falsey/disabled in this context
|
||||
let trrPref = Preferences.get("network.trr.mode");
|
||||
|
@ -298,7 +302,7 @@ var gConnectionsDialog = {
|
|||
// called to update checked element property to reflect current pref value
|
||||
let enabled = this.isDnsOverHttpsEnabled();
|
||||
let uriPref = Preferences.get("network.trr.uri");
|
||||
uriPref.disabled = !enabled;
|
||||
uriPref.disabled = !enabled || this.isDnsOverHttpsLocked();
|
||||
return enabled;
|
||||
},
|
||||
|
||||
|
@ -319,7 +323,25 @@ var gConnectionsDialog = {
|
|||
customDnsOverHttpsUrlRadio.disabled = !parentCheckbox.checked;
|
||||
},
|
||||
|
||||
getDnsOverHttpsControls() {
|
||||
return [
|
||||
document.getElementById("networkDnsOverHttps"),
|
||||
document.getElementById("customDnsOverHttpsUrlRadio"),
|
||||
document.getElementById("defaultDnsOverHttpsUrlRadio"),
|
||||
document.getElementById("customDnsOverHttpsInput"),
|
||||
];
|
||||
},
|
||||
|
||||
disableDnsOverHttpsUI(disabled) {
|
||||
for (let element of this.getDnsOverHttpsControls()) {
|
||||
element.disabled = disabled;
|
||||
}
|
||||
},
|
||||
|
||||
initDnsOverHttpsUI() {
|
||||
// If we have a locked pref disable the UI.
|
||||
this.disableDnsOverHttpsUI(this.isDnsOverHttpsLocked());
|
||||
|
||||
let defaultDnsOverHttpsUrlRadio = document.getElementById("defaultDnsOverHttpsUrlRadio");
|
||||
let defaultPrefUrl = Preferences.get("network.trr.uri").defaultValue;
|
||||
document.l10n.setAttributes(defaultDnsOverHttpsUrlRadio, "connection-dns-over-https-url-default", {
|
||||
|
|
|
@ -3724,7 +3724,8 @@ var SessionStoreInternal = {
|
|||
} else if (tabData.pinned &&
|
||||
tabbrowser.tabs[t] &&
|
||||
tabbrowser.tabs[t].pinned &&
|
||||
!tabbrowser.tabs[t].linkedPanel) {
|
||||
!tabbrowser.tabs[t].linkedPanel &&
|
||||
tabbrowser.tabs[t].userContextId == userContextId) {
|
||||
tab = tabbrowser.tabs[t];
|
||||
tabbrowser.activatePreopenedPinnedTab(tab);
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ class UrlbarInput {
|
|||
browser.lastLocationChange == lastLocationChange) {
|
||||
openParams.postData = data.postData;
|
||||
openParams.allowInheritPrincipal = data.mayInheritPrincipal;
|
||||
this._loadURL(data.url, where, openParams);
|
||||
this._loadURL(data.url, where, openParams, browser);
|
||||
}
|
||||
});
|
||||
return;
|
||||
|
@ -856,10 +856,10 @@ class UrlbarInput {
|
|||
* The POST data associated with a search submission.
|
||||
* @param {boolean} [params.allowInheritPrincipal]
|
||||
* If the principal may be inherited
|
||||
* @param {object} browser [optional] the browser to use for the load.
|
||||
*/
|
||||
_loadURL(url, openUILinkWhere, params) {
|
||||
let browser = this.window.gBrowser.selectedBrowser;
|
||||
|
||||
_loadURL(url, openUILinkWhere, params,
|
||||
browser = this.window.gBrowser.selectedBrowser) {
|
||||
this.value = url;
|
||||
browser.userTypedValue = url;
|
||||
|
||||
|
|
|
@ -566,7 +566,7 @@ class UrlbarView {
|
|||
}
|
||||
|
||||
_on_SelectedOneOffButtonChanged() {
|
||||
if (!this._queryContext) {
|
||||
if (!this.isOpen || !this._queryContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ subsuite = clipboard
|
|||
[browser_privateBrowsingWindowChange.js]
|
||||
skip-if = debug # Bug 1532034 - Leaks in debug mode.
|
||||
[browser_raceWithTabs.js]
|
||||
skip-if = true # Bug 1531787 - Fails with QuantumBar
|
||||
# skip-if = os == "linux" # Bug 1382456
|
||||
skip-if = os == "linux" # Bug 1382456
|
||||
[browser_redirect_error.js]
|
||||
support-files = redirect_error.sjs
|
||||
[browser_remotetab.js]
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
const TEST_URL = `${TEST_BASE_URL}dummy_page.html`;
|
||||
|
||||
async function addBookmark(bookmark) {
|
||||
info("Creating bookmark and keyword");
|
||||
let bm = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: bookmark.url,
|
||||
title: bookmark.title,
|
||||
});
|
||||
if (bookmark.keyword) {
|
||||
await PlacesUtils.keywords.insert({
|
||||
keyword: bookmark.keyword,
|
||||
|
@ -11,50 +17,56 @@ async function addBookmark(bookmark) {
|
|||
});
|
||||
}
|
||||
|
||||
let bm = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: bookmark.url,
|
||||
title: bookmark.title,
|
||||
});
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await PlacesUtils.bookmarks.remove(bm);
|
||||
if (bookmark.keyword) {
|
||||
await PlacesUtils.keywords.remove(bookmark.keyword);
|
||||
}
|
||||
await PlacesUtils.bookmarks.remove(bm);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that if the user hits enter and ctrl-t at the same time, we open the URL in the right tab.
|
||||
* Check that if the user hits enter and ctrl-t at the same time, we open the
|
||||
* URL in the right tab.
|
||||
*/
|
||||
add_task(async function hitEnterLoadInRightTab() {
|
||||
info("Opening new tab");
|
||||
let oldTabCreatedPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen");
|
||||
BrowserOpenTab();
|
||||
let oldTab = (await oldTabCreatedPromise).target;
|
||||
let oldTabLoadedPromise = BrowserTestUtils.browserLoaded(oldTab.linkedBrowser, false, TEST_URL);
|
||||
oldTabLoadedPromise.then(() => info("Old tab loaded"));
|
||||
let newTabCreatedPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen");
|
||||
await addBookmark({
|
||||
title: "Test for keyword bookmark and URL",
|
||||
url: TEST_URL,
|
||||
keyword: "urlbarkeyword",
|
||||
});
|
||||
|
||||
info("Opening a tab");
|
||||
let oldTabOpenPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer,
|
||||
"TabOpen");
|
||||
BrowserOpenTab();
|
||||
let oldTab = (await oldTabOpenPromise).target;
|
||||
let oldTabLoadedPromise = BrowserTestUtils.browserLoaded(oldTab.linkedBrowser,
|
||||
false, TEST_URL);
|
||||
oldTabLoadedPromise.then(() => info("Old tab loaded"));
|
||||
|
||||
info("Creating bookmark and keyword");
|
||||
await addBookmark({title: "Test for keyword bookmark and URL", url: TEST_URL, keyword: "urlbarkeyword"});
|
||||
info("Filling URL bar, sending <return> and opening a tab");
|
||||
let tabOpenPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer,
|
||||
"TabOpen");
|
||||
gURLBar.value = "urlbarkeyword";
|
||||
gURLBar.focus();
|
||||
gURLBar.select();
|
||||
EventUtils.sendKey("return");
|
||||
|
||||
info("Immediately open a second tab");
|
||||
BrowserOpenTab();
|
||||
info("Waiting for new tab");
|
||||
let newTab = (await newTabCreatedPromise).target;
|
||||
let newTab = (await tabOpenPromise).target;
|
||||
|
||||
info("Created new tab; waiting for either tab to load");
|
||||
let newTabLoadedPromise = BrowserTestUtils.browserLoaded(newTab.linkedBrowser, false, TEST_URL);
|
||||
let newTabLoadedPromise = BrowserTestUtils.browserLoaded(newTab.linkedBrowser,
|
||||
false, TEST_URL);
|
||||
newTabLoadedPromise.then(() => info("New tab loaded"));
|
||||
await Promise.race([newTabLoadedPromise, oldTabLoadedPromise]);
|
||||
is(newTab.linkedBrowser.currentURI.spec, "about:newtab", "New tab still has about:newtab");
|
||||
is(newTab.linkedBrowser.currentURI.spec, "about:newtab",
|
||||
"New tab still has about:newtab");
|
||||
is(oldTab.linkedBrowser.currentURI.spec, TEST_URL, "Old tab loaded URL");
|
||||
info("Closing new tab");
|
||||
|
||||
info("Closing tabs");
|
||||
BrowserTestUtils.removeTab(newTab);
|
||||
info("Closing old tab");
|
||||
BrowserTestUtils.removeTab(oldTab);
|
||||
info("Finished");
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ DIRS += [
|
|||
'src',
|
||||
]
|
||||
|
||||
include('node-templates.mozbuild')
|
||||
include('../../shared/build/node-templates.mozbuild')
|
||||
|
||||
DevToolsModules(
|
||||
'panel.js',
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
@template
|
||||
def DebuggerModules(*modules):
|
||||
# Compute where to put transpiled files into omni.ja package
|
||||
# All DevTools modules are used via resource://devtools/ URI
|
||||
# See devtools/shared/jar.mn for how this resource is mapped into jar package.
|
||||
base = FINAL_TARGET_FILES.chrome.devtools.modules
|
||||
|
||||
# Now, navigate to the right sub-directory into devtools root modules folder
|
||||
for dir in RELATIVEDIR.split('/'):
|
||||
base = base[dir]
|
||||
|
||||
size = 0
|
||||
for m in modules:
|
||||
base += ["!" + m]
|
||||
size += 1
|
||||
|
||||
if size == 0:
|
||||
return
|
||||
|
||||
# For the same reason as https://searchfox.org/mozilla-central/source/mobile/android/base/moz.build#180-184
|
||||
# we have to insert a first entry as recursivemake overrides the first entry and we end up with empty files
|
||||
# for the first file only.
|
||||
outputs = tuple(("node.stub",) + modules)
|
||||
GENERATED_FILES += [outputs]
|
||||
|
||||
bundle = GENERATED_FILES[outputs]
|
||||
bundle.script = '/python/mozbuild/mozbuild/action/node.py:generate'
|
||||
bundle.inputs = ['/devtools/client/debugger/new/build/copy-module.js']
|
||||
bundle.inputs.extend(modules)
|
|
@ -7,6 +7,6 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'setInScopeLines.js',
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'addBreakpoint.js',
|
||||
'breakpointPositions.js',
|
||||
'index.js',
|
||||
|
|
|
@ -11,7 +11,7 @@ DIRS += [
|
|||
'utils',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'ast.js',
|
||||
'debuggee.js',
|
||||
'event-listeners.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'breakOnNext.js',
|
||||
'commands.js',
|
||||
'continueToHere.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'blackbox.js',
|
||||
'index.js',
|
||||
'loadSourceText.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'history.js',
|
||||
'log.js',
|
||||
'promise.js',
|
||||
|
|
|
@ -7,6 +7,6 @@ DIRS += [
|
|||
'middleware',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'create-store.js',
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'commands.js',
|
||||
'create.js',
|
||||
'events.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'commands.js',
|
||||
'create.js',
|
||||
'events.js',
|
||||
|
|
|
@ -8,7 +8,7 @@ DIRS += [
|
|||
'firefox',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'chrome.js',
|
||||
'firefox.js',
|
||||
'index.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'index.js',
|
||||
'Popup.js',
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'breakpoints.js',
|
||||
'editor.js',
|
||||
'source.js',
|
||||
|
|
|
@ -8,7 +8,7 @@ DIRS += [
|
|||
'Preview',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'Breakpoint.js',
|
||||
'Breakpoints.js',
|
||||
'ColumnBreakpoint.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'index.js',
|
||||
'Outline.js',
|
||||
'OutlineFilter.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'Breakpoint.js',
|
||||
'BreakpointHeading.js',
|
||||
'BreakpointHeadingsContextMenu.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'Frame.js',
|
||||
'FrameIndent.js',
|
||||
'FrameMenu.js',
|
||||
|
|
|
@ -8,7 +8,7 @@ DIRS += [
|
|||
'Frames',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'CommandBar.js',
|
||||
'EventListeners.js',
|
||||
'Expressions.js',
|
||||
|
|
|
@ -10,7 +10,7 @@ DIRS += [
|
|||
'shared',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'A11yIntention.js',
|
||||
'App.js',
|
||||
'ProjectSearch.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'CloseButton.js',
|
||||
'CommandBarButton.js',
|
||||
'index.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'CloseButton.css',
|
||||
'CommandBarButton.css',
|
||||
'PaneToggleButton.css',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
'Button',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'AccessibleImage.js',
|
||||
'Accordion.js',
|
||||
'Badge.js',
|
||||
|
|
|
@ -13,7 +13,7 @@ DIRS += [
|
|||
'workers',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'main.development.js',
|
||||
'main.js',
|
||||
'vendors.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'ast.js',
|
||||
'async-requests.js',
|
||||
'breakpoints.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'breakpointAtLocation.js',
|
||||
'breakpoints.js',
|
||||
'breakpointSources.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'astBreakpointLocation.js',
|
||||
'index.js',
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'create-editor.js',
|
||||
'get-expression.js',
|
||||
'get-token-location.js',
|
||||
|
|
|
@ -10,7 +10,7 @@ DIRS += [
|
|||
'sources-tree',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'assert.js',
|
||||
'ast.js',
|
||||
'asyncStoreHelper.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'annotateFrames.js',
|
||||
'collapseFrames.js',
|
||||
'displayName.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'buildGeneratedBindingList.js',
|
||||
'filtering.js',
|
||||
'findGeneratedBindingFromPosition.js',
|
||||
|
|
|
@ -9,7 +9,7 @@ DIRS += [
|
|||
'scopes',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'index.js',
|
||||
'why.js',
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'getScope.js',
|
||||
'getVariables.js',
|
||||
'index.js',
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'addToTree.js',
|
||||
'collapseTree.js',
|
||||
'createTree.js',
|
||||
|
|
|
@ -9,6 +9,6 @@ DIRS += [
|
|||
'search',
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
|
||||
)
|
||||
|
|
|
@ -7,6 +7,6 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'index.js',
|
||||
)
|
||||
|
|
|
@ -7,6 +7,6 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'index.js',
|
||||
)
|
||||
|
|
|
@ -7,6 +7,6 @@ DIRS += [
|
|||
|
||||
]
|
||||
|
||||
DebuggerModules(
|
||||
CompiledModules(
|
||||
'index.js',
|
||||
)
|
||||
|
|
|
@ -64,7 +64,7 @@ class ChangesContextMenu {
|
|||
// Copy Rule option
|
||||
menu.append(new MenuItem({
|
||||
label: getStr("changes.contextmenu.copyRule"),
|
||||
click: () => this._onCopyRule(ruleId),
|
||||
click: () => this._onCopyRule(ruleId, true),
|
||||
}));
|
||||
|
||||
// Copy Declaration option. Visible only if there is a declaration element target.
|
||||
|
|
|
@ -18,7 +18,11 @@ const { getChangesStylesheet } = require("./selectors/changes");
|
|||
const {
|
||||
TELEMETRY_SCALAR_CONTEXTMENU,
|
||||
TELEMETRY_SCALAR_CONTEXTMENU_COPY,
|
||||
TELEMETRY_SCALAR_CONTEXTMENU_COPY_DECLARATION,
|
||||
TELEMETRY_SCALAR_CONTEXTMENU_COPY_RULE,
|
||||
TELEMETRY_SCALAR_COPY,
|
||||
TELEMETRY_SCALAR_COPY_ALL_CHANGES,
|
||||
TELEMETRY_SCALAR_COPY_RULE,
|
||||
} = require("./constants");
|
||||
|
||||
const {
|
||||
|
@ -113,6 +117,7 @@ class ChangesView {
|
|||
*/
|
||||
copyAllChanges() {
|
||||
this.copyChanges();
|
||||
this.telemetry.scalarAdd(TELEMETRY_SCALAR_COPY_ALL_CHANGES, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,20 +165,30 @@ class ChangesView {
|
|||
const isRemoved = element.classList.contains("diff-remove");
|
||||
const text = isRemoved ? `/* ${name}: ${value}; */` : `${name}: ${value};`;
|
||||
clipboardHelper.copyString(text);
|
||||
this.telemetry.scalarAdd(TELEMETRY_SCALAR_CONTEXTMENU_COPY_DECLARATION, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the "Copy Rule" option from the context menu.
|
||||
* Handler for the "Copy Rule" option from the context menu and "Copy Rule" button.
|
||||
* Gets the full content of the target CSS rule (including any changes applied)
|
||||
* and copies it to the clipboard.
|
||||
*
|
||||
* @param {String} ruleId
|
||||
* Rule id of the target CSS rule.
|
||||
* @param {Boolean} usingContextMenu
|
||||
* True if the handler is invoked from the context menu.
|
||||
* (Default) False if invoked from the button.
|
||||
*/
|
||||
async copyRule(ruleId) {
|
||||
async copyRule(ruleId, usingContextMenu = false) {
|
||||
const rule = await this.inspector.pageStyle.getRule(ruleId);
|
||||
const text = await rule.getRuleText();
|
||||
clipboardHelper.copyString(text);
|
||||
|
||||
if (usingContextMenu) {
|
||||
this.telemetry.scalarAdd(TELEMETRY_SCALAR_CONTEXTMENU_COPY_RULE, 1);
|
||||
} else {
|
||||
this.telemetry.scalarAdd(TELEMETRY_SCALAR_COPY_RULE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,10 @@ class ChangesApp extends PureComponent {
|
|||
return dom.button(
|
||||
{
|
||||
className: "changes__copy-all-changes-button",
|
||||
onClick: this.props.onCopyAllChanges,
|
||||
onClick: e => {
|
||||
e.stopPropagation();
|
||||
this.props.onCopyAllChanges();
|
||||
},
|
||||
title: getStr("changes.contextmenu.copyAllChangesDescription"),
|
||||
},
|
||||
getStr("changes.contextmenu.copyAllChanges")
|
||||
|
@ -50,6 +53,7 @@ class ChangesApp extends PureComponent {
|
|||
{
|
||||
className: "changes__copy-rule-button",
|
||||
onClick: e => {
|
||||
e.stopPropagation();
|
||||
this.props.onCopyRule(ruleId);
|
||||
},
|
||||
title: getStr("changes.contextmenu.copyRuleDescription"),
|
||||
|
|
|
@ -9,5 +9,10 @@
|
|||
module.exports = {
|
||||
TELEMETRY_SCALAR_CONTEXTMENU: "devtools.changesview.contextmenu",
|
||||
TELEMETRY_SCALAR_CONTEXTMENU_COPY: "devtools.changesview.contextmenu_copy",
|
||||
TELEMETRY_SCALAR_CONTEXTMENU_COPY_DECLARATION:
|
||||
"devtools.changesview.contextmenu_copy_declaration",
|
||||
TELEMETRY_SCALAR_CONTEXTMENU_COPY_RULE: "devtools.changesview.contextmenu_copy_rule",
|
||||
TELEMETRY_SCALAR_COPY: "devtools.changesview.copy",
|
||||
TELEMETRY_SCALAR_COPY_ALL_CHANGES: "devtools.changesview.copy_all_changes",
|
||||
TELEMETRY_SCALAR_COPY_RULE: "devtools.changesview.copy_rule",
|
||||
};
|
||||
|
|
|
@ -218,8 +218,6 @@ devtools.jar:
|
|||
skin/images/arrow-e.svg (themes/images/arrow-e.svg)
|
||||
skin/images/search-clear.svg (themes/images/search-clear.svg)
|
||||
skin/images/reload.svg (themes/images/reload.svg)
|
||||
skin/images/file-type-general.svg (netmonitor/src/assets/icons/file-type-general.svg)
|
||||
skin/images/file-type-image.svg (netmonitor/src/assets/icons/file-type-image.svg)
|
||||
skin/images/security-state-broken.svg (themes/images/security-state-broken.svg)
|
||||
skin/images/security-state-insecure.svg (themes/images/security-state-insecure.svg)
|
||||
skin/images/security-state-secure.svg (themes/images/security-state-secure.svg)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<svg width="16" height="16" fill="context-fill #0B0B0B" fill-rule="evenodd" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3 14.001L2.996 14h9.008l-.004.002V6l.293.707-4-4L9 3H3.003L3 2.999V14zm-1 0V3C2 2.447 2.449 2 3.003 2H9l4 4v8.002a.996.996 0 0 1-.996.998H2.996A.996.996 0 0 1 2 14.001z"/>
|
||||
<path d="M4.5 9H11V8H4v1h.5zM4.5 11H11v-1H4v1h.5zM4.5 13H11v-1H4v1h.5zM4.5 5H7V4H4v1h.5zM4.5 7H7V6H4v1h.5zM8 7h5V6H9V2H8v5z"/>
|
||||
</svg>
|
До Ширина: | Высота: | Размер: 644 B |
|
@ -1,7 +0,0 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<svg width="16" height="16" fill="context-fill #0B0B0B" fill-rule="evenodd" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3 14.001L2.996 14h9.008l-.004.002V6l.293.707-4-4L9 3H3.003L3 2.999V14zm-1 0V3C2 2.447 2.449 2 3.003 2H9l4 4v8.002a.996.996 0 0 1-.996.998H2.996A.996.996 0 0 1 2 14.001z"/>
|
||||
<path d="M8 7h5V6H9V2H8v5z"/>
|
||||
</svg>
|
До Ширина: | Высота: | Размер: 547 B |
|
@ -242,28 +242,10 @@
|
|||
text-align: start;
|
||||
}
|
||||
|
||||
.requests-file-type-icon {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 0 4px;
|
||||
vertical-align: text-bottom;
|
||||
-moz-context-properties: fill;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.request-list-item.selected .requests-file-type-icon {
|
||||
.request-list-item.selected {
|
||||
filter: brightness(1.3);
|
||||
}
|
||||
|
||||
.file-type-general {
|
||||
background-image: url(chrome://devtools/skin/images/file-type-general.svg);
|
||||
}
|
||||
|
||||
.file-type-image {
|
||||
background-image: url(chrome://devtools/skin/images/file-type-image.svg);
|
||||
}
|
||||
|
||||
/* Protocol column */
|
||||
|
||||
.requests-list-protocol {
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
const { Component } = require("devtools/client/shared/vendor/react");
|
||||
const dom = require("devtools/client/shared/vendor/react-dom-factories");
|
||||
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
||||
const { propertiesEqual, getFileName } = require("../utils/request-utils");
|
||||
|
||||
const { div } = dom;
|
||||
const { propertiesEqual } = require("../utils/request-utils");
|
||||
|
||||
const UPDATED_FILE_PROPS = [
|
||||
"urlDetails",
|
||||
|
@ -28,28 +26,14 @@ class RequestListColumnFile extends Component {
|
|||
|
||||
render() {
|
||||
const {
|
||||
item: { urlDetails, cause },
|
||||
item: { urlDetails },
|
||||
} = this.props;
|
||||
const iconClassList = ["requests-file-type-icon"];
|
||||
|
||||
if (cause && (
|
||||
cause.type.includes("img") ||
|
||||
cause.type.includes("image") ||
|
||||
cause.type.includes("beacon"))) {
|
||||
iconClassList.push("file-type-image");
|
||||
} else {
|
||||
iconClassList.push("file-type-general");
|
||||
}
|
||||
|
||||
return (
|
||||
dom.td({
|
||||
className: "requests-list-column requests-list-file",
|
||||
title: urlDetails.unicodeUrl,
|
||||
},
|
||||
div({
|
||||
className: iconClassList.join(" "),
|
||||
title: getFileName(urlDetails.baseNameWithQuery) || urlDetails.unicodeUrl,
|
||||
}),
|
||||
urlDetails.baseNameWithQuery
|
||||
)
|
||||
);
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
/* globals process, __filename, __dirname */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Babel = require("./babel");
|
||||
const fs = require("fs");
|
||||
const _path = require("path");
|
||||
const { execFileSync } = require("child_process");
|
||||
|
||||
const EXCLUDED_FILES = {
|
||||
"../assets/panel/debugger.properties": "devtools/shared/flags",
|
||||
"devtools-connection": "devtools/shared/flags",
|
||||
"chrome-remote-interface": "devtools/shared/flags",
|
||||
"devtools-launchpad": "devtools/shared/flags"
|
||||
"devtools-launchpad": "devtools/shared/flags",
|
||||
};
|
||||
|
||||
const mappings = Object.assign(
|
||||
|
@ -30,7 +32,7 @@ const mappings = Object.assign(
|
|||
"prop-types": "devtools/client/shared/vendor/react-prop-types",
|
||||
"devtools-services": "Services",
|
||||
"wasmparser/dist/WasmParser": "devtools/client/shared/vendor/WasmParser",
|
||||
"wasmparser/dist/WasmDis": "devtools/client/shared/vendor/WasmDis"
|
||||
"wasmparser/dist/WasmDis": "devtools/client/shared/vendor/WasmDis",
|
||||
},
|
||||
EXCLUDED_FILES
|
||||
);
|
||||
|
@ -46,10 +48,6 @@ function isRequire(t, node) {
|
|||
return node && t.isCallExpression(node) && node.callee.name == "require";
|
||||
}
|
||||
|
||||
function isImport(t, node) {
|
||||
return node && t.isImportDeclaration(node);
|
||||
}
|
||||
|
||||
// List of vendored modules.
|
||||
// Should be synchronized with vendors.js
|
||||
const VENDORS = [
|
||||
|
@ -66,27 +64,27 @@ const VENDORS = [
|
|||
"react-aria-components/src/tabs",
|
||||
"react-transition-group/Transition",
|
||||
"reselect",
|
||||
"Svg"
|
||||
"Svg",
|
||||
];
|
||||
|
||||
const moduleMapping = {
|
||||
Telemetry: "devtools/client/shared/telemetry",
|
||||
asyncStorage: "devtools/shared/async-storage"
|
||||
asyncStorage: "devtools/shared/async-storage",
|
||||
};
|
||||
|
||||
/*
|
||||
* Updates devtools-modules imports such as
|
||||
* `import { Telemetry } from "devtools-modules"`
|
||||
* so that we can customize how we resolve certain modules in the package
|
||||
*
|
||||
* In the case of multiple declarations we need to move
|
||||
* the telemetry module into its own import.
|
||||
*/
|
||||
* Updates devtools-modules imports such as
|
||||
* `import { Telemetry } from "devtools-modules"`
|
||||
* so that we can customize how we resolve certain modules in the package
|
||||
*
|
||||
* In the case of multiple declarations we need to move
|
||||
* the telemetry module into its own import.
|
||||
*/
|
||||
function updateDevtoolsModulesImport(path, t) {
|
||||
const specifiers = path.node.specifiers;
|
||||
|
||||
for (let i = 0; i < specifiers.length; i++) {
|
||||
let specifier = specifiers[i];
|
||||
const specifier = specifiers[i];
|
||||
const localName = specifier.local.name;
|
||||
if (localName in moduleMapping) {
|
||||
const newImport = t.importDeclaration(
|
||||
|
@ -108,9 +106,9 @@ function updateDevtoolsModulesImport(path, t) {
|
|||
}
|
||||
|
||||
/**
|
||||
* This Babel plugin is used to transpile a single Debugger module into a module that
|
||||
* can be loaded in Firefox via the regular DevTools loader.
|
||||
*/
|
||||
* This Babel plugin is used to transpile a single Debugger module into a module that
|
||||
* can be loaded in Firefox via the regular DevTools loader.
|
||||
*/
|
||||
function transformMC({ types: t }) {
|
||||
return {
|
||||
visitor: {
|
||||
|
@ -195,45 +193,22 @@ function transformMC({ types: t }) {
|
|||
!(value.startsWith("devtools") || mappingValues.includes(value))
|
||||
) {
|
||||
path.replaceWith(t.stringLiteral(`${value}/index`));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Babel.registerPlugin("transform-mc", transformMC);
|
||||
|
||||
function transform(filePath) {
|
||||
const doc = fs.readFileSync(filePath, "utf8");
|
||||
const out = Babel.transform(doc, {
|
||||
plugins: [
|
||||
"transform-flow-strip-types",
|
||||
"syntax-trailing-function-commas",
|
||||
"transform-class-properties",
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-react-jsx",
|
||||
"syntax-object-rest-spread",
|
||||
["transform-mc", { mappings, vendors: VENDORS, filePath }]
|
||||
]
|
||||
});
|
||||
|
||||
return out.code;
|
||||
}
|
||||
|
||||
const deps = [
|
||||
__filename,
|
||||
_path.resolve(__dirname, "babel.js")
|
||||
];
|
||||
|
||||
for (let i = 2; i < process.argv.length; i++) {
|
||||
const srcPath = process.argv[i];
|
||||
const code = transform(srcPath);
|
||||
const filePath = _path.basename(srcPath);
|
||||
fs.writeFileSync(filePath, code);
|
||||
deps.push(srcPath);
|
||||
}
|
||||
|
||||
// Print all dependencies prefixed with 'dep:' in order to help node.py, the script that
|
||||
// calls this module, to report back the precise list of all dependencies.
|
||||
console.log(deps.map(file => "dep:" + file).join("\n"));
|
||||
module.exports = function(filePath) {
|
||||
return [
|
||||
"transform-flow-strip-types",
|
||||
"syntax-trailing-function-commas",
|
||||
"transform-class-properties",
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-react-jsx",
|
||||
"syntax-object-rest-spread",
|
||||
["transform-mc", { mappings, vendors: VENDORS, filePath }],
|
||||
];
|
||||
};
|
|
@ -0,0 +1,45 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
/* globals process, __filename, __dirname */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Babel = require("./babel");
|
||||
const fs = require("fs");
|
||||
const _path = require("path");
|
||||
|
||||
const defaultPlugins = [
|
||||
"transform-flow-strip-types",
|
||||
"transform-class-properties",
|
||||
"transform-react-jsx",
|
||||
];
|
||||
|
||||
function transform(filePath) {
|
||||
// Use the extra plugins only for the debugger
|
||||
const plugins = filePath.includes("devtools/client/debugger/new")
|
||||
? require("./build-debugger")(filePath)
|
||||
: defaultPlugins;
|
||||
|
||||
const doc = fs.readFileSync(filePath, "utf8");
|
||||
const out = Babel.transform(doc, { plugins });
|
||||
|
||||
return out.code;
|
||||
}
|
||||
|
||||
const deps = [
|
||||
__filename,
|
||||
_path.resolve(__dirname, "babel.js"),
|
||||
];
|
||||
|
||||
for (let i = 2; i < process.argv.length; i++) {
|
||||
const srcPath = process.argv[i];
|
||||
const code = transform(srcPath);
|
||||
const filePath = _path.basename(srcPath);
|
||||
fs.writeFileSync(filePath, code);
|
||||
deps.push(srcPath);
|
||||
}
|
||||
|
||||
// Print all dependencies prefixed with 'dep:' in order to help node.py, the script that
|
||||
// calls this module, to report back the precise list of all dependencies.
|
||||
console.log(deps.map(file => "dep:" + file).join("\n"));
|
|
@ -0,0 +1,41 @@
|
|||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
@template
|
||||
def CompiledModules(*modules):
|
||||
# Compute where to put compiled files into omni.ja package
|
||||
# All DevTools modules are used via resource://devtools/ URI
|
||||
# See devtools/shared/jar.mn for how this resource is mapped into jar package.
|
||||
base = FINAL_TARGET_FILES.chrome.devtools.modules
|
||||
|
||||
compiled_directory_whitelist = (
|
||||
"devtools/client/debugger/new/src",
|
||||
)
|
||||
|
||||
if not RELATIVEDIR.startswith(compiled_directory_whitelist):
|
||||
error("File in directory provided to CompiledModules not allowed: " + RELATIVEDIR)
|
||||
|
||||
# Now, navigate to the right sub-directory into devtools root modules folder
|
||||
for dir in RELATIVEDIR.split('/'):
|
||||
base = base[dir]
|
||||
|
||||
size = 0
|
||||
for m in modules:
|
||||
base += ["!" + m]
|
||||
size += 1
|
||||
|
||||
if size == 0:
|
||||
return
|
||||
|
||||
# For the same reason as https://searchfox.org/mozilla-central/source/mobile/android/base/moz.build#180-184
|
||||
# we have to insert a first entry as recursivemake overrides the first entry and we end up with empty files
|
||||
# for the first file only.
|
||||
outputs = tuple(("node.stub",) + modules)
|
||||
GENERATED_FILES += [outputs]
|
||||
|
||||
bundle = GENERATED_FILES[outputs]
|
||||
bundle.script = '/python/mozbuild/mozbuild/action/node.py:generate'
|
||||
bundle.inputs = ['/devtools/client/shared/build/build.js',]
|
||||
bundle.inputs.extend(modules)
|
|
@ -12,23 +12,43 @@ const TEST_URI = "data:text/html;charset=utf8,Clickable URLS";
|
|||
|
||||
add_task(async function() {
|
||||
const hud = await openNewTabAndConsole(TEST_URI);
|
||||
const currentTab = gBrowser.selectedTab;
|
||||
|
||||
const url = "http://example.com/";
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, url, function(uri) {
|
||||
content.wrappedJSObject.console.log(uri);
|
||||
const firstURL = "http://example.com/";
|
||||
const secondURL = "http://example.com/?id=secondURL";
|
||||
ContentTask.spawn(gBrowser.selectedBrowser, [firstURL, secondURL], (urls) => {
|
||||
content.wrappedJSObject.console.log("Visit ", urls[0], " and ", urls[1]);
|
||||
});
|
||||
|
||||
const node = await waitFor(() => findMessage(hud, url));
|
||||
const link = node.querySelector("a.url");
|
||||
const node = await waitFor(() => findMessage(hud, firstURL));
|
||||
const [urlEl1, urlEl2] = Array.from(node.querySelectorAll("a.url"));
|
||||
|
||||
const onTabLoaded = BrowserTestUtils.waitForNewTab(gBrowser, url, true);
|
||||
let onTabLoaded = BrowserTestUtils.waitForNewTab(gBrowser, firstURL, true);
|
||||
|
||||
info("Clicking on the link");
|
||||
link.click();
|
||||
info("Clicking on the first link");
|
||||
urlEl1.click();
|
||||
|
||||
const newTab = await onTabLoaded;
|
||||
let newTab = await onTabLoaded;
|
||||
// We only need to check that newTab is truthy since
|
||||
// BrowserTestUtils.waitForNewTab checks the URL.
|
||||
ok(newTab, "The expected tab was opened.");
|
||||
BrowserTestUtils.removeTab(newTab);
|
||||
|
||||
info("Select the first tab again");
|
||||
gBrowser.selectedTab = currentTab;
|
||||
|
||||
info("Ctrl/Cmd + Click on the second link");
|
||||
onTabLoaded = BrowserTestUtils.waitForNewTab(gBrowser, secondURL, true);
|
||||
|
||||
const isMacOS = Services.appinfo.OS === "Darwin";
|
||||
EventUtils.sendMouseEvent({
|
||||
type: "click",
|
||||
[isMacOS ? "metaKey" : "ctrlKey"]: true,
|
||||
}, urlEl2, hud.ui.window);
|
||||
|
||||
newTab = await onTabLoaded;
|
||||
|
||||
ok(newTab, "The expected tab was opened.");
|
||||
is(newTab._tPos, currentTab._tPos + 1,
|
||||
"The new tab was opened in the position to the right of the current tab");
|
||||
is(gBrowser.selectedTab, currentTab, "The tab was opened in the background");
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ loader.lazyRequireGetter(this, "viewSource", "devtools/client/shared/view-source
|
|||
loader.lazyRequireGetter(this, "openDocLink", "devtools/client/shared/link", true);
|
||||
|
||||
var gHudId = 0;
|
||||
const isMacOS = Services.appinfo.OS === "Darwin";
|
||||
|
||||
/**
|
||||
* A WebConsole instance is an interactive console initialized *per target*
|
||||
|
@ -148,8 +149,11 @@ class WebConsole {
|
|||
* @param string link
|
||||
* The URL you want to open in a new tab.
|
||||
*/
|
||||
openLink(link, e) {
|
||||
openDocLink(link);
|
||||
openLink(link, e = {}) {
|
||||
openDocLink(link, {
|
||||
relatedToCurrent: true,
|
||||
inBackground: isMacOS ? e.metaKey : e.ctrlKey,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
var name = 'pb-window-cache';
|
||||
/* eslint-disable no-shadow */
|
||||
var name = "pb-window-cache";
|
||||
|
||||
function testMatch(browser) {
|
||||
return ContentTask.spawn(browser, name, function(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
content.caches.match('http://foo.com').then(function(response) {
|
||||
ok(false, 'caches.match() should not return success');
|
||||
content.caches.match("http://foo.com").then(function(response) {
|
||||
ok(false, "caches.match() should not return success");
|
||||
reject();
|
||||
}).catch(function(err) {
|
||||
is('SecurityError', err.name, 'caches.match() should throw SecurityError');
|
||||
is("SecurityError", err.name, "caches.match() should throw SecurityError");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -18,10 +19,10 @@ function testHas(browser) {
|
|||
return ContentTask.spawn(browser, name, function(name) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
content.caches.has(name).then(function(result) {
|
||||
ok(false, 'caches.has() should not return success');
|
||||
ok(false, "caches.has() should not return success");
|
||||
reject();
|
||||
}).catch(function(err) {
|
||||
is('SecurityError', err.name, 'caches.has() should throw SecurityError');
|
||||
is("SecurityError", err.name, "caches.has() should throw SecurityError");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -32,10 +33,10 @@ function testOpen(browser) {
|
|||
return ContentTask.spawn(browser, name, function(name) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
content.caches.open(name).then(function(c) {
|
||||
ok(false, 'caches.open() should not return success');
|
||||
ok(false, "caches.open() should not return success");
|
||||
reject();
|
||||
}).catch(function(err) {
|
||||
is('SecurityError', err.name, 'caches.open() should throw SecurityError');
|
||||
is("SecurityError", err.name, "caches.open() should throw SecurityError");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -46,10 +47,10 @@ function testDelete(browser) {
|
|||
return ContentTask.spawn(browser, name, function(name) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
content.caches.delete(name).then(function(result) {
|
||||
ok(false, 'caches.delete() should not return success');
|
||||
ok(false, "caches.delete() should not return success");
|
||||
reject();
|
||||
}).catch(function(err) {
|
||||
is('SecurityError', err.name, 'caches.delete() should throw SecurityError');
|
||||
is("SecurityError", err.name, "caches.delete() should throw SecurityError");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -60,10 +61,10 @@ function testKeys(browser) {
|
|||
return ContentTask.spawn(browser, name, function(name) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
content.caches.keys().then(function(names) {
|
||||
ok(false, 'caches.keys() should not return success');
|
||||
ok(false, "caches.keys() should not return success");
|
||||
reject();
|
||||
}).catch(function(err) {
|
||||
is('SecurityError', err.name, 'caches.keys() should throw SecurityError');
|
||||
is("SecurityError", err.name, "caches.keys() should throw SecurityError");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -74,20 +75,20 @@ function testOpen_worker(browser) {
|
|||
return ContentTask.spawn(browser, {}, function() {
|
||||
Cu.importGlobalProperties(["Blob"]);
|
||||
|
||||
let workerFunctionString = function () {
|
||||
let workerFunctionString = function() {
|
||||
caches.open("pb-worker-cache").then(function(cacheObject) {
|
||||
postMessage(cacheObject.toString());
|
||||
}, function (reason) {
|
||||
}, function(reason) {
|
||||
postMessage(reason.name);
|
||||
});
|
||||
}.toString();
|
||||
let workerBlobURL = content.URL.createObjectURL(
|
||||
new Blob(['(', workerFunctionString, ')()'],
|
||||
{ type : 'application/javascript' }));
|
||||
new Blob(["(", workerFunctionString, ")()"],
|
||||
{ type: "application/javascript" }));
|
||||
let worker = new content.Worker(workerBlobURL);
|
||||
content.URL.revokeObjectURL(workerBlobURL);
|
||||
return new Promise(function(resolve, reject) {
|
||||
worker.addEventListener("message", function (e) {
|
||||
worker.addEventListener("message", function(e) {
|
||||
let isGood = (e.data === "SecurityError");
|
||||
ok(isGood, "caches.open() should throw SecurityError from worker");
|
||||
isGood ? resolve() : reject();
|
||||
|
@ -99,8 +100,8 @@ function testOpen_worker(browser) {
|
|||
function test() {
|
||||
let privateWin, privateTab;
|
||||
waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [['dom.caches.enabled', true],
|
||||
['dom.caches.testing.enabled', true]]}
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.caches.enabled", true],
|
||||
["dom.caches.testing.enabled", true]]}
|
||||
).then(() => {
|
||||
return BrowserTestUtils.openNewBrowserWindow({private: true});
|
||||
}).then(pw => {
|
||||
|
|
|
@ -23,7 +23,7 @@ function runTests(testFile, order) {
|
|||
["dom.caches.testing.enabled", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true]]
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true]],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ function runTests(testFile, order) {
|
|||
}
|
||||
|
||||
function importDrivers() {
|
||||
/* import-globals-from worker_driver.js */
|
||||
/* import-globals-from serviceworker_driver.js */
|
||||
return Promise.all([loadScript("worker_driver.js"),
|
||||
loadScript("serviceworker_driver.js")]);
|
||||
}
|
||||
|
@ -73,10 +75,10 @@ function runTests(testFile, order) {
|
|||
if (event.data.context != "Window") {
|
||||
return;
|
||||
}
|
||||
if (event.data.type == 'finish') {
|
||||
if (event.data.type == "finish") {
|
||||
window.removeEventListener("message", onMessage);
|
||||
resolve();
|
||||
} else if (event.data.type == 'status') {
|
||||
} else if (event.data.type == "status") {
|
||||
ok(event.data.status, event.data.context + ": " + event.data.msg);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
<script>
|
||||
var context = "Window";
|
||||
function ok(a, msg) {
|
||||
parent.postMessage({type: 'status', status: !!a,
|
||||
msg: a + ": " + msg, context: context}, "*");
|
||||
parent.postMessage({type: "status", status: !!a,
|
||||
msg: a + ": " + msg, context}, "*");
|
||||
}
|
||||
|
||||
function is(a, b, msg) {
|
||||
parent.postMessage({type: 'status', status: a === b,
|
||||
msg: a + " === " + b + ": " + msg, context: context}, "*");
|
||||
parent.postMessage({type: "status", status: a === b,
|
||||
msg: a + " === " + b + ": " + msg, context}, "*");
|
||||
}
|
||||
|
||||
function testDone() {
|
||||
parent.postMessage({type: 'finish', context: context}, "*");
|
||||
parent.postMessage({type: "finish", context}, "*");
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// Touch CacheStorage, but then idle and do nothing.
|
||||
const name = 'idle_worker_cache';
|
||||
const name = "idle_worker_cache";
|
||||
var cache;
|
||||
self.caches.open(name).then(c => {
|
||||
cache = c;
|
||||
return self.caches.delete(name);
|
||||
}).then(_ => {
|
||||
postMessage('LOADED');
|
||||
postMessage("LOADED");
|
||||
});
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -9,17 +9,17 @@ function serviceWorkerTestExec(testFile) {
|
|||
registration.active;
|
||||
var iframe;
|
||||
|
||||
window.addEventListener("message",function onMessage(event) {
|
||||
window.addEventListener("message", function onMessage(event) {
|
||||
if (event.data.context != "ServiceWorker") {
|
||||
return;
|
||||
}
|
||||
if (event.data.type == 'finish') {
|
||||
if (event.data.type == "finish") {
|
||||
window.removeEventListener("message", onMessage);
|
||||
iframe.remove();
|
||||
registration.unregister()
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
} else if (event.data.type == 'status') {
|
||||
} else if (event.data.type == "status") {
|
||||
ok(event.data.status, event.data.context + ": " + event.data.msg);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,41 +1,43 @@
|
|||
var c = null
|
||||
/* global context testDone:true */
|
||||
|
||||
var c = null;
|
||||
var request = "http://example.com/hmm?q=foobar" + context;
|
||||
var response = new Response("This is some Response!");
|
||||
var name = 'snafu' + context;
|
||||
var foobar = 'foobar' + context;
|
||||
var name = "snafu" + context;
|
||||
var foobar = "foobar" + context;
|
||||
|
||||
ok(!!caches, 'caches object should be available on global');
|
||||
ok(!!caches, "caches object should be available on global");
|
||||
caches.open(name).then(function(openCache) {
|
||||
ok(openCache instanceof Cache, 'cache object should be resolved from caches.open');
|
||||
ok(openCache instanceof Cache, "cache object should be resolved from caches.open");
|
||||
return caches.has(name);
|
||||
}).then(function(hasResult) {
|
||||
ok(hasResult, 'caches.has() should resolve true');
|
||||
ok(hasResult, "caches.has() should resolve true");
|
||||
return caches.keys();
|
||||
}).then(function(keys) {
|
||||
ok(!!keys, 'caches.keys() should resolve to a truthy value');
|
||||
ok(keys.length >= 1, 'caches.keys() should resolve to an array of length at least 1');
|
||||
ok(keys.includes(name), 'caches.keys() should resolve to an array containing key');
|
||||
ok(!!keys, "caches.keys() should resolve to a truthy value");
|
||||
ok(keys.length >= 1, "caches.keys() should resolve to an array of length at least 1");
|
||||
ok(keys.includes(name), "caches.keys() should resolve to an array containing key");
|
||||
return caches.delete(name);
|
||||
}).then(function(deleteResult) {
|
||||
ok(deleteResult, 'caches.delete() should resolve true');
|
||||
ok(deleteResult, "caches.delete() should resolve true");
|
||||
return caches.has(name);
|
||||
}).then(function(hasMissingCache) {
|
||||
ok(!hasMissingCache, 'missing key should return false from has');
|
||||
ok(!hasMissingCache, "missing key should return false from has");
|
||||
}).then(function() {
|
||||
return caches.open(name);
|
||||
}).then(function(snafu) {
|
||||
return snafu.keys();
|
||||
}).then(function(empty) {
|
||||
is(0, empty.length, 'cache.keys() should resolve to an array of length 0');
|
||||
is(0, empty.length, "cache.keys() should resolve to an array of length 0");
|
||||
}).then(function() {
|
||||
return caches.open(name);
|
||||
}).then(function(snafu) {
|
||||
var req = './cachekey';
|
||||
var req = "./cachekey";
|
||||
var res = new Response("Hello world");
|
||||
return snafu.put('ftp://invalid', res).then(function() {
|
||||
ok(false, 'This should fail');
|
||||
}).catch(function (err) {
|
||||
is(err.name, 'TypeError', 'put() should throw TypeError for invalid scheme');
|
||||
return snafu.put("ftp://invalid", res).then(function() {
|
||||
ok(false, "This should fail");
|
||||
}).catch(function(err) {
|
||||
is(err.name, "TypeError", "put() should throw TypeError for invalid scheme");
|
||||
return snafu.put(req, res);
|
||||
}).then(function(v) {
|
||||
return snafu;
|
||||
|
@ -45,22 +47,22 @@ caches.open(name).then(function(openCache) {
|
|||
}).then(function(args) {
|
||||
var snafu = args[0];
|
||||
var keys = args[1];
|
||||
is(1, keys.length, 'cache.keys() should resolve to an array of length 1');
|
||||
ok(keys[0] instanceof Request, 'key should be a Request');
|
||||
ok(keys[0].url.match(/cachekey$/), 'Request URL should match original');
|
||||
return Promise.all([snafu, snafu.match(keys[0]), snafu.match('ftp://invalid')]);
|
||||
is(1, keys.length, "cache.keys() should resolve to an array of length 1");
|
||||
ok(keys[0] instanceof Request, "key should be a Request");
|
||||
ok(keys[0].url.match(/cachekey$/), "Request URL should match original");
|
||||
return Promise.all([snafu, snafu.match(keys[0]), snafu.match("ftp://invalid")]);
|
||||
}).then(function(args) {
|
||||
var snafu = args[0];
|
||||
var response = args[1];
|
||||
ok(response instanceof Response, 'value should be a Response');
|
||||
is(response.status, 200, 'Response status should be 200');
|
||||
is(undefined, args[2], 'Match with invalid scheme should resolve undefined');
|
||||
return Promise.all([snafu, snafu.put('./cachekey2', response)]);
|
||||
var res = args[1];
|
||||
ok(res instanceof Response, "value should be a Response");
|
||||
is(res.status, 200, "Response status should be 200");
|
||||
is(undefined, args[2], "Match with invalid scheme should resolve undefined");
|
||||
return Promise.all([snafu, snafu.put("./cachekey2", res)]);
|
||||
}).then(function(args) {
|
||||
var snafu = args[0]
|
||||
return snafu.match('./cachekey2');
|
||||
}).then(function(response) {
|
||||
return response.text().then(function(v) {
|
||||
var snafu = args[0];
|
||||
return snafu.match("./cachekey2");
|
||||
}).then(function(res) {
|
||||
return res.text().then(function(v) {
|
||||
is(v, "Hello world", "Response body should match original");
|
||||
});
|
||||
}).then(function() {
|
||||
|
@ -72,60 +74,60 @@ caches.open(name).then(function(openCache) {
|
|||
c = openCache;
|
||||
return c.put(request, response);
|
||||
}).then(function(putResponse) {
|
||||
is(putResponse, undefined, 'The promise should resolve to undefined');
|
||||
is(putResponse, undefined, "The promise should resolve to undefined");
|
||||
return c.keys(request);
|
||||
}).then(function(keys) {
|
||||
ok(keys, 'Valid keys object expected');
|
||||
is(keys.length, 1, 'Only one key is expected');
|
||||
ok(keys, "Valid keys object expected");
|
||||
is(keys.length, 1, "Only one key is expected");
|
||||
return c.keys();
|
||||
}).then(function(keys) {
|
||||
ok(keys, 'Valid keys object expected');
|
||||
is(keys.length, 1, 'Only one key is expected');
|
||||
ok(keys, "Valid keys object expected");
|
||||
is(keys.length, 1, "Only one key is expected");
|
||||
return c.matchAll(request);
|
||||
}).then(function(matchAllResponses) {
|
||||
ok(matchAllResponses, 'matchAll should succeed');
|
||||
is(matchAllResponses.length, 1, 'Only one match is expected');
|
||||
ok(matchAllResponses, "matchAll should succeed");
|
||||
is(matchAllResponses.length, 1, "Only one match is expected");
|
||||
return c.match(request);
|
||||
}).then(function(matchResponse) {
|
||||
ok(matchResponse, 'match should succeed');
|
||||
ok(matchResponse, "match should succeed");
|
||||
return caches.match(request);
|
||||
}).then(function(storageMatchResponse) {
|
||||
ok(storageMatchResponse, 'storage match should succeed');
|
||||
return caches.match(request, {cacheName:foobar});
|
||||
ok(storageMatchResponse, "storage match should succeed");
|
||||
return caches.match(request, {cacheName: foobar});
|
||||
}).then(function(storageMatchResponse) {
|
||||
ok(storageMatchResponse, 'storage match with cacheName should succeed');
|
||||
ok(storageMatchResponse, "storage match with cacheName should succeed");
|
||||
var request2 = new Request("http://example.com/hmm?q=snafu" + context);
|
||||
return c.match(request2, {ignoreSearch:true});
|
||||
return c.match(request2, {ignoreSearch: true});
|
||||
}).then(function(match2Response) {
|
||||
ok(match2Response, 'match should succeed');
|
||||
ok(match2Response, "match should succeed");
|
||||
return c.delete(request);
|
||||
}).then(function(deleteResult) {
|
||||
ok(deleteResult, 'delete should succeed');
|
||||
ok(deleteResult, "delete should succeed");
|
||||
return c.keys();
|
||||
}).then(function(keys) {
|
||||
ok(keys, 'Valid keys object expected');
|
||||
is(keys.length, 0, 'Zero keys is expected');
|
||||
ok(keys, "Valid keys object expected");
|
||||
is(keys.length, 0, "Zero keys is expected");
|
||||
return c.matchAll(request);
|
||||
}).then(function(matchAll2Responses) {
|
||||
ok(matchAll2Responses, 'matchAll should succeed');
|
||||
is(matchAll2Responses.length, 0, 'Zero matches is expected');
|
||||
ok(matchAll2Responses, "matchAll should succeed");
|
||||
is(matchAll2Responses.length, 0, "Zero matches is expected");
|
||||
return caches.has(foobar);
|
||||
}).then(function(hasResult) {
|
||||
ok(hasResult, 'has should succeed');
|
||||
ok(hasResult, "has should succeed");
|
||||
return caches.keys();
|
||||
}).then(function(keys) {
|
||||
ok(keys, 'Valid keys object expected');
|
||||
ok(keys.length >= 2, 'At least two keys are expected');
|
||||
ok(keys.includes(name), 'snafu should exist');
|
||||
ok(keys.indexOf(foobar) >= keys.indexOf(name), 'foobar should come after it');
|
||||
ok(keys, "Valid keys object expected");
|
||||
ok(keys.length >= 2, "At least two keys are expected");
|
||||
ok(keys.includes(name), "snafu should exist");
|
||||
ok(keys.indexOf(foobar) >= keys.indexOf(name), "foobar should come after it");
|
||||
return caches.delete(foobar);
|
||||
}).then(function(deleteResult) {
|
||||
ok(deleteResult, 'delete should succeed');
|
||||
ok(deleteResult, "delete should succeed");
|
||||
return caches.has(foobar);
|
||||
}).then(function(hasMissingCache) {
|
||||
ok(!hasMissingCache, 'has should have a result');
|
||||
ok(!hasMissingCache, "has should have a result");
|
||||
return caches.delete(name);
|
||||
}).then(function(deleteResult) {
|
||||
ok(deleteResult, 'delete should succeed');
|
||||
ok(deleteResult, "delete should succeed");
|
||||
testDone();
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,55 +1,57 @@
|
|||
var singleUrl = './test_cache_add.js';
|
||||
/* global context testDone:true */
|
||||
|
||||
var singleUrl = "./test_cache_add.js";
|
||||
var urlList = [
|
||||
'./empty.html',
|
||||
'./frame.html',
|
||||
'./test_cache.js'
|
||||
"./empty.html",
|
||||
"./frame.html",
|
||||
"./test_cache.js",
|
||||
];
|
||||
var cache;
|
||||
var name = "adder" + context;
|
||||
caches.open(name).then(function(openCache) {
|
||||
cache = openCache;
|
||||
return cache.add('ftp://example.com/invalid' + context);
|
||||
}).catch(function (err) {
|
||||
is(err.name, 'TypeError', 'add() should throw TypeError for invalid scheme');
|
||||
return cache.addAll(['http://example.com/valid' + context, 'ftp://example.com/invalid' + context]);
|
||||
}).catch(function (err) {
|
||||
is(err.name, 'TypeError', 'addAll() should throw TypeError for invalid scheme');
|
||||
return cache.add("ftp://example.com/invalid" + context);
|
||||
}).catch(function(err) {
|
||||
is(err.name, "TypeError", "add() should throw TypeError for invalid scheme");
|
||||
return cache.addAll(["http://example.com/valid" + context, "ftp://example.com/invalid" + context]);
|
||||
}).catch(function(err) {
|
||||
is(err.name, "TypeError", "addAll() should throw TypeError for invalid scheme");
|
||||
var promiseList = urlList.map(function(url) {
|
||||
return cache.match(url);
|
||||
});
|
||||
promiseList.push(cache.match(singleUrl));
|
||||
return Promise.all(promiseList);
|
||||
}).then(function(resultList) {
|
||||
is(urlList.length + 1, resultList.length, 'Expected number of results');
|
||||
is(urlList.length + 1, resultList.length, "Expected number of results");
|
||||
resultList.every(function(result) {
|
||||
is(undefined, result, 'URLs should not already be in the cache');
|
||||
is(undefined, result, "URLs should not already be in the cache");
|
||||
});
|
||||
return cache.add(singleUrl);
|
||||
}).then(function(result) {
|
||||
is(undefined, result, 'Successful add() should resolve undefined');
|
||||
is(undefined, result, "Successful add() should resolve undefined");
|
||||
return cache.addAll(urlList);
|
||||
}).then(function(result) {
|
||||
is(undefined, result, 'Successful addAll() should resolve undefined');
|
||||
is(undefined, result, "Successful addAll() should resolve undefined");
|
||||
var promiseList = urlList.map(function(url) {
|
||||
return cache.match(url);
|
||||
});
|
||||
promiseList.push(cache.match(singleUrl));
|
||||
return Promise.all(promiseList);
|
||||
}).then(function(resultList) {
|
||||
is(urlList.length + 1, resultList.length, 'Expected number of results');
|
||||
is(urlList.length + 1, resultList.length, "Expected number of results");
|
||||
resultList.every(function(result) {
|
||||
ok(!!result, 'Responses should now be in cache for each URL.');
|
||||
ok(!!result, "Responses should now be in cache for each URL.");
|
||||
});
|
||||
return cache.matchAll();
|
||||
}).then(function(resultList) {
|
||||
is(urlList.length + 1, resultList.length, 'Expected number of results');
|
||||
is(urlList.length + 1, resultList.length, "Expected number of results");
|
||||
resultList.every(function(result) {
|
||||
ok(!!result, 'Responses should now be in cache for each URL.');
|
||||
ok(!!result, "Responses should now be in cache for each URL.");
|
||||
});
|
||||
return caches.delete(name);
|
||||
}).then(function() {
|
||||
testDone();
|
||||
}).catch(function(err) {
|
||||
ok(false, 'Caught error: ' + err);
|
||||
ok(false, "Caught error: " + err);
|
||||
testDone();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
var name = "delete" + context;
|
||||
var c;
|
||||
|
||||
function setupTest(reqs) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
var cache = null;
|
||||
var name = 'https_' + context;
|
||||
var urlBase = 'https://example.com/tests/dom/cache/test/mochitest';
|
||||
var url1 = urlBase + '/test_cache.js';
|
||||
var url2 = urlBase + '/test_cache_add.js';
|
||||
/* global context testDone:true */
|
||||
|
||||
function addOpaque(cache, url) {
|
||||
return fetch(new Request(url, { mode: 'no-cors' })).then(function(response) {
|
||||
return cache.put(url, response);
|
||||
var cache = null;
|
||||
var name = "https_" + context;
|
||||
var urlBase = "https://example.com/tests/dom/cache/test/mochitest";
|
||||
var url1 = urlBase + "/test_cache.js";
|
||||
var url2 = urlBase + "/test_cache_add.js";
|
||||
|
||||
function addOpaque(c, url) {
|
||||
return fetch(new Request(url, { mode: "no-cors" })).then(function(response) {
|
||||
return c.put(url, response);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -14,18 +16,18 @@ caches.open(name).then(function(c) {
|
|||
cache = c;
|
||||
return Promise.all([
|
||||
addOpaque(cache, url1),
|
||||
addOpaque(cache, url2)
|
||||
addOpaque(cache, url2),
|
||||
]);
|
||||
}).then(function() {
|
||||
return cache.delete(url1);
|
||||
}).then(function(result) {
|
||||
ok(result, 'Cache entry should be deleted');
|
||||
ok(result, "Cache entry should be deleted");
|
||||
return cache.delete(url2);
|
||||
}).then(function(result) {
|
||||
ok(result, 'Cache entry should be deleted');
|
||||
ok(result, "Cache entry should be deleted");
|
||||
cache = null;
|
||||
return caches.delete(name);
|
||||
}).then(function(result) {
|
||||
ok(result, 'Cache should be deleted');
|
||||
ok(result, "Cache should be deleted");
|
||||
testDone();
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
var name = "keys" + context;
|
||||
var c;
|
||||
|
||||
|
@ -35,9 +37,9 @@ caches.open(name).then(function(cache) {
|
|||
ok(keys[0].url.includes(tests[1]), "Valid URL");
|
||||
// Try to see if ignoreSearch works as expected.
|
||||
return c.keys(new Request("//mochi.test:8888/?foo"), {ignoreSearch: true});
|
||||
}).then(function(keys) {
|
||||
is(keys.length, tests.length, "Same number of elements");
|
||||
keys.forEach(function(r, i) {
|
||||
}).then(function(key_arr) {
|
||||
is(key_arr.length, tests.length, "Same number of elements");
|
||||
key_arr.forEach(function(r, i) {
|
||||
ok(r instanceof Request, "Valid request object");
|
||||
ok(r.url.includes(tests[i]), "Valid URL");
|
||||
});
|
||||
|
@ -45,7 +47,7 @@ caches.open(name).then(function(cache) {
|
|||
return Promise.all(
|
||||
["POST", "PUT", "DELETE", "OPTIONS"]
|
||||
.map(function(method) {
|
||||
var req = new Request(tests[2], {method: method});
|
||||
var req = new Request(tests[2], {method});
|
||||
return c.keys(req)
|
||||
.then(function(keys) {
|
||||
is(keys.length, 0, "No request should be matched without ignoreMethod");
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
var request1 = new Request("//mochi.test:8888/?1&" + context + "#fragment");
|
||||
var request2 = new Request("//mochi.test:8888/?2&" + context);
|
||||
var request3 = new Request("//mochi.test:8888/?3&" + context);
|
||||
/* global context testDone:true */
|
||||
|
||||
var req1 = new Request("//mochi.test:8888/?1&" + context + "#fragment");
|
||||
var req2 = new Request("//mochi.test:8888/?2&" + context);
|
||||
var req3 = new Request("//mochi.test:8888/?3&" + context);
|
||||
var requestWithAltQS = new Request("//mochi.test:8888/?queryString");
|
||||
var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
|
||||
var response1, response3;
|
||||
|
@ -25,30 +27,30 @@ function checkResponse(r, response, responseText) {
|
|||
});
|
||||
}
|
||||
|
||||
fetch(new Request(request1)).then(function(r) {
|
||||
fetch(new Request(req1)).then(function(r) {
|
||||
response1 = r;
|
||||
return response1.text();
|
||||
}).then(function(text) {
|
||||
response1Text = text;
|
||||
return fetch(new Request(request3));
|
||||
return fetch(new Request(req3));
|
||||
}).then(function(r) {
|
||||
response3 = r;
|
||||
return response3.text();
|
||||
}).then(function(text) {
|
||||
response3Text = text;
|
||||
return testRequest(request1, request2, request3, unknownRequest,
|
||||
return testRequest(req1, req2, req3, unknownRequest,
|
||||
requestWithAltQS,
|
||||
request1.url.replace("#fragment", "#other"));
|
||||
req1.url.replace("#fragment", "#other"));
|
||||
}).then(function() {
|
||||
return testRequest(request1.url, request2.url, request3.url,
|
||||
return testRequest(req1.url, req2.url, req3.url,
|
||||
unknownRequest.url, requestWithAltQS.url,
|
||||
request1.url.replace("#fragment", "#other"));
|
||||
req1.url.replace("#fragment", "#other"));
|
||||
}).then(function() {
|
||||
testDone();
|
||||
});
|
||||
|
||||
// The request arguments can either be a URL string, or a Request object.
|
||||
function testRequest(request1, request2, request3, unknownRequest,
|
||||
function testRequest(request1, request2, request3, unknownReq,
|
||||
requestWithAlternateQueryString,
|
||||
requestWithDifferentFragment) {
|
||||
return caches.open(name).then(function(cache) {
|
||||
|
@ -60,7 +62,7 @@ function testRequest(request1, request2, request3, unknownRequest,
|
|||
return Promise.all(
|
||||
["HEAD", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
.map(function(method) {
|
||||
var r = new Request(request1, {method: method});
|
||||
var r = new Request(request1, {method});
|
||||
return c.add(r)
|
||||
.then(function() {
|
||||
ok(false, "Promise should be rejected");
|
||||
|
@ -86,7 +88,7 @@ function testRequest(request1, request2, request3, unknownRequest,
|
|||
return Promise.all(
|
||||
["HEAD", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
.map(function(method) {
|
||||
var req = new Request(request1, {method: method});
|
||||
var req = new Request(request1, {method});
|
||||
return c.matchAll(req)
|
||||
.then(function(r) {
|
||||
is(r.length, 0, "Searching for a request with a non-GET method should not succeed");
|
||||
|
@ -109,7 +111,7 @@ function testRequest(request1, request2, request3, unknownRequest,
|
|||
is(r.length, 2, "Should find 2 items");
|
||||
return Promise.all([
|
||||
checkResponse(r[0], response1, response1Text),
|
||||
checkResponse(r[1], response3, response3Text)
|
||||
checkResponse(r[1], response3, response3Text),
|
||||
]);
|
||||
}).then(function() {
|
||||
return c.matchAll(request3);
|
||||
|
@ -122,21 +124,21 @@ function testRequest(request1, request2, request3, unknownRequest,
|
|||
is(r.length, 2, "Should find 2 items");
|
||||
return Promise.all([
|
||||
checkResponse(r[0], response1, response1Text),
|
||||
checkResponse(r[1], response3, response3Text)
|
||||
checkResponse(r[1], response3, response3Text),
|
||||
]);
|
||||
}).then(function() {
|
||||
return caches.match(request1, {cacheName: name + "mambojambo"})
|
||||
.then(function() {
|
||||
is(typeof r, "undefined", 'Searching in the wrong cache should resolve to undefined');
|
||||
is(typeof r, "undefined", "Searching in the wrong cache should resolve to undefined");
|
||||
return caches.has(name + "mambojambo");
|
||||
}).then(function(hasCache) {
|
||||
ok(!hasCache, 'The wrong cache should still not exist');
|
||||
ok(!hasCache, "The wrong cache should still not exist");
|
||||
});
|
||||
}).then(function() {
|
||||
return c.matchAll(unknownRequest);
|
||||
return c.matchAll(unknownReq);
|
||||
}).then(function(r) {
|
||||
is(r.length, 0, "Searching for an unknown request should not succeed");
|
||||
return caches.match(unknownRequest, {cacheName: name});
|
||||
return caches.match(unknownReq, {cacheName: name});
|
||||
}).then(function(r) {
|
||||
is(typeof r, "undefined", "Searching for an unknown request should not succeed");
|
||||
// Make sure that cacheName is ignored on Cache
|
||||
|
@ -164,7 +166,7 @@ function testRequest(request1, request2, request3, unknownRequest,
|
|||
is(r.length, 2, "Should find 2 items");
|
||||
return Promise.all([
|
||||
checkResponse(r[0], response1, response1Text),
|
||||
checkResponse(r[1], response3, response3Text)
|
||||
checkResponse(r[1], response3, response3Text),
|
||||
]);
|
||||
}).then(function() {
|
||||
// Now, drop the cache, reopen and verify that we can't find the request any more.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
var request = new Request("//mochi.test:8888/?" + context + "#fragment");
|
||||
/* global context testDone:true */
|
||||
|
||||
var req = new Request("//mochi.test:8888/?" + context + "#fragment");
|
||||
var requestWithAltQS = new Request("//mochi.test:8888/?queryString");
|
||||
var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
|
||||
var unknownReq = new Request("//mochi.test:8888/non/existing/path?" + context);
|
||||
var response;
|
||||
var c;
|
||||
var responseText;
|
||||
|
@ -25,16 +27,16 @@ function checkResponse(r, expectedBody) {
|
|||
}
|
||||
});
|
||||
}
|
||||
fetch(new Request(request)).then(function(r) {
|
||||
fetch(new Request(req)).then(function(r) {
|
||||
response = r;
|
||||
return response.text();
|
||||
}).then(function(text) {
|
||||
responseText = text;
|
||||
return testRequest(request, unknownRequest, requestWithAltQS,
|
||||
request.url.replace("#fragment", "#other"));
|
||||
return testRequest(req, unknownReq, requestWithAltQS,
|
||||
req.url.replace("#fragment", "#other"));
|
||||
}).then(function() {
|
||||
return testRequest(request.url, unknownRequest.url, requestWithAltQS.url,
|
||||
request.url.replace("#fragment", "#other"));
|
||||
return testRequest(req.url, unknownReq.url, requestWithAltQS.url,
|
||||
req.url.replace("#fragment", "#other"));
|
||||
}).then(function() {
|
||||
testDone();
|
||||
});
|
||||
|
@ -48,7 +50,7 @@ function testRequest(request, unknownRequest, requestWithAlternateQueryString,
|
|||
return Promise.all(
|
||||
["HEAD", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
.map(function(method) {
|
||||
var r = new Request(request, {method: method});
|
||||
var r = new Request(request, {method});
|
||||
return c.add(r)
|
||||
.then(function() {
|
||||
ok(false, "Promise should be rejected");
|
||||
|
@ -72,11 +74,11 @@ function testRequest(request, unknownRequest, requestWithAlternateQueryString,
|
|||
return Promise.all(
|
||||
["HEAD", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||
.map(function(method) {
|
||||
var req = new Request(request, {method: method});
|
||||
return c.match(req)
|
||||
var req1 = new Request(request, {method});
|
||||
return c.match(req1)
|
||||
.then(function(r) {
|
||||
is(typeof r, "undefined", "Searching for a request with a non-GET method should not succeed");
|
||||
return c.match(req, {ignoreMethod: true});
|
||||
return c.match(req1, {ignoreMethod: true});
|
||||
}).then(function(r) {
|
||||
return checkResponse(r);
|
||||
});
|
||||
|
@ -102,10 +104,10 @@ function testRequest(request, unknownRequest, requestWithAlternateQueryString,
|
|||
}).then(function() {
|
||||
return caches.match(request, {cacheName: name + "mambojambo"})
|
||||
.then(function(result) {
|
||||
is(typeof r, "undefined", 'Searching in the wrong cache should resolve to undefined');
|
||||
is(typeof r, "undefined", "Searching in the wrong cache should resolve to undefined");
|
||||
return caches.has(name + "mambojambo");
|
||||
}).then(function(hasCache) {
|
||||
ok(!hasCache, 'The wrong cache should still not exist');
|
||||
ok(!hasCache, "The wrong cache should still not exist");
|
||||
});
|
||||
}).then(function() {
|
||||
// Make sure that cacheName is ignored on Cache
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
var requestURL = "//mochi.test:8888/tests/dom/cache/test/mochitest/vary.sjs?" + context;
|
||||
var name = "match-vary" + context;
|
||||
|
||||
|
@ -36,8 +38,8 @@ function setupTestMultipleEntries(headers) {
|
|||
var response, responseText, cache;
|
||||
Promise.all(headers.map(function(h) {
|
||||
return fetch(requestURL, {headers: h});
|
||||
})).then(function(r) {
|
||||
response = r;
|
||||
})).then(function(res) {
|
||||
response = res;
|
||||
return Promise.all(response.map(function(r) {
|
||||
return r.text();
|
||||
}));
|
||||
|
@ -50,7 +52,7 @@ function setupTestMultipleEntries(headers) {
|
|||
return c.add(new Request(requestURL, {headers: h}));
|
||||
}));
|
||||
}).then(function() {
|
||||
resolve({response: response, responseText: responseText, cache: cache});
|
||||
resolve({response, responseText, cache});
|
||||
}).catch(function(err) {
|
||||
reject(err);
|
||||
});
|
||||
|
@ -115,7 +117,6 @@ function testStar() {
|
|||
is(err.name, "TypeError", "Attempting to store a Response with a Vary:* header must fail");
|
||||
});
|
||||
}
|
||||
var test;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var cache;
|
||||
caches.open(name).then(function(c) {
|
||||
|
@ -257,7 +258,7 @@ function testMultipleCacheEntries() {
|
|||
]).then(function(t) {
|
||||
test = t;
|
||||
return test.cache.matchAll();
|
||||
}).then(function (r) {
|
||||
}).then(function(r) {
|
||||
is(r.length, 2, "Two cache entries should be stored in the DB");
|
||||
// Ensure that searching without specifying an Accept-Language header fails.
|
||||
return test.cache.matchAll(requestURL);
|
||||
|
|
|
@ -64,7 +64,7 @@ function workerGroupUsage() {
|
|||
URL.createObjectURL(new Blob(["(", workerScript.toSource(), ")()"]));
|
||||
|
||||
let worker = new Worker(url);
|
||||
worker.onmessage = function (e) {
|
||||
worker.onmessage = function(e) {
|
||||
resolve(e.data, 0);
|
||||
};
|
||||
});
|
||||
|
@ -92,14 +92,13 @@ SpecialPowers.pushPrefEnv({
|
|||
["dom.quotaManager.testing", true],
|
||||
["dom.storageManager.enabled", true]],
|
||||
}, function() {
|
||||
var name = 'orphanedBodyOwner';
|
||||
var name = "orphanedBodyOwner";
|
||||
var cache = null;
|
||||
var response = null;
|
||||
var initialUsage = 0;
|
||||
var fullUsage = 0;
|
||||
var resetUsage = 0;
|
||||
var endUsage = 0;
|
||||
var url = 'test_cache_add.js';
|
||||
var url = "test_cache_add.js";
|
||||
|
||||
// start from a fresh origin directory so other tests do not influence our
|
||||
// results
|
||||
|
@ -108,7 +107,7 @@ SpecialPowers.pushPrefEnv({
|
|||
}).then(function() {
|
||||
return storageUsage();
|
||||
}).then(function(usage) {
|
||||
is(0, usage, 'disk usage should be zero to start');
|
||||
is(0, usage, "disk usage should be zero to start");
|
||||
})
|
||||
|
||||
// Initialize and populate an initial cache to get the base sqlite pages
|
||||
|
@ -122,7 +121,7 @@ SpecialPowers.pushPrefEnv({
|
|||
}).then(function() {
|
||||
return caches.delete(name);
|
||||
}).then(function(deleted) {
|
||||
ok(deleted, 'cache should be deleted');
|
||||
ok(deleted, "cache should be deleted");
|
||||
|
||||
// This is a bit superfluous, but its necessary to make sure the Cache is
|
||||
// fully deleted before we proceed. The deletion actually takes place in
|
||||
|
@ -167,7 +166,7 @@ SpecialPowers.pushPrefEnv({
|
|||
return storageUsage();
|
||||
}).then(function(usage) {
|
||||
fullUsage = usage;
|
||||
ok(fullUsage > initialUsage, 'disk usage should have grown');
|
||||
ok(fullUsage > initialUsage, "disk usage should have grown");
|
||||
})
|
||||
|
||||
// Test groupUsage()
|
||||
|
@ -177,7 +176,7 @@ SpecialPowers.pushPrefEnv({
|
|||
return groupUsage();
|
||||
}).then(function(usage) {
|
||||
fullUsage = usage;
|
||||
ok(fullUsage > initialUsage, 'disk group usage should have grown');
|
||||
ok(fullUsage > initialUsage, "disk group usage should have grown");
|
||||
})
|
||||
|
||||
// Test workerGroupUsage()
|
||||
|
@ -187,7 +186,7 @@ SpecialPowers.pushPrefEnv({
|
|||
return workerGroupUsage();
|
||||
}).then(function(usage) {
|
||||
fullUsage = usage;
|
||||
ok(fullUsage > initialUsage, 'disk group usage on worker should have grown');
|
||||
ok(fullUsage > initialUsage, "disk group usage on worker should have grown");
|
||||
})
|
||||
|
||||
// Now perform a new Cache operation that will reopen the origin. This
|
||||
|
@ -195,7 +194,7 @@ SpecialPowers.pushPrefEnv({
|
|||
.then(function() {
|
||||
return caches.match(url);
|
||||
}).then(function(r) {
|
||||
ok(!r, 'response should not exist in storage');
|
||||
ok(!r, "response should not exist in storage");
|
||||
})
|
||||
|
||||
// Finally, verify orphaned data was cleaned up by re-checking the disk
|
||||
|
@ -209,21 +208,21 @@ SpecialPowers.pushPrefEnv({
|
|||
endUsage = usage;
|
||||
dump("### ### initial:" + initialUsage + ", full:" + fullUsage +
|
||||
", end:" + endUsage + "\n");
|
||||
ok(endUsage < fullUsage, 'disk usage should have shrank');
|
||||
is(endUsage, initialUsage, 'disk usage should return to original');
|
||||
ok(endUsage < fullUsage, "disk usage should have shrank");
|
||||
is(endUsage, initialUsage, "disk usage should return to original");
|
||||
})
|
||||
|
||||
// Verify that the stale, orphaned response cannot be put back into
|
||||
// the cache.
|
||||
.then(function() {
|
||||
ok(!response.bodyUsed, 'response body should not be considered used');
|
||||
ok(!response.bodyUsed, "response body should not be considered used");
|
||||
return cache.put(url, response).then(function() {
|
||||
ok(false, 'Should not be able to store stale orphaned body.');
|
||||
ok(false, "Should not be able to store stale orphaned body.");
|
||||
}).catch(function(e) {
|
||||
is(e.name, 'TypeError', 'storing a stale orphaned body should throw TypeError');
|
||||
is(e.name, "TypeError", "storing a stale orphaned body should throw TypeError");
|
||||
});
|
||||
}).then(function() {
|
||||
ok(response.bodyUsed, 'attempting to store response should mark body used');
|
||||
ok(response.bodyUsed, "attempting to store response should mark body used");
|
||||
})
|
||||
|
||||
.then(function() {
|
||||
|
|
|
@ -65,13 +65,12 @@ SpecialPowers.pushPrefEnv({
|
|||
["dom.caches.testing.enabled", true],
|
||||
["dom.quotaManager.testing", true]],
|
||||
}, function() {
|
||||
var name = 'toBeOrphaned';
|
||||
var name = "toBeOrphaned";
|
||||
var cache = null;
|
||||
var initialUsage = 0;
|
||||
var fullUsage = 0;
|
||||
var resetUsage = 0;
|
||||
var endUsage = 0;
|
||||
var url = 'test_cache_add.js';
|
||||
var url = "test_cache_add.js";
|
||||
|
||||
// start from a fresh origin directory so other tests do not influence our
|
||||
// results
|
||||
|
@ -80,7 +79,7 @@ SpecialPowers.pushPrefEnv({
|
|||
}).then(function() {
|
||||
return storageUsage();
|
||||
}).then(function(usage) {
|
||||
is(0, usage, 'disk usage should be zero to start');
|
||||
is(0, usage, "disk usage should be zero to start");
|
||||
})
|
||||
|
||||
// Initialize and populate an initial cache to get the base sqlite pages
|
||||
|
@ -94,7 +93,7 @@ SpecialPowers.pushPrefEnv({
|
|||
}).then(function() {
|
||||
return caches.delete(name);
|
||||
}).then(function(deleted) {
|
||||
ok(deleted, 'cache should be deleted');
|
||||
ok(deleted, "cache should be deleted");
|
||||
|
||||
// This is a bit superfluous, but its necessary to make sure the Cache is
|
||||
// fully deleted before we proceed. The deletion actually takes place in
|
||||
|
@ -122,7 +121,7 @@ SpecialPowers.pushPrefEnv({
|
|||
}).then(function() {
|
||||
return caches.delete(name);
|
||||
}).then(function(deleted) {
|
||||
ok(deleted, 'cache should be deleted');
|
||||
ok(deleted, "cache should be deleted");
|
||||
})
|
||||
|
||||
// Reset the quota dir while the cache is deleted, but still referenced
|
||||
|
@ -133,7 +132,7 @@ SpecialPowers.pushPrefEnv({
|
|||
return storageUsage();
|
||||
}).then(function(usage) {
|
||||
fullUsage = usage;
|
||||
ok(fullUsage > initialUsage, 'disk usage should have grown');
|
||||
ok(fullUsage > initialUsage, "disk usage should have grown");
|
||||
})
|
||||
|
||||
// Now perform a new Cache operation that will reopen the origin. This
|
||||
|
@ -141,7 +140,7 @@ SpecialPowers.pushPrefEnv({
|
|||
.then(function() {
|
||||
return caches.has(name);
|
||||
}).then(function(result) {
|
||||
ok(!result, 'cache should not exist in storage');
|
||||
ok(!result, "cache should not exist in storage");
|
||||
})
|
||||
|
||||
// Finally, verify orphaned data was cleaned up by re-checking the disk
|
||||
|
@ -155,8 +154,8 @@ SpecialPowers.pushPrefEnv({
|
|||
endUsage = usage;
|
||||
dump("### ### initial:" + initialUsage + ", full:" + fullUsage +
|
||||
", end:" + endUsage + "\n");
|
||||
ok(endUsage < fullUsage, 'disk usage should have shrank');
|
||||
is(endUsage, initialUsage, 'disk usage should return to original');
|
||||
ok(endUsage < fullUsage, "disk usage should have shrank");
|
||||
is(endUsage, initialUsage, "disk usage should return to original");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
var requestURL = "//mochi.test:8888/tests/dom/cache/test/mochitest/mirror.sjs?" + context;
|
||||
var response;
|
||||
var c;
|
||||
|
|
|
@ -76,7 +76,7 @@ async function waitForIOToComplete(cache, request) {
|
|||
await cache.match(request);
|
||||
|
||||
// Finally, wait for -wal file finish its job.
|
||||
return await resetStorage();
|
||||
return resetStorage();
|
||||
}
|
||||
|
||||
function fetchOpaqueResponse(url) {
|
||||
|
@ -87,9 +87,8 @@ SimpleTest.waitForExplicitFinish();
|
|||
SpecialPowers.pushPrefEnv({
|
||||
"set": [["dom.caches.enabled", true],
|
||||
["dom.caches.testing.enabled", true],
|
||||
["dom.quotaManager.testing", true]]
|
||||
["dom.quotaManager.testing", true]],
|
||||
}, async function() {
|
||||
|
||||
// This test is mainly to verify we only generate different padding size for
|
||||
// the opaque response which is comming from netwrok.
|
||||
// Besides, this test utilizes verifyUsage() to ensure Cache Acions does
|
||||
|
@ -101,10 +100,10 @@ SpecialPowers.pushPrefEnv({
|
|||
// Note: For the cloned and cached opaque response, the padding size shouldn't
|
||||
// be changed. Thus, it makes the attacker harder to get the padding size.
|
||||
|
||||
const name = 'cachePadding';
|
||||
const other_name = 'cachePaddingOther';
|
||||
const cors_base = 'https://example.com/test/dom/cache/test/mochitest/';
|
||||
const url = 'test_cache_add.js';
|
||||
const name = "cachePadding";
|
||||
const other_name = "cachePaddingOther";
|
||||
const cors_base = "https://example.com/test/dom/cache/test/mochitest/";
|
||||
const url = "test_cache_add.js";
|
||||
|
||||
await setupTestIframe();
|
||||
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
var url = 'test_cache.js';
|
||||
/* global context testDone:true */
|
||||
|
||||
var url = "test_cache.js";
|
||||
var cache;
|
||||
var fetchResponse;
|
||||
Promise.all([fetch(url),
|
||||
caches.open('putter' + context)]).then(function(results) {
|
||||
caches.open("putter" + context)]).then(function(results) {
|
||||
fetchResponse = results[0];
|
||||
cache = results[1];
|
||||
return cache.put(url, fetchResponse.clone());
|
||||
}).then(function(result) {
|
||||
is(undefined, result, 'Successful put() should resolve undefined');
|
||||
is(undefined, result, "Successful put() should resolve undefined");
|
||||
return cache.match(url);
|
||||
}).then(function(response) {
|
||||
ok(response, 'match() should find resppnse that was previously put()');
|
||||
ok(response.url.endsWith(url), 'matched response should match original url');
|
||||
ok(response, "match() should find resppnse that was previously put()");
|
||||
ok(response.url.endsWith(url), "matched response should match original url");
|
||||
return Promise.all([fetchResponse.text(),
|
||||
response.text()]);
|
||||
}).then(function(results) {
|
||||
// suppress large assert spam unless it's relevent
|
||||
if (results[0] !== results[1]) {
|
||||
is(results[0], results[1], 'stored response body should match original');
|
||||
is(results[0], results[1], "stored response body should match original");
|
||||
}
|
||||
|
||||
// Now, try to overwrite the request with a different response object.
|
||||
|
@ -43,7 +45,7 @@ Promise.all([fetch(url),
|
|||
// TODO: Verify that trying to store a response with an error raises a TypeError
|
||||
// when bug 1147178 is fixed.
|
||||
|
||||
return caches.delete('putter' + context);
|
||||
return caches.delete("putter" + context);
|
||||
}).then(function(deleted) {
|
||||
ok(deleted, "The cache should be deleted successfully");
|
||||
testDone();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
var name = "putreorder" + context;
|
||||
var c;
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
let cache;
|
||||
let url = 'foo.html';
|
||||
let redirectURL = 'http://example.com/foo-bar.html';
|
||||
caches.open('redirect-' + context).then(c => {
|
||||
let url = "foo.html";
|
||||
let redirectURL = "http://example.com/foo-bar.html";
|
||||
caches.open("redirect-" + context).then(c => {
|
||||
cache = c;
|
||||
var response = Response.redirect(redirectURL);
|
||||
is(response.headers.get('Location'), redirectURL);
|
||||
is(response.headers.get("Location"), redirectURL);
|
||||
return cache.put(url, response);
|
||||
}).then(_ => {
|
||||
return cache.match(url);
|
||||
}).then(response => {
|
||||
is(response.headers.get('Location'), redirectURL);
|
||||
is(response.headers.get("Location"), redirectURL);
|
||||
testDone();
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
var name = "requestCache" + context;
|
||||
var c;
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ SpecialPowers.pushPrefEnv({
|
|||
["dom.caches.testing.enabled", true],
|
||||
["dom.quotaManager.testing", true]],
|
||||
}, function() {
|
||||
var name = 'foo';
|
||||
var url = './test_cache_add.js';
|
||||
var name = "foo";
|
||||
var url = "./test_cache_add.js";
|
||||
var cache;
|
||||
setupTestIframe().then(function() {
|
||||
return caches.open(name);
|
||||
|
@ -48,9 +48,9 @@ SpecialPowers.pushPrefEnv({
|
|||
return resetStorage();
|
||||
}).then(function() {
|
||||
return cache.match(url).then(function(resp) {
|
||||
ok(false, 'old cache reference should not work after reset');
|
||||
ok(false, "old cache reference should not work after reset");
|
||||
}).catch(function(err) {
|
||||
ok(true, 'old cache reference should not work after reset');
|
||||
ok(true, "old cache reference should not work after reset");
|
||||
});
|
||||
}).then(function() {
|
||||
return caches.open(name);
|
||||
|
@ -58,10 +58,10 @@ SpecialPowers.pushPrefEnv({
|
|||
cache = c;
|
||||
return cache.match(url);
|
||||
}).then(function(resp) {
|
||||
ok(!!resp, 'cache should work after QM reset');
|
||||
ok(!!resp, "cache should work after QM reset");
|
||||
return caches.delete(name);
|
||||
}).then(function(success) {
|
||||
ok(success, 'cache should be deleted');
|
||||
ok(success, "cache should be deleted");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -65,7 +65,7 @@ SpecialPowers.pushPrefEnv({
|
|||
["dom.caches.testing.enabled", true],
|
||||
["dom.quotaManager.testing", true]],
|
||||
}, function() {
|
||||
var name = 'foo';
|
||||
var name = "foo";
|
||||
var cache = null;
|
||||
var initialUsage = 0;
|
||||
var fullUsage = 0;
|
||||
|
@ -77,7 +77,7 @@ SpecialPowers.pushPrefEnv({
|
|||
}).then(function() {
|
||||
return storageUsage();
|
||||
}).then(function(usage) {
|
||||
is(0, usage, 'disk usage should be zero to start');
|
||||
is(0, usage, "disk usage should be zero to start");
|
||||
return caches.open(name);
|
||||
}).then(function(c) {
|
||||
cache = c;
|
||||
|
@ -90,7 +90,7 @@ SpecialPowers.pushPrefEnv({
|
|||
}).then(function() {
|
||||
return cache.keys();
|
||||
}).then(function(keyList) {
|
||||
is(keyList.length, largeUrlList.length, 'Large URL list is stored in cache');
|
||||
is(keyList.length, largeUrlList.length, "Large URL list is stored in cache");
|
||||
cache = null;
|
||||
// Ensure the Cache DOM object is gone before proceeding. If its alive
|
||||
// it will keep the related entries on-disk as well.
|
||||
|
@ -102,10 +102,10 @@ SpecialPowers.pushPrefEnv({
|
|||
return storageUsage();
|
||||
}).then(function(usage) {
|
||||
fullUsage = usage;
|
||||
ok(fullUsage > initialUsage, 'disk usage should have grown');
|
||||
ok(fullUsage > initialUsage, "disk usage should have grown");
|
||||
return caches.delete(name);
|
||||
}).then(function(result) {
|
||||
ok(result, 'cache should be deleted');
|
||||
ok(result, "cache should be deleted");
|
||||
// This is a bit superfluous, but its necessary to make sure the Cache is
|
||||
// fully deleted before we proceed. The deletion actually takes place in
|
||||
// two async steps. We don't want to resetStorage() until the second step
|
||||
|
@ -113,7 +113,7 @@ SpecialPowers.pushPrefEnv({
|
|||
// runnables have been flushed through the threads, etc.
|
||||
return caches.has(name);
|
||||
}).then(function(result) {
|
||||
ok(!result, 'cache should not exist in storage');
|
||||
ok(!result, "cache should not exist in storage");
|
||||
// reset the quota manager storage to ensure the DB connection is flushed
|
||||
return resetStorage();
|
||||
}).then(function() {
|
||||
|
@ -122,8 +122,8 @@ SpecialPowers.pushPrefEnv({
|
|||
endUsage = usage;
|
||||
dump("### ### initial:" + initialUsage + ", full:" + fullUsage +
|
||||
", end:" + endUsage + "\n");
|
||||
ok(endUsage < (fullUsage / 2), 'disk usage should have shrank significantly');
|
||||
ok(endUsage > initialUsage, 'disk usage should not shrink back to orig size');
|
||||
ok(endUsage < (fullUsage / 2), "disk usage should have shrank significantly");
|
||||
ok(endUsage > initialUsage, "disk usage should not shrink back to orig size");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,8 +34,8 @@ function clearStorage() {
|
|||
|
||||
async function testCreateTonsOfFD() {
|
||||
const number_of_fd = 5120;
|
||||
const name = 'cacheTonsOfFD';
|
||||
const url = "foo.com"
|
||||
const name = "cacheTonsOfFD";
|
||||
const url = "foo.com";
|
||||
const body = "This is a body";
|
||||
|
||||
info("Stage A: Cached a Request/Response pairs");
|
||||
|
@ -54,30 +54,30 @@ async function testCreateTonsOfFD() {
|
|||
try {
|
||||
cached_response_array = await Promise.all(promise_array);
|
||||
} catch (e) {
|
||||
throw("Fail to open tons of files with error: " + e);
|
||||
throw ("Fail to open tons of files with error: " + e);
|
||||
}
|
||||
|
||||
if (cached_response_array.length != number_of_fd) {
|
||||
throw("Fail to cache.match the cached responses");
|
||||
throw ("Fail to cache.match the cached responses");
|
||||
}
|
||||
|
||||
info("Stage C: Consume the cached body")
|
||||
info("Stage C: Consume the cached body");
|
||||
for (let i = 0; i < number_of_fd; ++i) {
|
||||
if (!cached_response_array[i]) {
|
||||
// Reduce the checking message.
|
||||
throw("The cached response doesn't exist");
|
||||
throw ("The cached response doesn't exist");
|
||||
}
|
||||
|
||||
let bodyText = "";
|
||||
try {
|
||||
bodyText = await cached_response_array[i].text();
|
||||
} catch (e) {
|
||||
throw("Fail to consume the cached response's body with error: " + e);
|
||||
throw ("Fail to consume the cached response's body with error: " + e);
|
||||
}
|
||||
|
||||
if (bodyText != body) {
|
||||
// Reduce the checking message.
|
||||
throw("The cached body doeen't be the same as original one");
|
||||
throw ("The cached body doeen't be the same as original one");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ SimpleTest.waitForExplicitFinish();
|
|||
SpecialPowers.pushPrefEnv({
|
||||
"set": [["dom.caches.enabled", true],
|
||||
["dom.caches.testing.enabled", true],
|
||||
["dom.quotaManager.testing", true]]
|
||||
["dom.quotaManager.testing", true]],
|
||||
}, async function() {
|
||||
await setupTestIframe();
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ SpecialPowers.pushPrefEnv({
|
|||
"set": [["dom.caches.enabled", true]],
|
||||
}, function() {
|
||||
setupTestIframe().then(function() {
|
||||
return caches.open('foo');
|
||||
return caches.open("foo");
|
||||
}).then(function(usage) {
|
||||
ok(false, 'caches should not be usable in untrusted http origin');
|
||||
ok(false, "caches should not be usable in untrusted http origin");
|
||||
}).catch(function(err) {
|
||||
is(err.name, 'SecurityError', 'caches should reject with SecurityError');
|
||||
is(err.name, "SecurityError", "caches should reject with SecurityError");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -76,18 +76,18 @@ async function waitForIOToComplete(cache, request) {
|
|||
await cache.match(request);
|
||||
|
||||
// Finally, wait for -wal file finish its job.
|
||||
return await resetStorage();
|
||||
return resetStorage();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [["dom.caches.enabled", true],
|
||||
["dom.caches.testing.enabled", true],
|
||||
["dom.quotaManager.testing", true]]
|
||||
["dom.quotaManager.testing", true]],
|
||||
}, async function() {
|
||||
const name = 'cacheUpdateUsage';
|
||||
const url = 'test_cache_add.js';
|
||||
const other_url = 'test_cache_put.js';
|
||||
const name = "cacheUpdateUsage";
|
||||
const url = "test_cache_add.js";
|
||||
const other_url = "test_cache_put.js";
|
||||
|
||||
// This test mainly ensure DOM Cache updates its usage to QuotaManager when
|
||||
// executing an operation which creates/deletes files. To do this, we verify
|
||||
|
@ -108,7 +108,7 @@ SpecialPowers.pushPrefEnv({
|
|||
|
||||
info("Stage 2.2: Verify caches.delete.");
|
||||
var deleted = await caches.delete(name);
|
||||
ok(deleted, 'Cache storage should be deleted');
|
||||
ok(deleted, "Cache storage should be deleted");
|
||||
// Reference from test_cache_orphanced_body.html. It ensures that all
|
||||
// the runnables have been flushed through the threads.
|
||||
await caches.has(name);
|
||||
|
@ -137,7 +137,7 @@ SpecialPowers.pushPrefEnv({
|
|||
|
||||
info("Stage 3.3: Verify cache.put.");
|
||||
cache = await caches.open(name);
|
||||
response = await fetch(other_url);
|
||||
let response = await fetch(other_url);
|
||||
await cache.put(other_url, response);
|
||||
await verifyUsage();
|
||||
info("Stage 3.3.1: Delete cache.");
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
<script class="testbody" type="text/javascript">
|
||||
function startWorker() {
|
||||
return new Promise(resolve => {
|
||||
var w = new Worker('idle_worker.js');
|
||||
w.addEventListener('message', function onMessage(evt) {
|
||||
if (evt.data === 'LOADED') {
|
||||
w.removeEventListener('message', onMessage);
|
||||
var w = new Worker("idle_worker.js");
|
||||
w.addEventListener("message", function onMessage(evt) {
|
||||
if (evt.data === "LOADED") {
|
||||
w.removeEventListener("message", onMessage);
|
||||
resolve(w);
|
||||
}
|
||||
});
|
||||
|
@ -34,11 +34,11 @@ SimpleTest.waitForExplicitFinish();
|
|||
async function test() {
|
||||
let w = await startWorker();
|
||||
let weakWorker = SpecialPowers.Cu.getWeakReference(w);
|
||||
ok(weakWorker, 'worker supports weak reference');
|
||||
ok(weakWorker, "worker supports weak reference");
|
||||
w = null;
|
||||
await gc();
|
||||
await gc();
|
||||
ok(!weakWorker.get(), 'worker weak reference should be garbage collected');
|
||||
ok(!weakWorker.get(), "worker weak reference should be garbage collected");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global context testDone:true */
|
||||
|
||||
function arraysHaveSameContent(arr1, arr2) {
|
||||
if (arr1.length != arr2.length) {
|
||||
return false;
|
||||
|
|
|
@ -16,26 +16,26 @@
|
|||
["dom.caches.testing.enabled", true]],
|
||||
}, function() {
|
||||
// attach to a different origin's CacheStorage
|
||||
var url = 'http://example.com/';
|
||||
var storage = SpecialPowers.createChromeCache('content', url);
|
||||
var url = "http://example.com/";
|
||||
var storage = SpecialPowers.createChromeCache("content", url);
|
||||
|
||||
// verify we can use the other origin's CacheStorage as normal
|
||||
var req = new Request('http://example.com/index.html');
|
||||
var res = new Response('hello world');
|
||||
var req = new Request("http://example.com/index.html");
|
||||
var res = new Response("hello world");
|
||||
var cache;
|
||||
storage.open('foo').then(function(c) {
|
||||
storage.open("foo").then(function(c) {
|
||||
cache = c;
|
||||
ok(cache, 'storage should create cache');
|
||||
ok(cache, "storage should create cache");
|
||||
return cache.put(req, res.clone());
|
||||
}).then(function() {
|
||||
return cache.match(req);
|
||||
}).then(function(foundResponse) {
|
||||
return Promise.all([res.text(), foundResponse.text()]);
|
||||
}).then(function(results) {
|
||||
is(results[0], results[1], 'cache should contain response');
|
||||
return storage.delete('foo');
|
||||
is(results[0], results[1], "cache should contain response");
|
||||
return storage.delete("foo");
|
||||
}).then(function(deleted) {
|
||||
ok(deleted, 'storage should delete cache');
|
||||
ok(deleted, "storage should delete cache");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче