mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout e54c3b878993
This commit is contained in:
parent
afb25dcd80
commit
135e7d15b3
@ -164,7 +164,7 @@ function runTest() {
|
||||
ok(app, "App is non-null");
|
||||
is(app.manifestURL, gManifestURL, "App manifest url is correct.");
|
||||
|
||||
var context = {"manifestURL": app.manifestURL};
|
||||
var context = {"manifestURL": app.manifestURL, "isInBrowserElement": false};
|
||||
|
||||
SpecialPowers.pushPermissions([{"type": "homescreen-webapps-manage",
|
||||
"allow": 1,
|
||||
|
@ -32,8 +32,8 @@ function setUp() {
|
||||
|
||||
let appId = gAppsService.getAppLocalIdByManifestURL(APP_MANIFEST);
|
||||
SpecialPowers.addPermission("foobar", true, { url: APP_URL,
|
||||
originAttributes: { appId: appId }
|
||||
});
|
||||
appId: appId,
|
||||
isInBrowserElement: false });
|
||||
SpecialPowers.pushPrefEnv({"set":[['dom.mozBrowserFramesEnabled', true],
|
||||
['dom.ipc.browser_frames.oop_by_default', true]]}, runNextTest);
|
||||
}
|
||||
|
@ -104,13 +104,11 @@
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.pushPermissions([
|
||||
{ "type": "browser", "allow": 1, "context": { "url": principal.URI.spec,
|
||||
"originAttributes": {
|
||||
"appId": principal.appId
|
||||
}}},
|
||||
"appId": principal.appId,
|
||||
"isInBrowserElement": false }},
|
||||
{ "type": "browser", "allow": 1, "context": { "url": principal.URI.spec,
|
||||
"originAttributes": {
|
||||
"appId": principal.appId,
|
||||
"inBrowser": true }}}
|
||||
"appId": principal.appId,
|
||||
"isInBrowserElement": true }}
|
||||
], () => {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
|
@ -23,7 +23,8 @@ function runTest() {
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
var context = { 'url': 'http://example.org',
|
||||
'originAttributes': {'inBrowser': true} };
|
||||
'appId': SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
'isInBrowserElement': true };
|
||||
SpecialPowers.pushPermissions([
|
||||
{'type': 'browser', 'allow': 1, 'context': context},
|
||||
{'type': 'embed-apps', 'allow': 1, 'context': context}
|
||||
|
@ -344,9 +344,8 @@ function testCut2(e) {
|
||||
// Give our origin permission to open browsers, and remove it when the test is complete.
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var context = { 'url': SpecialPowers.wrap(principal.URI).spec,
|
||||
'originAttributes': {
|
||||
'appId': principal.appId,
|
||||
'inBrowser': true }};
|
||||
'appId': principal.appId,
|
||||
'isInBrowserElement': true };
|
||||
|
||||
addEventListener('testready', function() {
|
||||
SpecialPowers.pushPermissions([
|
||||
|
@ -28,8 +28,9 @@ function runTest() {
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
var context = {'url': 'http://example.org',
|
||||
'originAttributes': {'inBrowser': true}};
|
||||
var context = { 'url': 'http://example.org',
|
||||
'appId': SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
'isInBrowserElement': true };
|
||||
SpecialPowers.pushPermissions([
|
||||
{'type': 'browser', 'allow': 1, 'context': context},
|
||||
{'type': 'embed-apps', 'allow': 1, 'context': context}
|
||||
|
@ -36,7 +36,8 @@ function runTest() {
|
||||
allow: true,
|
||||
context: {
|
||||
url: imeUrl,
|
||||
originAttributes: {'inBrowser': true}
|
||||
appId: SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
isInBrowserElement: true
|
||||
}
|
||||
}], SimpleTest.waitForFocus.bind(SimpleTest, createFrames));
|
||||
}
|
||||
|
@ -18,11 +18,9 @@ var iframe;
|
||||
|
||||
function runTest() {
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.addPermission("browser", true, {url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.setAttribute('mozbrowser', 'true');
|
||||
@ -77,11 +75,10 @@ function finish() {
|
||||
iframe.removeEventListener('mozbrowsershowmodalprompt', checkMessage);
|
||||
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.removePermission("browser", {url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,9 @@ browserElementTestHelpers.addPermission();
|
||||
|
||||
function runTest() {
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.addPermission("browser", true, {url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.setAttribute('mozbrowser', 'true');
|
||||
@ -59,10 +57,8 @@ function runTest() {
|
||||
function finish() {
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -22,19 +22,15 @@ SpecialPowers.addPermission("embed-apps", true, document);
|
||||
|
||||
// Give our origin permission to open browsers, and remove it when the test is complete.
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.addPermission("browser", true, {url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
|
||||
addEventListener('unload', function() {
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.removePermission("browser", {url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
});
|
||||
|
||||
function runTest() {
|
||||
|
@ -21,19 +21,15 @@ browserElementTestHelpers.enableProcessPriorityManager();
|
||||
|
||||
// Give our origin permission to open browsers, and remove it when the test is complete.
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.addPermission("browser", true, {url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
|
||||
addEventListener('unload', function() {
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
SpecialPowers.removePermission("browser", {url: SpecialPowers.wrap(principal.URI).spec,
|
||||
originAttributes: {
|
||||
appId: principal.appId,
|
||||
inBrowser: true
|
||||
}});
|
||||
SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
|
||||
appId: principal.appId,
|
||||
isInBrowserElement: true });
|
||||
});
|
||||
|
||||
function runTest() {
|
||||
|
11
dom/cache/test/mochitest/driver.js
vendored
11
dom/cache/test/mochitest/driver.js
vendored
@ -35,7 +35,16 @@ function runTests(testFile, order) {
|
||||
// adapted from dom/indexedDB/test/helpers.js
|
||||
function clearStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.clearStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.clearStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -24,19 +24,46 @@ function setupTestIframe() {
|
||||
|
||||
function clearStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.clearStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.clearStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
function storageUsage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.getStorageUsageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.getStorageUsageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
function resetStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.resetStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.resetStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -24,19 +24,46 @@ function setupTestIframe() {
|
||||
|
||||
function clearStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.clearStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.clearStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
function storageUsage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.getStorageUsageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.getStorageUsageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
function resetStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.resetStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.resetStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
|
11
dom/cache/test/mochitest/test_cache_restart.html
vendored
11
dom/cache/test/mochitest/test_cache_restart.html
vendored
@ -23,7 +23,16 @@ function setupTestIframe() {
|
||||
|
||||
function resetStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.resetStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.resetStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
|
33
dom/cache/test/mochitest/test_cache_shrink.html
vendored
33
dom/cache/test/mochitest/test_cache_shrink.html
vendored
@ -24,19 +24,46 @@ function setupTestIframe() {
|
||||
|
||||
function clearStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.clearStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.clearStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
function storageUsage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.getStorageUsageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.getStorageUsageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
function resetStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.resetStorageForDoc(SpecialPowers.wrap(document), resolve);
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.resetStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,17 @@ function grabFileUsageAndContinueHandler(usage, fileUsage)
|
||||
|
||||
function getUsage(usageHandler)
|
||||
{
|
||||
SpecialPowers.getStorageUsageForDoc(SpecialPowers.wrap(document), usageHandler);
|
||||
let principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
let appId, inBrowser;
|
||||
if (principal.appId != Components.interfaces.nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != Components.interfaces.nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.getStorageUsageForURI(window.document.documentURI,
|
||||
usageHandler,
|
||||
appId,
|
||||
inBrowser);
|
||||
}
|
||||
|
||||
function getFileId(file)
|
||||
|
@ -34,7 +34,14 @@ function executeSoon(aFun)
|
||||
}
|
||||
|
||||
function clearAllDatabases(callback) {
|
||||
SpecialPowers.clearStorageForDoc(SpecialPowers.wrap(document), callback);
|
||||
let principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
let appId, inBrowser;
|
||||
if (principal.appId != Components.interfaces.nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != Components.interfaces.nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.clearStorageForURI(document.documentURI, callback, appId, inBrowser);
|
||||
}
|
||||
|
||||
var testHarnessGenerator = testHarnessSteps();
|
||||
|
@ -117,9 +117,11 @@ function start()
|
||||
}
|
||||
|
||||
SpecialPowers.addPermission("browser", true, document);
|
||||
SpecialPowers.addPermission("browser", true, { manifestURL: manifestURL });
|
||||
SpecialPowers.addPermission("browser", true, { manifestURL: manifestURL,
|
||||
isInBrowserElement: false });
|
||||
SpecialPowers.addPermission("embed-apps", true, document);
|
||||
SpecialPowers.addPermission("indexedDB", true, { manifestURL: manifestURL });
|
||||
SpecialPowers.addPermission("indexedDB", true, { manifestURL: manifestURL,
|
||||
isInBrowserElement: false });
|
||||
|
||||
SpecialPowers.setAllAppsLaunchable(true);
|
||||
|
||||
|
@ -91,9 +91,8 @@ function runTest() {
|
||||
allow: true,
|
||||
context: {
|
||||
url: imeUrl,
|
||||
originAttributes: {
|
||||
inBrowser: true
|
||||
}
|
||||
appId: SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
isInBrowserElement: true
|
||||
}
|
||||
}], function() {
|
||||
keyboardA.src = imeUrl;
|
||||
|
@ -78,9 +78,8 @@ function runTest() {
|
||||
allow: true,
|
||||
context: {
|
||||
url: imeUrl,
|
||||
originAttributes: {
|
||||
inBrowser: true
|
||||
}
|
||||
appId: SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
isInBrowserElement: true
|
||||
}
|
||||
}], function() {
|
||||
// STEP 2c: Tell Gecko to use this iframe as its keyboard app
|
||||
|
@ -141,9 +141,8 @@ function setupInputAppFrame() {
|
||||
allow: true,
|
||||
context: {
|
||||
url: imeUrl,
|
||||
originAttributes: {
|
||||
inBrowser: true
|
||||
}
|
||||
appId: SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
isInBrowserElement: true
|
||||
}
|
||||
}], function() {
|
||||
let mm = SpecialPowers.getBrowserFrameMessageManager(inputAppFrame);
|
||||
|
@ -70,9 +70,8 @@ function setupInputAppFrame() {
|
||||
allow: true,
|
||||
context: {
|
||||
url: imeUrl,
|
||||
originAttributes: {
|
||||
inBrowser: true
|
||||
}
|
||||
appId: SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
isInBrowserElement: true
|
||||
}
|
||||
}], function() {
|
||||
let mm = appFrameMM =
|
||||
|
@ -103,9 +103,8 @@ function setupInputAppFrame() {
|
||||
allow: true,
|
||||
context: {
|
||||
url: imeUrl,
|
||||
originAttributes: {
|
||||
inBrowser: true
|
||||
}
|
||||
appId: SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||
isInBrowserElement: true
|
||||
}
|
||||
}], function() {
|
||||
let mm = appFrameMM =
|
||||
|
@ -33,7 +33,8 @@ var tests = [
|
||||
function() {
|
||||
var appId = gAppsService.getAppLocalIdByManifestURL(embedAppHostedManifestURL);
|
||||
var context = { url: embedApp.origin,
|
||||
originAttributes: { appId: appId } };
|
||||
appId: appId,
|
||||
isInBrowserElement: false };
|
||||
setupOpenAppPermission(context, runTests);
|
||||
},
|
||||
|
||||
|
@ -33,7 +33,8 @@ var tests = [
|
||||
function() {
|
||||
var appId = gAppsService.getAppLocalIdByManifestURL(embedAppHostedManifestURL);
|
||||
var context = { url: embedApp.origin,
|
||||
originAttributes: { appId: appId } };
|
||||
appId: appId,
|
||||
isInBrowserElement: false };
|
||||
setupOpenAppPermission(context, runTests);
|
||||
},
|
||||
|
||||
|
@ -53,7 +53,8 @@ function test1() {
|
||||
|
||||
if (!SpecialPowers.hasPermission( PERMISSION_TYPE,
|
||||
{ url: APP_URL,
|
||||
originAttributes: { appId: appId }})) {
|
||||
appId: appId,
|
||||
isInBrowserElement: false })) {
|
||||
errorHandler('[test 1] App should have permission: ' + PERMISSION_TYPE);
|
||||
}
|
||||
|
||||
@ -81,7 +82,8 @@ function test2() {
|
||||
|
||||
if (!SpecialPowers.hasPermission( PERMISSION_TYPE,
|
||||
{ url: APP_URL,
|
||||
originAttributes: { appId: appId }})) {
|
||||
appId: appId,
|
||||
isInBrowserElement: false })) {
|
||||
errorHandler('[test 2] App should have permission: ' + PERMISSION_TYPE);
|
||||
}
|
||||
|
||||
@ -109,7 +111,8 @@ function test3() {
|
||||
|
||||
if (!SpecialPowers.hasPermission(PERMISSION_TYPE,
|
||||
{ url: APP_URL,
|
||||
originAttributes: { appId: appId }})) {
|
||||
appId: appId,
|
||||
isInBrowserElement: false })) {
|
||||
errorHandler('[test 3] App should have permission: ' + PERMISSION_TYPE);
|
||||
}
|
||||
}
|
||||
@ -145,7 +148,8 @@ function test4() {
|
||||
|
||||
if (!SpecialPowers.hasPermission(PERMISSION_TYPE,
|
||||
{ url: APP_URL,
|
||||
originAttributes: { appId: appId }})) {
|
||||
appId: appId,
|
||||
isInBrowserElement: false })) {
|
||||
errorHandler('[test 4] App should have permission: ' + PERMISSION_TYPE);
|
||||
}
|
||||
}
|
||||
@ -170,7 +174,8 @@ function test5() {
|
||||
|
||||
if (!SpecialPowers.hasPermission( PERMISSION_TYPE,
|
||||
{ url: APP_URL,
|
||||
originAttributes: { appId: appId }})) {
|
||||
appId: appId,
|
||||
isInBrowserElement: false })) {
|
||||
errorHandler('[test 5] App should have permission: ' + PERMISSION_TYPE);
|
||||
}
|
||||
|
||||
@ -285,7 +290,8 @@ function addPermissionToApp(appURL, manifestURL) {
|
||||
"expireType":permManager.EXPIRE_SESSION,
|
||||
"expireTime":now + SESSION_PERSIST_MINUTES*60*1000,
|
||||
"context": { url: appURL,
|
||||
originAttributes: { appId: appId } }
|
||||
appId: appId,
|
||||
isInBrowserElement:false }
|
||||
}
|
||||
], function() {
|
||||
runTests();
|
||||
@ -297,7 +303,8 @@ function runNextIfAppHasPermission(round, expect, appURL, manifestURL) {
|
||||
|
||||
var hasPerm = SpecialPowers.hasPermission(PERMISSION_TYPE,
|
||||
{ url: appURL,
|
||||
originAttributes: { appId: appId }});
|
||||
appId: appId,
|
||||
isInBrowserElement: false });
|
||||
var result = (expect==hasPerm);
|
||||
if (result) {
|
||||
runTests();
|
||||
|
@ -33,7 +33,8 @@ var tests = [
|
||||
function() {
|
||||
var appId = gAppsService.getAppLocalIdByManifestURL(embedAppHostedManifestURL);
|
||||
var context = { url: embedApp.origin,
|
||||
originAttributes: { appId: appId } };
|
||||
appId: appId,
|
||||
isInBrowserElement: false };
|
||||
setupOpenAppPermission(context, runTests);
|
||||
},
|
||||
|
||||
|
@ -22,9 +22,8 @@ function installApp(aTestToken, aTemplate) {
|
||||
|
||||
var appId = gAppsService.getAppLocalIdByManifestURL(gApp.manifestURL);
|
||||
SpecialPowers.addPermission("tv", true, { url: gApp.origin,
|
||||
originAttributes: {
|
||||
appId: appId
|
||||
}});
|
||||
appId: appId,
|
||||
isInBrowserElement: false });
|
||||
|
||||
runTest();
|
||||
}
|
||||
|
@ -69,7 +69,8 @@ function installApp(aTestToken, aTemplate) {
|
||||
function pushPermissionsToApp() {
|
||||
var appId = gAppsService.getAppLocalIdByManifestURL(gApp.manifestURL);
|
||||
var context = { url: gApp.origin,
|
||||
originAttributes: {appId: appId}};
|
||||
appId: appId,
|
||||
isInBrowserElement: false };
|
||||
SpecialPowers.pushPermissions([
|
||||
{ "type": "pAppPermission", "allow": true, "context": context }
|
||||
], testPermissionsForApp);
|
||||
@ -78,7 +79,8 @@ function pushPermissionsToApp() {
|
||||
function testPermissionsForApp() {
|
||||
var appId = gAppsService.getAppLocalIdByManifestURL(gApp.manifestURL);
|
||||
var context = { url: gApp.origin,
|
||||
originAttributes: {appId: appId}};
|
||||
appId: appId,
|
||||
isInBrowserElement: false };
|
||||
ok(SpecialPowers.hasPermission('pAppPermission', context), 'pAppPermission should have permission');
|
||||
uninstallApp();
|
||||
}
|
||||
@ -93,10 +95,10 @@ function uninstallApp() {
|
||||
|
||||
function testPermissionsForSelfAndApp() {
|
||||
var appId = gAppsService.getAppLocalIdByManifestURL(gApp.manifestURL);
|
||||
is(appId, 0, "appId should become NO_APP_ID");
|
||||
// since gApp is uninstalled, calling SpecialPowers.hasPermission with the
|
||||
// app's properties (manifestURL, origin, principal, ... etc) will throw.
|
||||
// So we don't need to test hasPermission for the app.
|
||||
var context = { url: gApp.origin,
|
||||
appId: appId,
|
||||
isInBrowserElement: false };
|
||||
ok(!SpecialPowers.hasPermission('pAppPermission', context), 'pAppPermission should not have permission');
|
||||
|
||||
ok(SpecialPowers.hasPermission('pAppPermission', document), 'pAppPermission should have permission');
|
||||
|
||||
|
@ -57,7 +57,8 @@ function starttest(){
|
||||
SpecialPowers.addPermission(perms[0], true, origin);
|
||||
SpecialPowers.addPermission(perms[1], true, {manifestURL: manifest});
|
||||
SpecialPowers.addPermission(perms[2], true, document);
|
||||
SpecialPowers.addPermission(perms[3], true, {url: origin});
|
||||
SpecialPowers.addPermission(perms[3], true, {url: origin,
|
||||
appId: Ci.nsIScriptSecurityManager.NO_APP_ID});
|
||||
|
||||
is(Services.perms.testPermissionFromPrincipal(noappPrincipal, perms[0]),
|
||||
allow, "Set permission by string");
|
||||
@ -73,7 +74,8 @@ function starttest(){
|
||||
SpecialPowers.removePermission(perms[0], origin);
|
||||
SpecialPowers.removePermission(perms[1], {manifestURL: manifest});
|
||||
SpecialPowers.removePermission(perms[2], document);
|
||||
SpecialPowers.removePermission(perms[3], {url: origin});
|
||||
SpecialPowers.removePermission(perms[3], {url: origin,
|
||||
appId: Ci.nsIScriptSecurityManager.NO_APP_ID});
|
||||
|
||||
is(Services.perms.testPermissionFromPrincipal(noappPrincipal, perms[0]),
|
||||
unknown, "Removed permission by string");
|
||||
|
@ -234,10 +234,7 @@ SpecialPowersObserver.prototype = new SpecialPowersObserverAPI();
|
||||
// We need to ensure that it looks the same as a real permission,
|
||||
// so we fake these properties.
|
||||
msg.permission = {
|
||||
principal: {
|
||||
appId: permission.principal.appId,
|
||||
originAttributes: {appId: permission.principal.appId}
|
||||
},
|
||||
principal: { appId: permission.principal.appId },
|
||||
type: permission.type
|
||||
};
|
||||
default:
|
||||
|
@ -321,7 +321,11 @@ SpecialPowersObserverAPI.prototype = {
|
||||
|
||||
case "SPPermissionManager": {
|
||||
let msg = aMessage.json;
|
||||
let principal = msg.principal;
|
||||
|
||||
let secMan = Services.scriptSecurityManager;
|
||||
// TODO: Bug 1196665 - Add originAttributes into SpecialPowers
|
||||
let attrs = {appId: msg.appId, inBrowser: msg.isInBrowserElement};
|
||||
let principal = secMan.createCodebasePrincipal(this._getURI(msg.url), attrs);
|
||||
|
||||
switch (msg.op) {
|
||||
case "add":
|
||||
@ -332,10 +336,17 @@ SpecialPowersObserverAPI.prototype = {
|
||||
break;
|
||||
case "has":
|
||||
let hasPerm = Services.perms.testPermissionFromPrincipal(principal, msg.type);
|
||||
return hasPerm == Ci.nsIPermissionManager.ALLOW_ACTION;
|
||||
if (hasPerm == Ci.nsIPermissionManager.ALLOW_ACTION)
|
||||
return true;
|
||||
return false;
|
||||
break;
|
||||
case "test":
|
||||
let testPerm = Services.perms.testPermissionFromPrincipal(principal, msg.type, msg.value);
|
||||
return testPerm == msg.value;
|
||||
if (testPerm == msg.value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
throw new SpecialPowersError(
|
||||
"Invalid operation for SPPermissionManager");
|
||||
@ -499,13 +510,18 @@ SpecialPowersObserverAPI.prototype = {
|
||||
.frameLoader
|
||||
.messageManager;
|
||||
let msg = aMessage.data;
|
||||
let principal = msg.principal;
|
||||
let op = msg.op;
|
||||
|
||||
if (op != 'clear' && op != 'getUsage' && op != 'reset') {
|
||||
throw new SpecialPowersError('Invalid operation for SPQuotaManager');
|
||||
}
|
||||
|
||||
let secMan = Services.scriptSecurityManager;
|
||||
let principal = secMan.createCodebasePrincipal(this._getURI(msg.uri), {
|
||||
appId: msg.appId,
|
||||
inBrowser: msg.inBrowser,
|
||||
});
|
||||
|
||||
if (op == 'clear') {
|
||||
qm.clearStoragesForPrincipal(principal);
|
||||
} else if (op == 'reset') {
|
||||
|
@ -786,7 +786,7 @@ SpecialPowersAPI.prototype = {
|
||||
originalValue = Ci.nsICookiePermission.ACCESS_LIMIT_THIRD_PARTY;
|
||||
}
|
||||
|
||||
let [principal, isSystem] = this._getInfoFromPermissionArg(context);
|
||||
let [url, appId, isInBrowserElement, isSystem] = this._getInfoFromPermissionArg(context);
|
||||
if (isSystem) {
|
||||
continue;
|
||||
}
|
||||
@ -810,7 +810,9 @@ SpecialPowersAPI.prototype = {
|
||||
'type': permission.type,
|
||||
'permission': perm,
|
||||
'value': perm,
|
||||
'principal': principal,
|
||||
'url': url,
|
||||
'appId': appId,
|
||||
'isInBrowserElement': isInBrowserElement,
|
||||
'expireType': (typeof permission.expireType === "number") ?
|
||||
permission.expireType : 0, // default: EXPIRE_NEVER
|
||||
'expireTime': (typeof permission.expireTime === "number") ?
|
||||
@ -965,7 +967,7 @@ SpecialPowersAPI.prototype = {
|
||||
for (var j = 0; j < undos.length; j++) {
|
||||
var undo = undos[j];
|
||||
if (undo.op == this._obsDataMap[aData] &&
|
||||
undo.principal.originAttributes.appId == permission.principal.originAttributes.appId &&
|
||||
undo.appId == permission.principal.appId &&
|
||||
undo.type == permission.type) {
|
||||
// Remove this undo item if it has been done by others(not
|
||||
// specialpowers itself.)
|
||||
@ -1819,43 +1821,55 @@ SpecialPowersAPI.prototype = {
|
||||
},
|
||||
|
||||
_getInfoFromPermissionArg: function(arg) {
|
||||
let principal;
|
||||
let url = "";
|
||||
let appId = Ci.nsIScriptSecurityManager.NO_APP_ID;
|
||||
let isInBrowserElement = false;
|
||||
let isSystem = false;
|
||||
let secMan = Services.scriptSecurityManager;
|
||||
|
||||
if (typeof(arg) == "string") {
|
||||
// It's an URL.
|
||||
let uri = Services.io.newURI(arg, null, null);
|
||||
principal = secMan.createCodebasePrincipal(uri, {});
|
||||
url = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService)
|
||||
.newURI(arg, null, null)
|
||||
.spec;
|
||||
} else if (arg.manifestURL) {
|
||||
// It's a thing representing an app.
|
||||
let appsSvc = Cc["@mozilla.org/AppsService;1"]
|
||||
.getService(Ci.nsIAppsService)
|
||||
let app = appsSvc.getAppByManifestURL(arg.manifestURL);
|
||||
|
||||
if (!app) {
|
||||
throw "No app for this manifest!";
|
||||
}
|
||||
|
||||
principal = app.principal;
|
||||
appId = appsSvc.getAppLocalIdByManifestURL(arg.manifestURL);
|
||||
url = app.origin;
|
||||
isInBrowserElement = arg.isInBrowserElement || false;
|
||||
} else if (arg.nodePrincipal) {
|
||||
// It's a document.
|
||||
isSystem = (arg.nodePrincipal instanceof Ci.nsIPrincipal) &&
|
||||
Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager)
|
||||
.isSystemPrincipal(arg.nodePrincipal);
|
||||
// some tests the arg is a wrapped DOM element, so we unwrap it first.
|
||||
principal = unwrapIfWrapped(arg).nodePrincipal;
|
||||
Cc["@mozilla.org/scriptsecuritymanager;1"].
|
||||
getService(Ci.nsIScriptSecurityManager).
|
||||
isSystemPrincipal(arg.nodePrincipal);
|
||||
if (!isSystem) {
|
||||
// System principals don't have a URL associated with them, and they
|
||||
// don't really need any permissions to be registered with the
|
||||
// permission manager anyway.
|
||||
url = arg.nodePrincipal.URI.spec;
|
||||
appId = arg.nodePrincipal.appId;
|
||||
isInBrowserElement = arg.nodePrincipal.isInBrowserElement;
|
||||
}
|
||||
} else {
|
||||
let uri = Services.io.newURI(arg.url, null, null);
|
||||
let attrs = arg.originAttributes || {};
|
||||
principal = secMan.createCodebasePrincipal(uri, attrs);
|
||||
url = arg.url;
|
||||
appId = arg.appId;
|
||||
isInBrowserElement = arg.isInBrowserElement;
|
||||
}
|
||||
|
||||
return [ principal, isSystem ];
|
||||
return [ url, appId, isInBrowserElement, isSystem ];
|
||||
},
|
||||
|
||||
addPermission: function(type, allow, arg, expireType, expireTime) {
|
||||
let [principal, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
let [url, appId, isInBrowserElement, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
if (isSystem) {
|
||||
return; // nothing to do
|
||||
}
|
||||
@ -1872,7 +1886,9 @@ SpecialPowersAPI.prototype = {
|
||||
'op': 'add',
|
||||
'type': type,
|
||||
'permission': permission,
|
||||
'principal': principal,
|
||||
'url': url,
|
||||
'appId': appId,
|
||||
'isInBrowserElement': isInBrowserElement,
|
||||
'expireType': (typeof expireType === "number") ? expireType : 0,
|
||||
'expireTime': (typeof expireTime === "number") ? expireTime : 0
|
||||
};
|
||||
@ -1881,7 +1897,7 @@ SpecialPowersAPI.prototype = {
|
||||
},
|
||||
|
||||
removePermission: function(type, arg) {
|
||||
let [principal, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
let [url, appId, isInBrowserElement, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
if (isSystem) {
|
||||
return; // nothing to do
|
||||
}
|
||||
@ -1889,14 +1905,16 @@ SpecialPowersAPI.prototype = {
|
||||
var msg = {
|
||||
'op': 'remove',
|
||||
'type': type,
|
||||
'principal': principal
|
||||
'url': url,
|
||||
'appId': appId,
|
||||
'isInBrowserElement': isInBrowserElement
|
||||
};
|
||||
|
||||
this._sendSyncMessage('SPPermissionManager', msg);
|
||||
},
|
||||
|
||||
hasPermission: function (type, arg) {
|
||||
let [principal, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
let [url, appId, isInBrowserElement, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
if (isSystem) {
|
||||
return true; // system principals have all permissions
|
||||
}
|
||||
@ -1904,14 +1922,15 @@ SpecialPowersAPI.prototype = {
|
||||
var msg = {
|
||||
'op': 'has',
|
||||
'type': type,
|
||||
'principal': principal
|
||||
'url': url,
|
||||
'appId': appId,
|
||||
'isInBrowserElement': isInBrowserElement
|
||||
};
|
||||
|
||||
return this._sendSyncMessage('SPPermissionManager', msg)[0];
|
||||
},
|
||||
|
||||
testPermission: function (type, value, arg) {
|
||||
let [principal, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
let [url, appId, isInBrowserElement, isSystem] = this._getInfoFromPermissionArg(arg);
|
||||
if (isSystem) {
|
||||
return true; // system principals have all permissions
|
||||
}
|
||||
@ -1919,8 +1938,10 @@ SpecialPowersAPI.prototype = {
|
||||
var msg = {
|
||||
'op': 'test',
|
||||
'type': type,
|
||||
'value': value,
|
||||
'principal': principal
|
||||
'value': value,
|
||||
'url': url,
|
||||
'appId': appId,
|
||||
'isInBrowserElement': isInBrowserElement
|
||||
};
|
||||
return this._sendSyncMessage('SPPermissionManager', msg)[0];
|
||||
},
|
||||
@ -1945,20 +1966,28 @@ SpecialPowersAPI.prototype = {
|
||||
this._sendSyncMessage('SPObserverService', msg);
|
||||
},
|
||||
|
||||
clearStorageForDoc: function(wrappedDocument, callback) {
|
||||
this._quotaManagerRequest('clear', wrappedDocument, callback);
|
||||
clearStorageForURI: function(uri, callback, appId, inBrowser) {
|
||||
this._quotaManagerRequest('clear', uri, appId, inBrowser, callback);
|
||||
},
|
||||
|
||||
getStorageUsageForDoc: function(wrappedDocument, callback) {
|
||||
this._quotaManagerRequest('getUsage', wrappedDocument, callback);
|
||||
getStorageUsageForURI: function(uri, callback, appId, inBrowser) {
|
||||
this._quotaManagerRequest('getUsage', uri, appId, inBrowser, callback);
|
||||
},
|
||||
|
||||
resetStorageForDoc: function(wrappedDocument, callback) {
|
||||
this._quotaManagerRequest('reset', wrappedDocument, callback);
|
||||
// Technically this restarts the QuotaManager for all URIs, but we need
|
||||
// a specific one to perform the synchronized callback when the reset is
|
||||
// complete.
|
||||
resetStorageForURI: function(uri, callback, appId, inBrowser) {
|
||||
this._quotaManagerRequest('reset', uri, appId, inBrowser, callback);
|
||||
},
|
||||
|
||||
_quotaManagerRequest: function(op, wrappedDocument, callback) {
|
||||
_quotaManagerRequest: function(op, uri, appId, inBrowser, callback) {
|
||||
const messageTopic = "SPQuotaManager";
|
||||
|
||||
if (uri instanceof Ci.nsIURI) {
|
||||
uri = uri.spec;
|
||||
}
|
||||
|
||||
const id = Cc["@mozilla.org/uuid-generator;1"]
|
||||
.getService(Ci.nsIUUIDGenerator)
|
||||
.generateUUID()
|
||||
@ -1995,8 +2024,7 @@ SpecialPowersAPI.prototype = {
|
||||
this._quotaManagerCallbackInfos = [ callbackInfo ];
|
||||
}
|
||||
|
||||
let principal = unwrapIfWrapped(wrappedDocument).nodePrincipal;
|
||||
let msg = { op: op, principal: principal, id: id };
|
||||
let msg = { op: op, uri: uri, appId: appId, inBrowser: inBrowser, id: id };
|
||||
this._sendAsyncMessage(messageTopic, msg);
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user