Merge pull request #79 from sayrer/master
Just some small fixes making the test harness a little better. r=gal
This commit is contained in:
		
						commit
						d08943b51d
					
				@ -33,3 +33,4 @@ user_pref("browser.panorama.experienced_first_run", true); // Assume experienced
 | 
				
			|||||||
user_pref("dom.w3c_touch_events.enabled", true);
 | 
					user_pref("dom.w3c_touch_events.enabled", true);
 | 
				
			||||||
user_pref("extensions.checkCompatibility", false);
 | 
					user_pref("extensions.checkCompatibility", false);
 | 
				
			||||||
user_pref("extensions.installDistroAddons", false); // prevent testpilot etc
 | 
					user_pref("extensions.installDistroAddons", false); // prevent testpilot etc
 | 
				
			||||||
 | 
					user_pref("browser.safebrowsing.enable", false); // prevent traffic to google servers
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										22
									
								
								test/test.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								test/test.py
									
									
									
									
									
								
							@ -51,6 +51,7 @@ MIMEs = {
 | 
				
			|||||||
    '.json': 'application/json',
 | 
					    '.json': 'application/json',
 | 
				
			||||||
    '.pdf': 'application/pdf',
 | 
					    '.pdf': 'application/pdf',
 | 
				
			||||||
    '.xhtml': 'application/xhtml+xml',
 | 
					    '.xhtml': 'application/xhtml+xml',
 | 
				
			||||||
 | 
					    '.ico': 'image/x-icon'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class State:
 | 
					class State:
 | 
				
			||||||
@ -84,6 +85,14 @@ class PDFTestHandler(BaseHTTPRequestHandler):
 | 
				
			|||||||
        if VERBOSE:
 | 
					        if VERBOSE:
 | 
				
			||||||
            BaseHTTPRequestHandler.log_request(code, size)
 | 
					            BaseHTTPRequestHandler.log_request(code, size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def sendFile(self, path, ext):
 | 
				
			||||||
 | 
					        self.send_response(200)
 | 
				
			||||||
 | 
					        self.send_header("Content-Type", MIMEs[ext])
 | 
				
			||||||
 | 
					        self.send_header("Content-Length", os.path.getsize(path))
 | 
				
			||||||
 | 
					        self.end_headers()
 | 
				
			||||||
 | 
					        with open(path) as f:
 | 
				
			||||||
 | 
					            self.wfile.write(f.read())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_GET(self):
 | 
					    def do_GET(self):
 | 
				
			||||||
        url = urlparse(self.path)
 | 
					        url = urlparse(self.path)
 | 
				
			||||||
        # Ignore query string
 | 
					        # Ignore query string
 | 
				
			||||||
@ -92,9 +101,14 @@ class PDFTestHandler(BaseHTTPRequestHandler):
 | 
				
			|||||||
        prefix = os.path.commonprefix(( path, DOC_ROOT ))
 | 
					        prefix = os.path.commonprefix(( path, DOC_ROOT ))
 | 
				
			||||||
        _, ext = os.path.splitext(path)
 | 
					        _, ext = os.path.splitext(path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if url.path == "/favicon.ico":
 | 
				
			||||||
 | 
					            self.sendFile(os.path.join(DOC_ROOT, "test", "resources", "favicon.ico"), ext)
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if not (prefix == DOC_ROOT
 | 
					        if not (prefix == DOC_ROOT
 | 
				
			||||||
                and os.path.isfile(path) 
 | 
					                and os.path.isfile(path) 
 | 
				
			||||||
                and ext in MIMEs):
 | 
					                and ext in MIMEs):
 | 
				
			||||||
 | 
					            print path
 | 
				
			||||||
            self.send_error(404)
 | 
					            self.send_error(404)
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -103,14 +117,8 @@ class PDFTestHandler(BaseHTTPRequestHandler):
 | 
				
			|||||||
            self.send_error(501)
 | 
					            self.send_error(501)
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.send_response(200)
 | 
					        self.sendFile(path, ext)
 | 
				
			||||||
        self.send_header("Content-Type", MIMEs[ext])
 | 
					 | 
				
			||||||
        self.end_headers()
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        # Sigh, os.sendfile() plz
 | 
					 | 
				
			||||||
        f = open(path)
 | 
					 | 
				
			||||||
        self.wfile.write(f.read())
 | 
					 | 
				
			||||||
        f.close()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_POST(self):
 | 
					    def do_POST(self):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user