Bug 1262766 - Storage Inspector breaks down when Cache Storage throws a DOM security error. r=mratcliffe

This commit is contained in:
Jarda Snajdr 2016-04-11 01:23:00 -04:00
Родитель e5a08515d2
Коммит 8eb506fa5f
4 изменённых файлов: 59 добавлений и 8 удалений

Просмотреть файл

@ -2,6 +2,7 @@
tags = devtools
subsuite = devtools
support-files =
storage-cache-error.html
storage-complex-values.html
storage-cookies.html
storage-listings.html
@ -15,6 +16,7 @@ support-files =
head.js
[browser_storage_basic.js]
[browser_storage_cache_error.js]
[browser_storage_cookies_delete_all.js]
[browser_storage_cookies_edit.js]
[browser_storage_cookies_edit_keyboard.js]

Просмотреть файл

@ -0,0 +1,21 @@
/* 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/. */
/* import-globals-from head.js */
"use strict";
// Test handling errors in CacheStorage
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cache-error.html");
const cacheItemId = ["Cache", "javascript:parent.frameContent"];
gUI.tree.selectedItem = cacheItemId;
ok(gUI.tree.isSelected(cacheItemId),
`The item ${cacheItemId.join(" > ")} is present in the tree`);
yield finishTests();
});

Просмотреть файл

@ -0,0 +1,20 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Storage inspector test for handling errors in CacheStorage</title>
</head>
<body>
<script type="application/javascript;version=1.7">
"use strict";
// Create an iframe with a javascript: source URL. Such iframes are
// considered untrusted by the CacheStorage.
let frameEl = document.createElement("iframe");
document.body.appendChild(frameEl);
window.frameContent = 'Hello World';
frameEl.contentWindow.location.href = "javascript:parent.frameContent";
</script>
</body>
</html>

Просмотреть файл

@ -352,7 +352,9 @@ StorageActors.defaults = function(typeName, observationTopic, storeObjectType) {
// We only acquire principal when the type of the storage is indexedDB
// because the principal only matters the indexedDB.
let win = this.storageActor.getWindowFromHost(host);
principal = win.document.nodePrincipal;
if (win) {
principal = win.document.nodePrincipal;
}
}
if (names) {
@ -1345,8 +1347,12 @@ StorageActors.createActor({
populateStoresForHost: Task.async(function*(host) {
let storeMap = new Map();
let caches = yield this.getCachesForHost(host);
for (let name of (yield caches.keys())) {
storeMap.set(name, (yield caches.open(name)));
try {
for (let name of (yield caches.keys())) {
storeMap.set(name, (yield caches.open(name)));
}
} catch (ex) {
console.error(`Failed to enumerate CacheStorage for host ${host}:`, ex);
}
this.hostVsStores.set(host, storeMap);
}),
@ -1606,13 +1612,15 @@ StorageActors.createActor({
let storeMap = new Map();
let {names} = yield this.getDBNamesForHost(host);
let win = this.storageActor.getWindowFromHost(host);
let principal = win.document.nodePrincipal;
if (win) {
let principal = win.document.nodePrincipal;
for (let name of names) {
let metadata = yield this.getDBMetaData(host, principal, name);
for (let name of names) {
let metadata = yield this.getDBMetaData(host, principal, name);
metadata = indexedDBHelpers.patchMetadataMapsAndProtos(metadata);
storeMap.set(name, metadata);
metadata = indexedDBHelpers.patchMetadataMapsAndProtos(metadata);
storeMap.set(name, metadata);
}
}
this.hostVsStores.set(host, storeMap);