Bug 546857 Part 5: Add a default permissions.sqlite to unit test profiles. r=ted a=blocker

This commit is contained in:
Jonas Sicking 2010-08-19 16:12:46 -07:00
parent ec59d3da3c
commit a66617aa2d
2 changed files with 33 additions and 2 deletions

View File

@ -51,6 +51,7 @@ import sys
import threading
import tempfile
import zipfile
import sqlite3
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
sys.path.insert(0, SCRIPT_DIR)
@ -289,6 +290,30 @@ class Automation(object):
return locations
def setupPermissionsDatabase(self, profileDir, permissions):
# Open database and create table
permDB = sqlite3.connect(os.path.join(profileDir, "permissions.sqlite"))
cursor = permDB.cursor();
cursor.execute("""CREATE TABLE moz_hosts (
id INTEGER PRIMARY KEY,
host TEXT,
type TEXT,
permission INTEGER,
expireType INTEGER,
expireTime INTEGER)""")
# Insert desired permissions
c = 0
for perm in permissions.keys():
for host in permissions[perm]:
c += 1
cursor.execute("INSERT INTO moz_hosts values(?, ?, ?, 1, 0, 0)",
(c, host, perm))
# Commit and close
permDB.commit()
cursor.close()
def initializeProfile(self, profileDir, extraPrefs = [], useServerLocations = False):
" Sets up the standard testing profile."
@ -297,6 +322,11 @@ class Automation(object):
shutil.rmtree(profileDir, True)
os.mkdir(profileDir)
# Set up permissions database
locations = self.readLocations()
self.setupPermissionsDatabase(profileDir,
{'allowXULXBL':map(lambda l: l.host, locations)});
part = """\
user_pref("browser.dom.window.dump.enabled", true);
user_pref("dom.allow_scripts_to_close_windows", true);
@ -354,8 +384,6 @@ user_pref("capability.principal.codebase.p1.subjectName", "");
""" % { "origin": "http://" + self.webServer + ":" + str(self.httpPort) }
prefs.append(part)
else:
locations = self.readLocations()
# Grant God-power to all the privileged servers on which tests run.
privileged = filter(lambda loc: "privileged" in loc.options, locations)
for (i, l) in itertools.izip(itertools.count(1), privileged):

View File

@ -68,6 +68,9 @@ class RefTest(object):
def createReftestProfile(self, options, profileDir):
"Sets up a profile for reftest."
self.automation.setupPermissionsDatabase(profileDir,
{'allowXULXBL': ['localhost', '<file>']})
# Set preferences.
prefsFile = open(os.path.join(profileDir, "user.js"), "w")
prefsFile.write("""user_pref("browser.dom.window.dump.enabled", true);