Merge branch 'master' of github.com:andreasgal/pdf.js
This commit is contained in:
commit
6c8f78a59c
10
test/resources/browser_manifests/browser_manifest.json.linux
Normal file
10
test/resources/browser_manifests/browser_manifest.json.linux
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name":"firefox7",
|
||||||
|
"path":"/home/sayrer/firefoxen/nightly/firefox"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"chrome14",
|
||||||
|
"path":"/opt/google/chrome/chrome"
|
||||||
|
}
|
||||||
|
]
|
@ -6,5 +6,9 @@
|
|||||||
{
|
{
|
||||||
"name":"firefox6",
|
"name":"firefox6",
|
||||||
"path":"/Users/sayrer/firefoxen/Aurora.app"
|
"path":"/Users/sayrer/firefoxen/Aurora.app"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"chrome14",
|
||||||
|
"path":"/Applications/Google Chrome.app"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
63
test/test.py
63
test/test.py
@ -2,7 +2,7 @@ import json, platform, os, shutil, sys, subprocess, tempfile, threading, time, u
|
|||||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||||
import SocketServer
|
import SocketServer
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse, parse_qs
|
||||||
|
|
||||||
USAGE_EXAMPLE = "%prog"
|
USAGE_EXAMPLE = "%prog"
|
||||||
|
|
||||||
@ -132,6 +132,11 @@ class PDFTestHandler(BaseHTTPRequestHandler):
|
|||||||
self.send_header('Content-Type', 'text/plain')
|
self.send_header('Content-Type', 'text/plain')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
|
url = urlparse(self.path)
|
||||||
|
if url.path == "/tellMeToQuit":
|
||||||
|
tellAppToQuit(url.path, url.query)
|
||||||
|
return
|
||||||
|
|
||||||
result = json.loads(self.rfile.read(numBytes))
|
result = json.loads(self.rfile.read(numBytes))
|
||||||
browser, id, failure, round, page, snapshot = result['browser'], result['id'], result['failure'], result['round'], result['page'], result['snapshot']
|
browser, id, failure, round, page, snapshot = result['browser'], result['id'], result['failure'], result['round'], result['page'], result['snapshot']
|
||||||
taskResults = State.taskResults[browser][id]
|
taskResults = State.taskResults[browser][id]
|
||||||
@ -156,8 +161,20 @@ class PDFTestHandler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
State.done = (0 == State.remaining)
|
State.done = (0 == State.remaining)
|
||||||
|
|
||||||
# this just does Firefox for now
|
# Applescript hack to quit Chrome on Mac
|
||||||
class BrowserCommand():
|
def tellAppToQuit(path, query):
|
||||||
|
if platform.system() != "Darwin":
|
||||||
|
return
|
||||||
|
d = parse_qs(query)
|
||||||
|
path = d['path'][0]
|
||||||
|
cmd = """osascript<<END
|
||||||
|
tell application "%s"
|
||||||
|
quit
|
||||||
|
end tell
|
||||||
|
END""" % path
|
||||||
|
os.system(cmd)
|
||||||
|
|
||||||
|
class BaseBrowserCommand(object):
|
||||||
def __init__(self, browserRecord):
|
def __init__(self, browserRecord):
|
||||||
self.name = browserRecord["name"]
|
self.name = browserRecord["name"]
|
||||||
self.path = browserRecord["path"]
|
self.path = browserRecord["path"]
|
||||||
@ -170,14 +187,9 @@ class BrowserCommand():
|
|||||||
if not os.path.exists(self.path):
|
if not os.path.exists(self.path):
|
||||||
throw("Path to browser '%s' does not exist." % self.path)
|
throw("Path to browser '%s' does not exist." % self.path)
|
||||||
|
|
||||||
def _fixupMacPath(self):
|
|
||||||
self.path = os.path.join(self.path, "Contents", "MacOS", "firefox-bin")
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.tempDir = tempfile.mkdtemp()
|
self.tempDir = tempfile.mkdtemp()
|
||||||
self.profileDir = os.path.join(self.tempDir, "profile")
|
self.profileDir = os.path.join(self.tempDir, "profile")
|
||||||
shutil.copytree(os.path.join(DOC_ROOT, "test", "resources", "firefox"),
|
|
||||||
self.profileDir)
|
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
# If the browser is still running, wait up to ten seconds for it to quit
|
# If the browser is still running, wait up to ten seconds for it to quit
|
||||||
@ -194,6 +206,18 @@ class BrowserCommand():
|
|||||||
if self.tempDir is not None and os.path.exists(self.tempDir):
|
if self.tempDir is not None and os.path.exists(self.tempDir):
|
||||||
shutil.rmtree(self.tempDir)
|
shutil.rmtree(self.tempDir)
|
||||||
|
|
||||||
|
def start(self, url):
|
||||||
|
raise Exception("Can't start BaseBrowserCommand")
|
||||||
|
|
||||||
|
class FirefoxBrowserCommand(BaseBrowserCommand):
|
||||||
|
def _fixupMacPath(self):
|
||||||
|
self.path = os.path.join(self.path, "Contents", "MacOS", "firefox-bin")
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
super(FirefoxBrowserCommand, self).setup()
|
||||||
|
shutil.copytree(os.path.join(DOC_ROOT, "test", "resources", "firefox"),
|
||||||
|
self.profileDir)
|
||||||
|
|
||||||
def start(self, url):
|
def start(self, url):
|
||||||
cmds = [self.path]
|
cmds = [self.path]
|
||||||
if platform.system() == "Darwin":
|
if platform.system() == "Darwin":
|
||||||
@ -201,9 +225,29 @@ class BrowserCommand():
|
|||||||
cmds.extend(["-no-remote", "-profile", self.profileDir, url])
|
cmds.extend(["-no-remote", "-profile", self.profileDir, url])
|
||||||
self.process = subprocess.Popen(cmds)
|
self.process = subprocess.Popen(cmds)
|
||||||
|
|
||||||
|
class ChromeBrowserCommand(BaseBrowserCommand):
|
||||||
|
def _fixupMacPath(self):
|
||||||
|
self.path = os.path.join(self.path, "Contents", "MacOS", "Google Chrome")
|
||||||
|
|
||||||
|
def start(self, url):
|
||||||
|
cmds = [self.path]
|
||||||
|
cmds.extend(["--user-data-dir=%s" % self.profileDir,
|
||||||
|
"--no-first-run", "--disable-sync", url])
|
||||||
|
self.process = subprocess.Popen(cmds)
|
||||||
|
|
||||||
|
def makeBrowserCommand(browser):
|
||||||
|
path = browser["path"].lower()
|
||||||
|
name = browser["name"].lower()
|
||||||
|
if name.find("firefox") > -1 or path.find("firefox") > -1:
|
||||||
|
return FirefoxBrowserCommand(browser)
|
||||||
|
elif name.find("chrom") > -1 or path.find("chrom") > -1:
|
||||||
|
return ChromeBrowserCommand(browser)
|
||||||
|
else:
|
||||||
|
raise Exception("Unrecognized browser: %s" % browser)
|
||||||
|
|
||||||
def makeBrowserCommands(browserManifestFile):
|
def makeBrowserCommands(browserManifestFile):
|
||||||
with open(browserManifestFile) as bmf:
|
with open(browserManifestFile) as bmf:
|
||||||
browsers = [BrowserCommand(browser) for browser in json.load(bmf)]
|
browsers = [makeBrowserCommand(browser) for browser in json.load(bmf)]
|
||||||
return browsers
|
return browsers
|
||||||
|
|
||||||
def downloadLinkedPDFs(manifestList):
|
def downloadLinkedPDFs(manifestList):
|
||||||
@ -267,6 +311,7 @@ def startBrowsers(browsers, options):
|
|||||||
b.setup()
|
b.setup()
|
||||||
print 'Launching', b.name
|
print 'Launching', b.name
|
||||||
qs = 'browser='+ urllib.quote(b.name) +'&manifestFile='+ urllib.quote(options.manifestFile)
|
qs = 'browser='+ urllib.quote(b.name) +'&manifestFile='+ urllib.quote(options.manifestFile)
|
||||||
|
qs += '&path=' + b.path
|
||||||
b.start('http://localhost:8080/test/test_slave.html?'+ qs)
|
b.start('http://localhost:8080/test/test_slave.html?'+ qs)
|
||||||
|
|
||||||
def teardownBrowsers(browsers):
|
def teardownBrowsers(browsers):
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<script type="text/javascript" src="/fonts.js"></script>
|
<script type="text/javascript" src="/fonts.js"></script>
|
||||||
<script type="text/javascript" src="/glyphlist.js"></script>
|
<script type="text/javascript" src="/glyphlist.js"></script>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
var browser, canvas, currentTask, currentTaskIdx, failure, manifest, numPages, pdfDoc, stdout;
|
var appPath, browser, canvas, currentTask, currentTaskIdx, failure, manifest, numPages, pdfDoc, stdout;
|
||||||
|
|
||||||
function queryParams() {
|
function queryParams() {
|
||||||
var qs = window.location.search.substring(1);
|
var qs = window.location.search.substring(1);
|
||||||
@ -23,12 +23,13 @@ function load() {
|
|||||||
var params = queryParams();
|
var params = queryParams();
|
||||||
browser = params.browser;
|
browser = params.browser;
|
||||||
manifestFile = params.manifestFile;
|
manifestFile = params.manifestFile;
|
||||||
|
appPath = params.path;
|
||||||
|
|
||||||
canvas = document.createElement("canvas");
|
canvas = document.createElement("canvas");
|
||||||
canvas.mozOpaque = true;
|
canvas.mozOpaque = true;
|
||||||
stdout = document.getElementById("stdout");
|
stdout = document.getElementById("stdout");
|
||||||
|
|
||||||
log("Harness thinks this browser is '"+ browser +"'\n");
|
log("Harness thinks this browser is '"+ browser + "' with path " + appPath + "\n");
|
||||||
log("Fetching manifest "+ manifestFile +"...");
|
log("Fetching manifest "+ manifestFile +"...");
|
||||||
|
|
||||||
var r = new XMLHttpRequest();
|
var r = new XMLHttpRequest();
|
||||||
@ -157,13 +158,21 @@ function snapshotCurrentPage(gfx) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendQuitRequest() {
|
||||||
|
var r = new XMLHttpRequest();
|
||||||
|
r.open("POST", "/tellMeToQuit?path=" + escape(appPath), false);
|
||||||
|
r.send("");
|
||||||
|
}
|
||||||
|
|
||||||
function quitApp() {
|
function quitApp() {
|
||||||
log("Done!");
|
log("Done!");
|
||||||
document.body.innerHTML = "Tests are finished. <h1>CLOSE ME!</h1>";
|
document.body.innerHTML = "Tests are finished. <h1>CLOSE ME!</h1>";
|
||||||
if (window.SpecialPowers)
|
if (window.SpecialPowers) {
|
||||||
SpecialPowers.quitApplication();
|
SpecialPowers.quitApplication();
|
||||||
else
|
} else {
|
||||||
|
sendQuitRequest();
|
||||||
window.close();
|
window.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function done() {
|
function done() {
|
||||||
|
Loading…
Reference in New Issue
Block a user