Fix crashing iframes due to gtk_init, stop using windows in xpcshell tests
authorBen Turner <bent.mozilla@gmail.com>
Tue, 08 Sep 2009 13:35:12 -0700
changeset 35892 eb2e8946baa1bf6f2ace6b5ba1fc7fa6bbf06367
parent 35891 56e8ff80e374ea67692614952f7c1e1c5dabdad0
child 35893 0e69d53a498169ebf3acf888711b4e974fa6e247
push idunknown
push userunknown
push dateunknown
milestone1.9.3a1pre
Fix crashing iframes due to gtk_init, stop using windows in xpcshell tests
ipc/app/MozillaRuntimeMain.cpp
ipc/testshell/tests/test_ipcshell.js
ipc/testshell/tests/test_ipcshell_child.js
--- a/ipc/app/MozillaRuntimeMain.cpp
+++ b/ipc/app/MozillaRuntimeMain.cpp
@@ -58,20 +58,16 @@
 
 int
 main(int argc, char* argv[])
 {
 #if 0
     MessageBox(NULL, L"Hi", L"Hi", MB_OK);
 #endif
 
-#ifdef MOZ_WIDGET_GTK2
-    gtk_init(0, 0);
-#endif
-
     GeckoProcessType proctype =
         XRE_StringToChildProcessType(argv[argc - 1]);
 
     nsresult rv = XRE_InitChildProcess(argc - 1, argv, proctype);
     NS_ENSURE_SUCCESS(rv, 1);
 
     return 0;
 }
--- a/ipc/testshell/tests/test_ipcshell.js
+++ b/ipc/testshell/tests/test_ipcshell.js
@@ -1,15 +1,15 @@
-function checkStatus(result) {
-  if (result == "Waiting") {
-    sendCommand("observer.status;", checkStatus);
-    return;
-  }
-
-  do_check_eq(result, "Success");
+function callback(result) {
+  do_check_eq(result, Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT);
   do_test_finished();
 }
 
 function run_test() {
   do_test_pending();
-  sendCommand("load('test_ipcshell_child.js'); start();");
-  sendCommand("observer.status;", checkStatus);
+
+  do_check_eq(runtime.processType, Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+  
+  sendCommand("load('test_ipcshell_child.js');");
+  sendCommand("runtime.processType;", callback);
 }
+load('test_ipcshell_child.js');
+
--- a/ipc/testshell/tests/test_ipcshell_child.js
+++ b/ipc/testshell/tests/test_ipcshell_child.js
@@ -1,81 +1,9 @@
 const Cc = Components.classes;
 const Ci = Components.interfaces;
-
-function WWObserver(watcher) {
-  this._watcher = watcher;
-  this._status = "Waiting";
-}
-WWObserver.prototype = {
-  _exit: function(status) {
-    var ok = (status == "Success");
-
-    this._status = status;
-    this._window = null;
-    this._watcher.unregisterNotification(this);
-    this._watcher = null;
-
-    if (!ok) {
-      throw new Error(this._status);
-    }
-  },
-
-  observe: function(subject, topic, data) {
-    switch (topic) {
-      case "domwindowopened":
-        this._window = subject.QueryInterface(Ci.nsIDOMJSWindow);
-        if (!this._window) {
-          this._exit("Error");
-        }
-        this._window.setTimeout(function doTimeout(window) {
-          window.QueryInterface(Ci.nsIDOMWindowInternal).close();
-        }, 2000, this._window);
-        break;
-
-      case "domwindowclosed":
-        if (subject.QueryInterface(Ci.nsIDOMJSWindow) != this._window) {
-          this._exit("Error");
-        }
-        this._exit("Success");
-        break;
-
-      default:
-        this._exit("Error");
-    }
-  },
-
-  get status() {
-    return this._status;
-  }
-};
-
-var observer = null;
-
-function start(standalone) {
-  var windowCreator = Cc["@mozilla.org/toolkit/app-startup;1"].
-                      getService(Ci.nsIWindowCreator);
-  var windowWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].
-                      getService(Ci.nsIWindowWatcher);
-  windowWatcher.setWindowCreator(windowCreator);
-
-  observer = new WWObserver(windowWatcher);
-  windowWatcher.registerNotification(observer, standalone);
-
-  var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
-                      getService(Ci.nsIPromptService);
-  promptService.alert(null, "Howdy!", "This window will close automatically.");
-}
-
-function maybeExit() {
-  if (observer.status != "Waiting") {
-    do_check_eq(observer.status, "Success");
-    do_test_finished();
-    return;
-  }
-  do_timeout(100, "maybeExit();");
-}
-
-function run_test() {
-  do_test_pending();
-  start();
-  do_timeout(100, "maybeExit();");
-}
+
+const runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
+
+if (typeof(run_test) == "undefined") {
+  run_test = function() {
+    do_check_eq(runtime.processType, Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+  }
}