From 1f60168d52acbb86edd76517071c6359e377de74 Mon Sep 17 00:00:00 2001 From: Bob Moss Date: Thu, 30 Sep 2010 16:47:54 -0700 Subject: [PATCH 1/4] Bug 600266 Change AGENT-ERROR to AGENT-WARNING, add reboot notice and clok command to sutagent r=ctalbert a=NPOTB --- build/mobile/sutagent/android/ASMozStub.java | 8 ++ .../sutagent/android/AndroidManifest.xml | 8 +- .../sutagent/android/DataWorkerThread.java | 19 +++- build/mobile/sutagent/android/DoCommand.java | 102 +++++++++++++++++- .../sutagent/android/RunDataThread.java | 13 +++ .../sutagent/android/SUTAgentAndroid.java | 5 +- 6 files changed, 148 insertions(+), 7 deletions(-) diff --git a/build/mobile/sutagent/android/ASMozStub.java b/build/mobile/sutagent/android/ASMozStub.java index 5372881f373..ed522f833c9 100755 --- a/build/mobile/sutagent/android/ASMozStub.java +++ b/build/mobile/sutagent/android/ASMozStub.java @@ -111,4 +111,12 @@ public class ASMozStub extends android.app.Service { System.exit(0); } + + public void SendToDataChannel(String strToSend) + { + if (runDataThrd.isAlive()) + { + runDataThrd.SendToDataChannel(strToSend); + } + } } diff --git a/build/mobile/sutagent/android/AndroidManifest.xml b/build/mobile/sutagent/android/AndroidManifest.xml index 1f2c9e969a0..ddc5dbf5a25 100644 --- a/build/mobile/sutagent/android/AndroidManifest.xml +++ b/build/mobile/sutagent/android/AndroidManifest.xml @@ -5,6 +5,7 @@ android:versionName="1.0" android:sharedUserId="org.mozilla.sharedID"> @@ -25,7 +26,7 @@ - + @@ -59,4 +60,9 @@ + + + + + \ No newline at end of file diff --git a/build/mobile/sutagent/android/DataWorkerThread.java b/build/mobile/sutagent/android/DataWorkerThread.java index cd802a6e2b1..8dea41998b4 100755 --- a/build/mobile/sutagent/android/DataWorkerThread.java +++ b/build/mobile/sutagent/android/DataWorkerThread.java @@ -55,18 +55,34 @@ public class DataWorkerThread extends Thread private RunDataThread theParent = null; private Socket socket = null; boolean bListening = true; + PrintWriter out = null; + SimpleDateFormat sdf = null; public DataWorkerThread(RunDataThread theParent, Socket workerSocket) { super("DataWorkerThread"); this.theParent = theParent; this.socket = workerSocket; + this.sdf = new SimpleDateFormat("yyyyMMdd-HH:mm:ss"); } public void StopListening() { bListening = false; } + + public void SendString(String strToSend) + { + if (this.out != null) + { + Calendar cal = Calendar.getInstance(); + String strOut = sdf.format(cal.getTime()); + strOut += " " + strToSend + "\r\n"; + + out.write(strOut); + out.flush(); + } + } private String readLine(BufferedInputStream in) { @@ -135,13 +151,12 @@ public class DataWorkerThread extends Thread { OutputStream cmdOut = socket.getOutputStream(); InputStream cmdIn = socket.getInputStream(); - PrintWriter out = new PrintWriter(cmdOut, true); + this.out = new PrintWriter(cmdOut, true); BufferedInputStream in = new BufferedInputStream(cmdIn); String inputLine, outputLine; DoCommand dc = new DoCommand(theParent.svc); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH:mm:ss"); sRet = sdf.format(cal.getTime()); sRet += " trace output"; diff --git a/build/mobile/sutagent/android/DoCommand.java b/build/mobile/sutagent/android/DoCommand.java index fe7ae82d721..4618c0ab3ef 100755 --- a/build/mobile/sutagent/android/DoCommand.java +++ b/build/mobile/sutagent/android/DoCommand.java @@ -60,7 +60,9 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.List; +import java.util.TimeZone; import java.util.Timer; import java.util.zip.Adler32; import java.util.zip.CheckedInputStream; @@ -95,6 +97,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; import android.os.Build; +import android.os.Debug; import android.os.Environment; import android.os.StatFs; import android.os.SystemClock; @@ -113,9 +116,9 @@ public class DoCommand { ContextWrapper contextWrapper = null; String currentDir = "/"; - String sErrorPrefix = "##AGENT-ERROR## "; + String sErrorPrefix = "##AGENT-WARNING## "; - private final String prgVersion = "SUTAgentAndroid Version 0.80"; + private final String prgVersion = "SUTAgentAndroid Version 0.85"; public enum Command { @@ -128,6 +131,7 @@ public class DoCommand { OS ("os"), ID ("id"), UPTIME ("uptime"), + SETTIME ("settime"), SYSTIME ("systime"), SCREEN ("screen"), MEMORY ("memory"), @@ -215,10 +219,18 @@ public class DoCommand { strReturn = prgVersion; break; + case CLOK: + strReturn = GetClok(); + break; + case UPDT: strReturn = StartUpdateOMatic(Argv[1], Argv[2]); break; + case SETTIME: + strReturn = SetSystemTime(Argv[1], Argv[2], cmdOut); + break; + case CWD: try { strReturn = new java.io.File(currentDir).getCanonicalPath(); @@ -244,7 +256,7 @@ public class DoCommand { if (Argc == 2) strReturn = GetAppRoot(Argv[1]); else - strReturn = sErrorPrefix + "Wrong number of arguments for cd command!"; + strReturn = sErrorPrefix + "Wrong number of arguments for getapproot command!"; break; case TESTROOT: @@ -1929,6 +1941,84 @@ public class DoCommand { return (sRet); } + public String SetSystemTime(String sDate, String sTime, OutputStream out) + { +// Debug.waitForDebugger(); + String sRet = ""; + +// Intent prgIntent = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS); +// prgIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); +// contextWrapper.startActivity(prgIntent); + + // 2010/09/22 + // 15:41:00 + // 0123456789012345678 + + if (((sDate != null) && (sTime != null)) && + (sDate.contains("/") || sDate.contains(".")) && + (sTime.contains(":"))) + { + int year = Integer.parseInt(sDate.substring(0,4)); + int month = Integer.parseInt(sDate.substring(5,7)); + int day = Integer.parseInt(sDate.substring(8,10)); + + int hour = Integer.parseInt(sTime.substring(0,2)); + int mins = Integer.parseInt(sTime.substring(3,5)); + int secs = Integer.parseInt(sTime.substring(6,8)); + + Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); + cal.set(year, month - 1, day, hour, mins, secs); + long lMillisecs = cal.getTime().getTime(); + +// boolean bRet = SystemClock.setCurrentTimeMillis(lMillisecs); + String sM = Long.toString(lMillisecs); +// long lm = 1285175618316L; + String sTest = cal.getTime().toGMTString(); + String sMillis = sM.substring(0, sM.length() - 3) + "." + sM.substring(sM.length() - 3); + String [] theArgs = new String [3]; + + theArgs[0] = "su"; + theArgs[1] = "-c"; + theArgs[2] = "date -u " + sMillis; + + try + { + pProc = Runtime.getRuntime().exec(theArgs); + RedirOutputThread outThrd = new RedirOutputThread(pProc, null); + outThrd.start(); + outThrd.join(10000); + sRet = GetSystemTime(); + } + catch (IOException e) + { + sRet = e.getMessage(); + e.printStackTrace(); + } + catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + else + { + sRet = "Invalid argument(s)"; + } + + return (sRet); + } + + public String GetClok() + { + long lMillisecs = System.currentTimeMillis(); + String sRet = ""; + + if (lMillisecs > 0) + sRet = Long.toString(lMillisecs); + + return(sRet); + } + public String GetUptime() { String sRet = ""; @@ -2140,6 +2230,9 @@ public class DoCommand { try { + // Tell all of the data channels we are rebooting + ((ASMozStub)this.contextWrapper).SendToDataChannel("Rebooting ..."); + pProc = Runtime.getRuntime().exec(theArgs); RedirOutputThread outThrd = new RedirOutputThread(pProc, out); outThrd.start(); @@ -2551,6 +2644,9 @@ public class DoCommand { "rebt - reboot device\n" + "inst /path/filename.apk - install the referenced apk file\n" + "uninst packagename - uninstall the referenced package\n" + + "updt pkgname pkgfile - unpdate the referenced package\n" + + "clok - the current device time expressed as the number of millisecs since epoch\n" + + "settime date time - sets the device date and time (YYYY/MM/DD HH:MM:SS)\n" + "rebt - reboot device\n" + "quit - disconnect SUTAgent\n" + "exit - close SUTAgent\n" + diff --git a/build/mobile/sutagent/android/RunDataThread.java b/build/mobile/sutagent/android/RunDataThread.java index e30ad0031bd..dd363a071a7 100755 --- a/build/mobile/sutagent/android/RunDataThread.java +++ b/build/mobile/sutagent/android/RunDataThread.java @@ -66,6 +66,19 @@ public class RunDataThread extends Thread { bListening = false; } + + public void SendToDataChannel(String strToSend) + { + int nNumWorkers = theWorkers.size(); + for (int lcv = 0; lcv < nNumWorkers; lcv++) + { + if (theWorkers.get(lcv).isAlive()) + { + theWorkers.get(lcv).SendString(strToSend); + } + } + return; + } public void run() { try { diff --git a/build/mobile/sutagent/android/SUTAgentAndroid.java b/build/mobile/sutagent/android/SUTAgentAndroid.java index df3bfc99eaa..dcd27dc396e 100755 --- a/build/mobile/sutagent/android/SUTAgentAndroid.java +++ b/build/mobile/sutagent/android/SUTAgentAndroid.java @@ -65,6 +65,7 @@ import android.net.wifi.WifiManager; import android.net.wifi.WifiManager.WifiLock; import android.os.BatteryManager; import android.os.Bundle; +import android.os.Debug; import android.os.PowerManager; import android.telephony.TelephonyManager; import android.util.Log; @@ -133,7 +134,9 @@ public class SUTAgentAndroid extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.main); - + +// Debug.waitForDebugger(); + // long lHeapSize = VMRuntime.getRuntime().getMinimumHeapSize(); // lHeapSize = 16000000; // VMRuntime.getRuntime().setMinimumHeapSize(lHeapSize); From 8543ff90e49f55e51da88f47257f8a62d495de49 Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Thu, 30 Sep 2010 16:49:24 -0700 Subject: [PATCH 2/4] Bug 543800 Package chrome style tests into .jar file for Android testing r=ctalbert a=NPOTB --- .../tests/mochitest/events/test_scroll.xul | 4 +-- accessible/tests/mochitest/test_value.html | 2 +- .../content/test/browser_tab_dragdrop2.js | 4 +-- .../tests/browser_privacypane_1.js | 4 +-- .../tests/browser_privacypane_2.js | 4 +-- .../tests/browser_privacypane_3.js | 4 +-- .../tests/browser_privacypane_4.js | 4 +-- .../tests/browser_privacypane_5.js | 4 +-- .../tests/browser_privacypane_6.js | 4 +-- .../tests/browser_privacypane_7.js | 4 +-- .../tests/browser_privacypane_8.js | 4 +-- .../whatwg/postMessage_chrome_helper.html | 35 +++++++++++-------- .../whatwg/test_postMessage_chrome.html | 11 +++++- layout/generic/test/file_bug514732_window.xul | 2 +- layout/generic/test/test_bug514732-2.xul | 3 +- modules/libpr0n/test/browser/head.js | 4 ++- testing/mochitest/chrome-harness.js | 8 ++++- .../tests/chrome/rtlchrome/rtl.manifest | 7 +--- .../test/browser/browser_aboutCrashes.js | 2 +- .../browser/browser_aboutCrashesResubmit.js | 2 +- .../test/browser/browser_bug471404.js | 2 +- xpinstall/tests/browser_auth.js | 4 ++- xpinstall/tests/browser_auth2.js | 4 ++- xpinstall/tests/browser_auth3.js | 4 ++- xpinstall/tests/browser_badhash.js | 4 ++- xpinstall/tests/browser_badhashtype.js | 4 ++- xpinstall/tests/browser_bug540558.js | 4 ++- xpinstall/tests/browser_cancel.js | 4 ++- xpinstall/tests/browser_chrome.js | 4 ++- xpinstall/tests/browser_cookies.js | 5 ++- xpinstall/tests/browser_cookies2.js | 5 ++- xpinstall/tests/browser_cookies3.js | 4 ++- xpinstall/tests/browser_cookies4.js | 4 ++- xpinstall/tests/browser_corrupt.js | 4 ++- xpinstall/tests/browser_empty.js | 4 ++- xpinstall/tests/browser_enabled.js | 4 ++- xpinstall/tests/browser_enabled2.js | 4 ++- xpinstall/tests/browser_enabled3.js | 4 ++- xpinstall/tests/browser_hash.js | 4 ++- xpinstall/tests/browser_installchrome.js | 4 ++- xpinstall/tests/browser_localfile.js | 4 ++- xpinstall/tests/browser_localfile2.js | 4 ++- xpinstall/tests/browser_navigateaway.js | 4 ++- xpinstall/tests/browser_navigateaway2.js | 4 ++- xpinstall/tests/browser_offline.js | 4 ++- xpinstall/tests/browser_opendialog.js | 4 ++- xpinstall/tests/browser_signed_multiple.js | 4 ++- xpinstall/tests/browser_signed_naming.js | 4 ++- xpinstall/tests/browser_signed_tampered.js | 4 ++- xpinstall/tests/browser_signed_trigger.js | 4 ++- xpinstall/tests/browser_signed_untrusted.js | 4 ++- xpinstall/tests/browser_signed_url.js | 4 ++- xpinstall/tests/browser_softwareupdate.js | 4 ++- xpinstall/tests/browser_unsigned_trigger.js | 4 ++- xpinstall/tests/browser_unsigned_url.js | 4 ++- xpinstall/tests/browser_whitelist.js | 4 ++- xpinstall/tests/browser_whitelist2.js | 4 ++- xpinstall/tests/browser_whitelist3.js | 4 ++- xpinstall/tests/browser_whitelist4.js | 4 ++- xpinstall/tests/browser_whitelist5.js | 4 ++- xpinstall/tests/browser_whitelist6.js | 4 ++- xpinstall/tests/harness.js | 12 ++++++- 62 files changed, 201 insertions(+), 91 deletions(-) diff --git a/accessible/tests/mochitest/events/test_scroll.xul b/accessible/tests/mochitest/events/test_scroll.xul index 32e3c907df0..2fec8a662fd 100644 --- a/accessible/tests/mochitest/events/test_scroll.xul +++ b/accessible/tests/mochitest/events/test_scroll.xul @@ -73,10 +73,10 @@ var jar = getJar(rootDir); if (jar) { var tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - var url = rootDir + "/scroll.html#link1"; + var url = rootDir + "scroll.html#link1"; var tabBrowser = document.getElementById("tabBrowser"); tabBrowser.loadURI(url); } diff --git a/accessible/tests/mochitest/test_value.html b/accessible/tests/mochitest/test_value.html index b648b1f6a4a..8edb2357251 100644 --- a/accessible/tests/mochitest/test_value.html +++ b/accessible/tests/mochitest/test_value.html @@ -39,7 +39,7 @@ } var rootDir = getRootDirectory(window.location.href); - var href = rootDir.path + "/foo"; + var href = rootDir.path + "foo"; // roles that can't live as nsHTMLLinkAccessibles testValue("aria_menuitem_link", ""); diff --git a/browser/base/content/test/browser_tab_dragdrop2.js b/browser/base/content/test/browser_tab_dragdrop2.js index 461a9ede0f2..21ed9deaa33 100644 --- a/browser/base/content/test/browser_tab_dragdrop2.js +++ b/browser/base/content/test/browser_tab_dragdrop2.js @@ -11,8 +11,8 @@ function test() // Now run the tests again and then close C. // The test results does not matter, all this is just to exercise some code to // catch assertions or crashes. - var uri = "chrome://mochikit/content/browser/" + - "browser/base/content/test/browser_tab_dragdrop2_frame1.xul"; + var chromeroot = getRootDirectory(gTestPath); + var uri = chromeroot + "browser_tab_dragdrop2_frame1.xul"; let window_B = openDialog(location, "_blank", "chrome,all,dialog=no,left=200,top=200,width=200,height=200", uri); window_B.addEventListener("load", function(aEvent) { window_B.removeEventListener("load", arguments.callee, false); diff --git a/browser/components/preferences/tests/browser_privacypane_1.js b/browser/components/preferences/tests/browser_privacypane_1.js index a0cc92b5cf9..0891b8b7e6a 100644 --- a/browser/components/preferences/tests/browser_privacypane_1.js +++ b/browser/components/preferences/tests/browser_privacypane_1.js @@ -43,9 +43,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ test_pane_visibility, diff --git a/browser/components/preferences/tests/browser_privacypane_2.js b/browser/components/preferences/tests/browser_privacypane_2.js index f9ac590b9af..47c6308d372 100644 --- a/browser/components/preferences/tests/browser_privacypane_2.js +++ b/browser/components/preferences/tests/browser_privacypane_2.js @@ -43,9 +43,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ test_historymode_retention("remember", undefined), diff --git a/browser/components/preferences/tests/browser_privacypane_3.js b/browser/components/preferences/tests/browser_privacypane_3.js index 215f34758c9..bead9e907cb 100644 --- a/browser/components/preferences/tests/browser_privacypane_3.js +++ b/browser/components/preferences/tests/browser_privacypane_3.js @@ -42,9 +42,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ test_custom_retention("rememberHistory", "remember"), diff --git a/browser/components/preferences/tests/browser_privacypane_4.js b/browser/components/preferences/tests/browser_privacypane_4.js index 2fb0bccff64..df46008426e 100644 --- a/browser/components/preferences/tests/browser_privacypane_4.js +++ b/browser/components/preferences/tests/browser_privacypane_4.js @@ -42,9 +42,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ test_custom_retention("acceptCookies", "remember"), diff --git a/browser/components/preferences/tests/browser_privacypane_5.js b/browser/components/preferences/tests/browser_privacypane_5.js index 2a99069e3a9..2962c5cb465 100644 --- a/browser/components/preferences/tests/browser_privacypane_5.js +++ b/browser/components/preferences/tests/browser_privacypane_5.js @@ -42,9 +42,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ test_locbar_suggestion_retention(-1, undefined), diff --git a/browser/components/preferences/tests/browser_privacypane_6.js b/browser/components/preferences/tests/browser_privacypane_6.js index e2f03eca14c..7196550c158 100644 --- a/browser/components/preferences/tests/browser_privacypane_6.js +++ b/browser/components/preferences/tests/browser_privacypane_6.js @@ -42,9 +42,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ test_privatebrowsing_toggle, diff --git a/browser/components/preferences/tests/browser_privacypane_7.js b/browser/components/preferences/tests/browser_privacypane_7.js index 6da4c02b5f5..3fa4e4877a5 100644 --- a/browser/components/preferences/tests/browser_privacypane_7.js +++ b/browser/components/preferences/tests/browser_privacypane_7.js @@ -42,9 +42,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ test_privatebrowsing_ui, diff --git a/browser/components/preferences/tests/browser_privacypane_8.js b/browser/components/preferences/tests/browser_privacypane_8.js index 40adbeedb15..3b8249ccdcb 100644 --- a/browser/components/preferences/tests/browser_privacypane_8.js +++ b/browser/components/preferences/tests/browser_privacypane_8.js @@ -41,9 +41,9 @@ function test() { let jar = getJar(rootDir); if (jar) { let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path; + rootDir = "file://" + tmpdir.path + '/'; } - loader.loadSubScript(rootDir + "/privacypane_tests.js", this); + loader.loadSubScript(rootDir + "privacypane_tests.js", this); run_test_subset([ // history mode should be initialized to remember diff --git a/dom/tests/mochitest/whatwg/postMessage_chrome_helper.html b/dom/tests/mochitest/whatwg/postMessage_chrome_helper.html index a6232c7cee7..daf6e32f962 100644 --- a/dom/tests/mochitest/whatwg/postMessage_chrome_helper.html +++ b/dom/tests/mochitest/whatwg/postMessage_chrome_helper.html @@ -3,25 +3,32 @@ postMessage chrome message receiver diff --git a/modules/libpr0n/test/browser/head.js b/modules/libpr0n/test/browser/head.js index ac4d525c4c3..528495f6e95 100644 --- a/modules/libpr0n/test/browser/head.js +++ b/modules/libpr0n/test/browser/head.js @@ -5,7 +5,9 @@ const Cu = Components.utils; const RELATIVE_DIR = "modules/libpr0n/test/browser/"; const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR; const TESTROOT2 = "http://example.org/browser/" + RELATIVE_DIR; -const CHROMEROOT = "chrome://mochikit/content/browser/" + RELATIVE_DIR; + +var chrome_root = getRootDirectory(gTestPath); +const CHROMEROOT = chrome_root; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); diff --git a/testing/mochitest/chrome-harness.js b/testing/mochitest/chrome-harness.js index 8beee7f5c36..e01a81008dc 100644 --- a/testing/mochitest/chrome-harness.js +++ b/testing/mochitest/chrome-harness.js @@ -234,8 +234,14 @@ function getRootDirectory(path, chromeURI) { chromeURI = getChromeURI(path); } var myURL = chromeURI.QueryInterface(Components.interfaces.nsIURL); + var mydir = myURL.directory; - return chromeURI.prePath + myURL.directory; + if (mydir.match('/$') != '/') + { + mydir += '/'; + } + + return chromeURI.prePath + mydir; } //used by tests to determine their directory based off window.location.path diff --git a/toolkit/content/tests/chrome/rtlchrome/rtl.manifest b/toolkit/content/tests/chrome/rtlchrome/rtl.manifest index df898d0f58f..a4cc6929be4 100644 --- a/toolkit/content/tests/chrome/rtlchrome/rtl.manifest +++ b/toolkit/content/tests/chrome/rtlchrome/rtl.manifest @@ -1,10 +1,5 @@ -content rtlchrome /content +content rtlchrome / # Override intl.css with our own CSS file override chrome://global/locale/intl.css chrome://rtlchrome/rtl.css override chrome://global/locale/global.dtd chrome://rtlchrome/rtl.dtd - - -# Override intl.css with our own CSS file -override chrome://global/locale/intl.css chrome://mochikit/content/chrome/toolkit/content/tests/chrome/rtlchrome/rtl.css -override chrome://global/locale/global.dtd chrome://mochikit/content/chrome/toolkit/content/tests/chrome/rtlchrome/rtl.dtd diff --git a/toolkit/crashreporter/test/browser/browser_aboutCrashes.js b/toolkit/crashreporter/test/browser/browser_aboutCrashes.js index 267ff933430..984e5759fda 100644 --- a/toolkit/crashreporter/test/browser/browser_aboutCrashes.js +++ b/toolkit/crashreporter/test/browser/browser_aboutCrashes.js @@ -3,7 +3,7 @@ var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); var rootDir = getRootDirectory(gTestPath); -scriptLoader.loadSubScript(rootDir + "/aboutcrashes_utils.js", this); +scriptLoader.loadSubScript(rootDir + "aboutcrashes_utils.js", this); function check_crash_list(tab, crashes) { let doc = gBrowser.getBrowserForTab(tab).contentDocument; diff --git a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js index c57f4ac43ab..cc64564e8c2 100644 --- a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js +++ b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js @@ -3,7 +3,7 @@ var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); var rootDir = getRootDirectory(gTestPath); -scriptLoader.loadSubScript(rootDir + "/aboutcrashes_utils.js", this); +scriptLoader.loadSubScript(rootDir + "aboutcrashes_utils.js", this); function cleanup_and_finish() { try { diff --git a/toolkit/crashreporter/test/browser/browser_bug471404.js b/toolkit/crashreporter/test/browser/browser_bug471404.js index d84285a67e0..d6dd370bd05 100644 --- a/toolkit/crashreporter/test/browser/browser_bug471404.js +++ b/toolkit/crashreporter/test/browser/browser_bug471404.js @@ -3,7 +3,7 @@ var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); var rootDir = getRootDirectory(gTestPath); -scriptLoader.loadSubScript(rootDir + "/aboutcrashes_utils.js", this); +scriptLoader.loadSubScript(rootDir + "aboutcrashes_utils.js", this); function check_clear_visible(tab, aVisible) { let doc = gBrowser.getBrowserForTab(tab).contentDocument; diff --git a/xpinstall/tests/browser_auth.js b/xpinstall/tests/browser_auth.js index 740e114bb8a..bf25cc32e08 100644 --- a/xpinstall/tests/browser_auth.js +++ b/xpinstall/tests/browser_auth.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install succeeds when authentication is required diff --git a/xpinstall/tests/browser_auth2.js b/xpinstall/tests/browser_auth2.js index 8872649149e..6a88e62cdc1 100644 --- a/xpinstall/tests/browser_auth2.js +++ b/xpinstall/tests/browser_auth2.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install fails when authentication is required and bad diff --git a/xpinstall/tests/browser_auth3.js b/xpinstall/tests/browser_auth3.js index 4cfe8252a69..02f1c9e3c95 100644 --- a/xpinstall/tests/browser_auth3.js +++ b/xpinstall/tests/browser_auth3.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install fails when authentication is required and it is diff --git a/xpinstall/tests/browser_badhash.js b/xpinstall/tests/browser_badhash.js index d1f3789f837..3ee779933b1 100644 --- a/xpinstall/tests/browser_badhash.js +++ b/xpinstall/tests/browser_badhash.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install fails when an invalid hash is included diff --git a/xpinstall/tests/browser_badhashtype.js b/xpinstall/tests/browser_badhashtype.js index b514d40a4de..418ec29c53a 100644 --- a/xpinstall/tests/browser_badhashtype.js +++ b/xpinstall/tests/browser_badhashtype.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install fails when an unknown hash type is included diff --git a/xpinstall/tests/browser_bug540558.js b/xpinstall/tests/browser_bug540558.js index c7f6594cb3a..0048457b0d6 100644 --- a/xpinstall/tests/browser_bug540558.js +++ b/xpinstall/tests/browser_bug540558.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that calling InstallTrigger.installChrome works diff --git a/xpinstall/tests/browser_cancel.js b/xpinstall/tests/browser_cancel.js index 1a6ef4a6025..54d63333223 100644 --- a/xpinstall/tests/browser_cancel.js +++ b/xpinstall/tests/browser_cancel.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that cancelling an in progress download works. diff --git a/xpinstall/tests/browser_chrome.js b/xpinstall/tests/browser_chrome.js index c23258c1f63..db463edfdac 100644 --- a/xpinstall/tests/browser_chrome.js +++ b/xpinstall/tests/browser_chrome.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that starting a download from chrome works and bypasses the whitelist diff --git a/xpinstall/tests/browser_cookies.js b/xpinstall/tests/browser_cookies.js index b45ba4202e1..5235fd05abf 100644 --- a/xpinstall/tests/browser_cookies.js +++ b/xpinstall/tests/browser_cookies.js @@ -1,7 +1,10 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test that an install that requires cookies to be sent fails when no cookies diff --git a/xpinstall/tests/browser_cookies2.js b/xpinstall/tests/browser_cookies2.js index bb1b8487dee..4e3b28490b2 100644 --- a/xpinstall/tests/browser_cookies2.js +++ b/xpinstall/tests/browser_cookies2.js @@ -1,7 +1,10 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test that an install that requires cookies to be sent succeeds when cookies diff --git a/xpinstall/tests/browser_cookies3.js b/xpinstall/tests/browser_cookies3.js index dbf6467fbe2..0b11729a4db 100644 --- a/xpinstall/tests/browser_cookies3.js +++ b/xpinstall/tests/browser_cookies3.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test that an install that requires cookies to be sent succeeds when cookies diff --git a/xpinstall/tests/browser_cookies4.js b/xpinstall/tests/browser_cookies4.js index 7412c88e1fa..c5dec917dda 100644 --- a/xpinstall/tests/browser_cookies4.js +++ b/xpinstall/tests/browser_cookies4.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test that an install that requires cookies to be sent fails when cookies diff --git a/xpinstall/tests/browser_corrupt.js b/xpinstall/tests/browser_corrupt.js index 5b1bb362395..5e344fa1d59 100644 --- a/xpinstall/tests/browser_corrupt.js +++ b/xpinstall/tests/browser_corrupt.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install fails when the xpi is corrupt. diff --git a/xpinstall/tests/browser_empty.js b/xpinstall/tests/browser_empty.js index 9ddd3aef928..02bde7a9d58 100644 --- a/xpinstall/tests/browser_empty.js +++ b/xpinstall/tests/browser_empty.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install fails when there is no install script present. diff --git a/xpinstall/tests/browser_enabled.js b/xpinstall/tests/browser_enabled.js index 98831487a4e..75866a84acc 100644 --- a/xpinstall/tests/browser_enabled.js +++ b/xpinstall/tests/browser_enabled.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an InstallTrigger.enabled is working diff --git a/xpinstall/tests/browser_enabled2.js b/xpinstall/tests/browser_enabled2.js index 11fb9d4a58f..81c5e1c13d1 100644 --- a/xpinstall/tests/browser_enabled2.js +++ b/xpinstall/tests/browser_enabled2.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an InstallTrigger.enabled is working diff --git a/xpinstall/tests/browser_enabled3.js b/xpinstall/tests/browser_enabled3.js index 7a0844049be..022acee9a8f 100644 --- a/xpinstall/tests/browser_enabled3.js +++ b/xpinstall/tests/browser_enabled3.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an InstallTrigger.install call fails when xpinstall is disabled diff --git a/xpinstall/tests/browser_hash.js b/xpinstall/tests/browser_hash.js index 05658b60787..cf7f662fbd3 100644 --- a/xpinstall/tests/browser_hash.js +++ b/xpinstall/tests/browser_hash.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install succeeds when a valid hash is included diff --git a/xpinstall/tests/browser_installchrome.js b/xpinstall/tests/browser_installchrome.js index 12d6f98e6a7..6d8d7b293e3 100644 --- a/xpinstall/tests/browser_installchrome.js +++ b/xpinstall/tests/browser_installchrome.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that calling InstallTrigger.installChrome works diff --git a/xpinstall/tests/browser_localfile.js b/xpinstall/tests/browser_localfile.js index d7910b0dd82..fdfa6ed40bf 100644 --- a/xpinstall/tests/browser_localfile.js +++ b/xpinstall/tests/browser_localfile.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an local file works when loading the url diff --git a/xpinstall/tests/browser_localfile2.js b/xpinstall/tests/browser_localfile2.js index 2c3fe584b63..91f5cb6b696 100644 --- a/xpinstall/tests/browser_localfile2.js +++ b/xpinstall/tests/browser_localfile2.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install fails if the url is a local file when requested from diff --git a/xpinstall/tests/browser_navigateaway.js b/xpinstall/tests/browser_navigateaway.js index d078e03c66e..59885cba829 100644 --- a/xpinstall/tests/browser_navigateaway.js +++ b/xpinstall/tests/browser_navigateaway.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that navigating away from the initiating page during the install diff --git a/xpinstall/tests/browser_navigateaway2.js b/xpinstall/tests/browser_navigateaway2.js index a7c3c67915d..bd1814c9f67 100644 --- a/xpinstall/tests/browser_navigateaway2.js +++ b/xpinstall/tests/browser_navigateaway2.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that closing the initiating page during the install doesn't break the diff --git a/xpinstall/tests/browser_offline.js b/xpinstall/tests/browser_offline.js index 845aaf64f19..b51a19865f1 100644 --- a/xpinstall/tests/browser_offline.js +++ b/xpinstall/tests/browser_offline.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that going offline cancels an in progress download. diff --git a/xpinstall/tests/browser_opendialog.js b/xpinstall/tests/browser_opendialog.js index 90c4d2e9ca9..6f2b515cb01 100644 --- a/xpinstall/tests/browser_opendialog.js +++ b/xpinstall/tests/browser_opendialog.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Test whether an install succeeds when the progress dialog is already open. diff --git a/xpinstall/tests/browser_signed_multiple.js b/xpinstall/tests/browser_signed_multiple.js index 155ed8a1ed3..2a0e6517723 100644 --- a/xpinstall/tests/browser_signed_multiple.js +++ b/xpinstall/tests/browser_signed_multiple.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing two signed add-ons in the same trigger works. diff --git a/xpinstall/tests/browser_signed_naming.js b/xpinstall/tests/browser_signed_naming.js index 8dccc724d6e..aa00c56f9f0 100644 --- a/xpinstall/tests/browser_signed_naming.js +++ b/xpinstall/tests/browser_signed_naming.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that the correct signer is presented for combinations of O and CN present. diff --git a/xpinstall/tests/browser_signed_tampered.js b/xpinstall/tests/browser_signed_tampered.js index ff9bece2eb1..9a852180dfa 100644 --- a/xpinstall/tests/browser_signed_tampered.js +++ b/xpinstall/tests/browser_signed_tampered.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing a signed add-on that has been tampered with after signing. diff --git a/xpinstall/tests/browser_signed_trigger.js b/xpinstall/tests/browser_signed_trigger.js index af2abd89fa8..150a7808e75 100644 --- a/xpinstall/tests/browser_signed_trigger.js +++ b/xpinstall/tests/browser_signed_trigger.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an signed add-on through an InstallTrigger call in web diff --git a/xpinstall/tests/browser_signed_untrusted.js b/xpinstall/tests/browser_signed_untrusted.js index dee923fe88c..c0bdbfef355 100644 --- a/xpinstall/tests/browser_signed_untrusted.js +++ b/xpinstall/tests/browser_signed_untrusted.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an add-on signed by an untrusted certificate through an diff --git a/xpinstall/tests/browser_signed_url.js b/xpinstall/tests/browser_signed_url.js index 4359f4001ae..231d098860e 100644 --- a/xpinstall/tests/browser_signed_url.js +++ b/xpinstall/tests/browser_signed_url.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an signed add-on by navigating directly to the url diff --git a/xpinstall/tests/browser_softwareupdate.js b/xpinstall/tests/browser_softwareupdate.js index abe7d9a7941..041b6f40d03 100644 --- a/xpinstall/tests/browser_softwareupdate.js +++ b/xpinstall/tests/browser_softwareupdate.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests that calling InstallTrigger.startSoftwareUpdate works diff --git a/xpinstall/tests/browser_unsigned_trigger.js b/xpinstall/tests/browser_unsigned_trigger.js index e6aa17e03e7..b0086f52fbd 100644 --- a/xpinstall/tests/browser_unsigned_trigger.js +++ b/xpinstall/tests/browser_unsigned_trigger.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on through an InstallTrigger call in web diff --git a/xpinstall/tests/browser_unsigned_url.js b/xpinstall/tests/browser_unsigned_url.js index ff38bc48a70..a71b8cb2b8b 100644 --- a/xpinstall/tests/browser_unsigned_url.js +++ b/xpinstall/tests/browser_unsigned_url.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on by navigating directly to the url diff --git a/xpinstall/tests/browser_whitelist.js b/xpinstall/tests/browser_whitelist.js index 7d2d3d99ccb..0467bc067af 100644 --- a/xpinstall/tests/browser_whitelist.js +++ b/xpinstall/tests/browser_whitelist.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on through an InstallTrigger call in web diff --git a/xpinstall/tests/browser_whitelist2.js b/xpinstall/tests/browser_whitelist2.js index a36f8160270..170ede59ba9 100644 --- a/xpinstall/tests/browser_whitelist2.js +++ b/xpinstall/tests/browser_whitelist2.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on through an InstallTrigger call in web diff --git a/xpinstall/tests/browser_whitelist3.js b/xpinstall/tests/browser_whitelist3.js index 201a980832a..fef29d90dbb 100644 --- a/xpinstall/tests/browser_whitelist3.js +++ b/xpinstall/tests/browser_whitelist3.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on through a navigation. Should not be diff --git a/xpinstall/tests/browser_whitelist4.js b/xpinstall/tests/browser_whitelist4.js index 97e2d7b8113..08ee9e7e200 100644 --- a/xpinstall/tests/browser_whitelist4.js +++ b/xpinstall/tests/browser_whitelist4.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on through a navigation. Should be diff --git a/xpinstall/tests/browser_whitelist5.js b/xpinstall/tests/browser_whitelist5.js index 17f48fb1bf8..e9fb58234cf 100644 --- a/xpinstall/tests/browser_whitelist5.js +++ b/xpinstall/tests/browser_whitelist5.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on through a startSoftwareUpdate call in web diff --git a/xpinstall/tests/browser_whitelist6.js b/xpinstall/tests/browser_whitelist6.js index e457c68e02c..1b5592ddbaf 100644 --- a/xpinstall/tests/browser_whitelist6.js +++ b/xpinstall/tests/browser_whitelist6.js @@ -1,7 +1,9 @@ // Load in the test harness var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader); -scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +var rootDir = getRootDirectory(window.location.href); +scriptLoader.loadSubScript(rootDir + "harness.js", this); // ---------------------------------------------------------------------------- // Tests installing an unsigned add-on through an installChrome call in web diff --git a/xpinstall/tests/harness.js b/xpinstall/tests/harness.js index f154ed139be..f958afccca8 100644 --- a/xpinstall/tests/harness.js +++ b/xpinstall/tests/harness.js @@ -1,10 +1,20 @@ const TESTROOT = "http://example.com/browser/xpinstall/tests/"; const TESTROOT2 = "http://example.org/browser/xpinstall/tests/"; -const CHROMEROOT = "chrome://mochikit/content/browser/xpinstall/tests/" const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul"; const PROMPT_URL = "chrome://global/content/commonDialog.xul"; const ADDONS_URL = "chrome://mozapps/content/extensions/extensions.xul"; +var rootDir = getRootDirectory(gTestPath); +var path = rootDir.split('/'); +var chromeName = path[0] + '//' + path[2]; +var croot = chromeName + "/content/browser/xpinstall/tests/"; +var jar = getJar(croot); +if (jar) { + var tmpdir = extractJarToTmp(jar); + croot = 'file://' + tmpdir.path + '/'; +} +const CHROMEROOT = croot; + /** * This is a test harness designed to handle responding to UI during the process * of installing an XPI. A test can set callbacks to hear about specific parts From db0824c44e71aa303dac10ab12bbc81abd16c16f Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Thu, 30 Sep 2010 16:50:24 -0700 Subject: [PATCH 3/4] Bug 543800 Package chrome style tests into .jar file for Android testing r=ted a=NPOTB --- Makefile.in | 3 - build/macosx/universal/flight.mk | 4 +- testing/mochitest/Makefile.in | 35 ++++++ testing/mochitest/browser-harness.xul | 20 +++- testing/mochitest/chrome-harness.js | 17 +-- testing/mochitest/harness-overlay.xul | 113 ++++++++---------- testing/mochitest/install.rdf | 23 ++++ testing/mochitest/jar.mn | 39 ++++++ testing/mochitest/runtests.py.in | 58 ++++++--- .../mochitest/tests/SimpleTest/Makefile.in | 1 + testing/testsuite-targets.mk | 7 +- 11 files changed, 226 insertions(+), 94 deletions(-) create mode 100644 testing/mochitest/install.rdf create mode 100644 testing/mochitest/jar.mn diff --git a/Makefile.in b/Makefile.in index 56714333347..e38377c6951 100644 --- a/Makefile.in +++ b/Makefile.in @@ -120,9 +120,6 @@ export:: ifdef ENABLE_TESTS # Additional makefile targets to call automated test suites include $(topsrcdir)/testing/testsuite-targets.mk -else -# OS X Universal builds will want to call this, so stub it out -package-tests: endif include $(topsrcdir)/config/rules.mk diff --git a/build/macosx/universal/flight.mk b/build/macosx/universal/flight.mk index 3b761921897..4016eac86b7 100644 --- a/build/macosx/universal/flight.mk +++ b/build/macosx/universal/flight.mk @@ -121,8 +121,8 @@ postflight_all: # A universal .dmg can now be produced by making in either architecture's # INSTALLER_DIR. # Now, repeat the process for the test package. - $(MAKE) -C $(OBJDIR_ARCH_1) UNIVERSAL_BINARY= package-tests - $(MAKE) -C $(OBJDIR_ARCH_2) UNIVERSAL_BINARY= package-tests + $(MAKE) -C $(OBJDIR_ARCH_1) UNIVERSAL_BINARY= CHROME_JAR= package-tests + $(MAKE) -C $(OBJDIR_ARCH_2) UNIVERSAL_BINARY= CHROME_JAR= package-tests rm -rf $(DIST_UNI)/test-package-stage # automation.py differs because it hardcodes a path to # dist/bin. It doesn't matter which one we use. diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in index 9505566ab54..8e3ce072166 100644 --- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -51,6 +51,19 @@ DIRS = MochiKit \ ssltunnel \ $(NULL) + +NO_JS_MANIFEST = 1 +MOZ_CHROME_FILE_FORMAT = jar +DIST_FILES = install.rdf + +# Used in install.rdf +USE_EXTENSION_MANIFEST = 1 + +XPI_NAME = mochijar + +# we turn this off for UNIVERSAL_BINARY +CHROME_JAR = 1 + include $(topsrcdir)/config/rules.mk # We're installing to _tests/testing/mochitest, so this is the depth # necessary for relative objdir paths. @@ -108,6 +121,9 @@ _HANDSHAKE_FILES = \ _DEST_DIR = $(DEPTH)/_tests/$(relativesrcdir) +libs:: + (cd $(DIST)/xpi-stage && tar $(TAR_CREATE_FLAGS) - mochijar) | (cd $(_DEST_DIR) && tar -xf -) + libs:: $(_PYWEBSOCKET_FILES) $(INSTALL) $(foreach f,$^,"$f") $(_DEST_DIR)/pywebsocket @@ -175,6 +191,25 @@ endif PKG_STAGE = $(DIST)/test-package-stage DIST_BIN = $(DIST)/bin +PKG_CHROMEJAR = $(PKG_STAGE)/mochitest/content/ + +ifdef CHROME_JAR +stage-chromejar: + $(NSINSTALL) -D $(PKG_CHROMEJAR) + cp -RL $(DEPTH)/_tests/testing/mochitest/browser $(PKG_CHROMEJAR) + cp -RL $(DEPTH)/_tests/testing/mochitest/chrome $(PKG_CHROMEJAR) +ifdef ACCESSIBILITY + cp -RL $(DEPTH)/_tests/testing/mochitest/a11y $(PKG_CHROMEJAR) +endif + @(cd $(PKG_STAGE)/mochitest && zip -r tests.jar content/) + @(rm -rf $(PKG_CHROMEJAR)) + +stage-package: stage-chromejar +endif + +$(_DEST_DIR): + $(NSINSTALL) -D $@ + stage-package: $(NSINSTALL) -D $(PKG_STAGE)/mochitest && $(NSINSTALL) -D $(PKG_STAGE)/bin/plugins @(cd $(DEPTH)/_tests/testing/mochitest/ && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mochitest && tar -xf -) diff --git a/testing/mochitest/browser-harness.xul b/testing/mochitest/browser-harness.xul index ced53fd9771..fe4369a117b 100644 --- a/testing/mochitest/browser-harness.xul +++ b/testing/mochitest/browser-harness.xul @@ -208,15 +208,31 @@ // Returns an array of browserTest objects for all the selected tests function listTests() { + var baseURL = 'chrome://mochitests/content'; + var testsURI = Components.classes["@mozilla.org/file/directory_service;1"] + .getService(Components.interfaces.nsIProperties) + .get("ProfD", Components.interfaces.nsILocalFile); + testsURI.append("tests.manifest"); + var ioSvc = Components.classes["@mozilla.org/network/io-service;1"]. + getService(Components.interfaces.nsIIOService); + var manifestFile = ioSvc.newFileURI(testsURI) + .QueryInterface(Components.interfaces.nsIFileURL).file; + + Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar). + autoRegister(manifestFile); // load server.js in so we can share template functions var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. getService(Ci.mozIJSSubScriptLoader); var srvScope = {}; - var baseURL = 'chrome://mochikit/content'; scriptLoader.loadSubScript('chrome://mochikit/content/server.js', srvScope); - var [links, singleTestPath] = getFileListing(baseURL, gConfig.testPath, "browser", srvScope); + var jar = getJar(baseURL); + if (jar != null) { + var [links, singleTestPath] = getMochitestJarListing(baseURL, gConfig.testPath, "browser"); + } else { + var [links, singleTestPath] = getFileListing(baseURL, gConfig.testPath, "browser", srvScope); + } var fileNames = []; var fileNameRegexp = /browser_.+\.js$/; diff --git a/testing/mochitest/chrome-harness.js b/testing/mochitest/chrome-harness.js index e01a81008dc..70e820e9fbd 100644 --- a/testing/mochitest/chrome-harness.js +++ b/testing/mochitest/chrome-harness.js @@ -108,6 +108,9 @@ function getMochitestJarListing(basePath, testPath, dir) var fileName = fileHandler.getFileFromURLSpec(getResolvedURI(basePath).JARFile.spec); zReader.open(fileName); //hardcoded 'content' as that is the root dir in the mochikit.jar file + var idx = basePath.indexOf('/content'); + var basePath = basePath.slice(0, idx); + var base = "content/" + dir + "/"; var singleTestPath; @@ -119,7 +122,7 @@ function getMochitestJarListing(basePath, testPath, dir) if (pathEntry.isDirectory) { base = pathToCheck; } else { - singleTestPath = '/' + base + testPath; + singleTestPath = basePath + '/' + base + testPath; var singleObject = {}; singleObject[singleTestPath] = true; return [singleObject, singleTestPath]; @@ -129,7 +132,7 @@ function getMochitestJarListing(basePath, testPath, dir) base = pathToCheck + "/"; } } - var [links, count] = zList(base, zReader, true); + var [links, count] = zList(base, zReader, basePath, true); return [links, null]; } @@ -143,7 +146,7 @@ function getMochitestJarListing(basePath, testPath, dir) * returns: * [json object of {dir:{subdir:{file:true, file:true, ...}}}, count of tests] */ -function zList(base, zReader, recurse) { +function zList(base, zReader, baseJarName, recurse) { var dirs = zReader.findEntries(base + "*"); var links = {}; var count = 0; @@ -162,12 +165,12 @@ function zList(base, zReader, recurse) { var myFile = fileArray[i]; if (myFile.substr(-1) === '/' && recurse) { var childCount = 0; - [links[myFile], childCount] = zList(myFile, zReader, recurse); + [links[myFile], childCount] = zList(myFile, zReader, baseJarName, recurse); count += childCount; } else { if (myFile.indexOf("SimpleTest") == -1) { //we add the '/' so we don't try to run content/content/chrome - links['/' + myFile] = true; + links[baseJarName + '/' + myFile] = true; } } } @@ -283,7 +286,7 @@ function extractJarToTmp(jar) { tmpdir.append("mochikit.tmp"); // parseInt is used because octal escape sequences cause deprecation warnings // in strict mode (which is turned on in debug builds) - tmpdir.createUnique(Components.interfaces.nsIFile.DIRECTORY_TYPE, parseInt("0777", 8)); + tmpdir.createUnique(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); var zReader = Components.classes["@mozilla.org/libjar/zip-reader;1"]. createInstance(Components.interfaces.nsIZipReader); @@ -311,7 +314,7 @@ function extractJarToTmp(jar) { var targetDir = buildRelativePath(dirs.getNext(), tmpdir, filepath); // parseInt is used because octal escape sequences cause deprecation warnings // in strict mode (which is turned on in debug builds) - targetDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, parseInt("0777", 8)); + targetDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); } //now do the files diff --git a/testing/mochitest/harness-overlay.xul b/testing/mochitest/harness-overlay.xul index 49bcd9904f0..57fc6d5da52 100644 --- a/testing/mochitest/harness-overlay.xul +++ b/testing/mochitest/harness-overlay.xul @@ -17,76 +17,59 @@ src="chrome://mochikit/content/tests/SimpleTest/quit.js" />