Bug 596762: Allow specification of differing IPC preferences for each architecture in a universal binary. r=josh a=blocking-b7
authorScott Greenlay <sgreenlay@mozilla.com>
Mon, 27 Sep 2010 16:42:43 -0400
changeset 54674 e0d1f460215cb4461ae2c64bf6ae1766709d6674
parent 54673 9829aad9a09ffd1cde72f92a9e85fe71a6c57899
child 54675 0c2e0a2a3714611a12d5fc4cb06cb7605d689b70
push id15987
push userjosh@mozilla.com
push dateMon, 27 Sep 2010 20:42:59 +0000
treeherdermozilla-central@e0d1f460215c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh, blocking-b7
bugs596762
milestone2.0b7pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 596762: Allow specification of differing IPC preferences for each architecture in a universal binary. r=josh a=blocking-b7
browser/app/profile/firefox.js
layout/tools/reftest/reftest.js
modules/plugin/base/src/nsNPAPIPlugin.cpp
modules/plugin/test/mochitest/test_GCrace.html
modules/plugin/test/mochitest/test_crash_nested_loop.html
modules/plugin/test/mochitest/test_crash_notify.xul
modules/plugin/test/mochitest/test_crash_notify_no_report.xul
modules/plugin/test/mochitest/test_crash_submit.xul
modules/plugin/test/mochitest/test_crashing.html
modules/plugin/test/mochitest/test_crashing2.html
modules/plugin/test/mochitest/test_hanging.html
modules/plugin/test/reftest/reftest.list
testing/mochitest/tests/SimpleTest/SimpleTest.js
testing/testsuite-targets.mk
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -933,24 +933,23 @@ pref("browser.sessionstore.interval", 60
 pref("toolbar.customization.usesheet", true);
 #else
 pref("toolbar.customization.usesheet", false);
 #endif
 
 // The default for this pref reflects whether the build is capable of IPC.
 // (Turning it on in a no-IPC build will have no effect.)
 #ifdef XP_MACOSX
-// OSX still has only partial support for IPC.  Note that the PowerPC
-// and x86 builds must generate identical copies of this file, so we
-// can't make the prefs indicate that IPC is not available at all in
-// PowerPC builds.
-pref("dom.ipc.plugins.enabled", false);
-// These plug-ins will run OOP by default
-pref("dom.ipc.plugins.enabled.flash player.plugin", true);
-pref("dom.ipc.plugins.enabled.javaplugin2_npapi.plugin", true);
+// i386 ipc preferences
+pref("dom.ipc.plugins.enabled.i386", false);
+pref("dom.ipc.plugins.enabled.i386.flash player.plugin", true);
+pref("dom.ipc.plugins.enabled.i386.javaplugin2_npapi.plugin", true);
+// x86_64 ipc preferences
+pref("dom.ipc.plugins.enabled.x86_64", true);
+pref("dom.ipc.plugins.enabled.x86_64.test.plugin", false);
 #elifdef MOZ_IPC
 pref("dom.ipc.plugins.enabled", true);
 #else
 pref("dom.ipc.plugins.enabled", false);
 #endif
 
 #ifdef XP_WIN
 #ifndef WINCE
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -437,16 +437,48 @@ function BuildConditionSandbox(aURL) {
         getBoolPref: 'r',
         getIntPref: 'r',
       },
       _prefs:      prefs,
       getBoolPref: function(p) { return this._prefs.getBoolPref(p); },
       getIntPref:  function(p) { return this._prefs.getIntPref(p); }
     }
 
+    sandbox.testPluginIsOOP = function () {
+        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+        var prefservice = Components.classes["@mozilla.org/preferences-service;1"]
+                                    .getService(CI.nsIPrefBranch);
+
+        var testPluginIsOOP = false;
+        if (navigator.platform.indexOf("Mac") == 0) {
+            var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+                                       .getService(CI.nsIXULAppInfo)
+                                       .QueryInterface(CI.nsIXULRuntime);
+            if (xulRuntime.XPCOMABI.match(/x86-/)) {
+                try {
+                    testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.i386.test.plugin");
+                } catch (e) {
+                    testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.i386");
+                }
+            }
+            else if (xulRuntime.XPCOMABI.match(/x86_64-/)) {
+                try {
+                    testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.x86_64.test.plugin");
+                } catch (e) {
+                    testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.x86_64");
+                }
+            }
+        }
+        else {
+            testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled");
+        }
+
+        return testPluginIsOOP;
+    };
+
     dump("REFTEST INFO | Dumping JSON representation of sandbox \n");
     dump("REFTEST INFO | " + JSON.stringify(sandbox) + " \n");
 
     return sandbox;
 }
 
 function ReadTopManifest(aFileURL)
 {
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -368,17 +368,27 @@ nsNPAPIPlugin::RunPluginOOP(const nsPlug
 
   nsCAutoString prefFile(aPluginTag->mFullPath.get());
   PRInt32 slashPos = prefFile.RFindCharInSet("/\\");
   if (kNotFound == slashPos)
     return PR_FALSE;
   prefFile.Cut(0, slashPos + 1);
   ToLowerCase(prefFile);
 
+#ifdef XP_MACOSX
+#if defined(__i386__)
+  nsCAutoString prefGroupKey("dom.ipc.plugins.enabled.i386.");
+#elif defined(__x86_64__)
+  nsCAutoString prefGroupKey("dom.ipc.plugins.enabled.x86_64.");
+#elif defined(__ppc__)
+  nsCAutoString prefGroupKey("dom.ipc.plugins.enabled.ppc.");
+#endif
+#else
   nsCAutoString prefGroupKey("dom.ipc.plugins.enabled.");
+#endif
 
   PRUint32 prefCount;
   char** prefNames;
   nsresult rv = prefs->GetChildList(prefGroupKey.get(),
                                     &prefCount, &prefNames);
 
   PRBool oopPluginsEnabled = PR_FALSE;
   PRBool prefSet = PR_FALSE;
@@ -408,17 +418,27 @@ nsNPAPIPlugin::RunPluginOOP(const nsPlug
         break;
       }
     }
     NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefNames);
   }
 
   if (!prefSet) {
     oopPluginsEnabled = PR_FALSE;
+#ifdef XP_MACOSX
+#if defined(__i386__)
+    prefs->GetBoolPref("dom.ipc.plugins.enabled.i386", &oopPluginsEnabled);
+#elif defined(__x86_64__)
+    prefs->GetBoolPref("dom.ipc.plugins.enabled.x86_64", &oopPluginsEnabled);
+#elif defined(__ppc__)
+    prefs->GetBoolPref("dom.ipc.plugins.enabled.ppc", &oopPluginsEnabled);
+#endif
+#else
     prefs->GetBoolPref("dom.ipc.plugins.enabled", &oopPluginsEnabled);
+#endif
   }
 
   return oopPluginsEnabled;
 }
 
 #endif // MOZ_IPC
 
 inline PluginLibrary*
--- a/modules/plugin/test/mochitest/test_GCrace.html
+++ b/modules/plugin/test/mochitest/test_GCrace.html
@@ -11,21 +11,18 @@
   <p id="display"></p>
 
   <embed id="p" type="application/x-test" wmode="window"></embed>
 
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
 
     function start() {
-      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-      var prefs = Components.classes['@mozilla.org/preferences-service;1']
-        .getService(Components.interfaces.nsIPrefBranch);
-      if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-        ok(true, "Skipping this test when IPC plugins are not enabled.");
+      if (!SimpleTest.testPluginIsOOP()) {
+        ok(true, "Skipping this test when test plugin is not OOP.");
         SimpleTest.finish();
         return;
       }
       else {
         setTimeout(checkGCRace, 1000);
       }
     }
 
--- a/modules/plugin/test/mochitest/test_crash_nested_loop.html
+++ b/modules/plugin/test/mochitest/test_crash_nested_loop.html
@@ -7,21 +7,18 @@
   <iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
 
   var iframe = document.getElementById('iframe1');
 
   window.frameLoaded = function frameLoaded_toCrash() {
-    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-    var prefs = Components.classes['@mozilla.org/preferences-service;1']
-      .getService(Components.interfaces.nsIPrefBranch);
-    if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-      ok(true, "Skipping this test when IPC plugins are not enabled.");
+    if (!SimpleTest.testPluginIsOOP()) {
+      ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
     }
 
     var p = iframe.contentDocument.getElementById('plugin1');
 
     // This test is for bug 550026, which is inherently nondeterministic.
     // If we hit that bug, the browser process would crash when the plugin
--- a/modules/plugin/test/mochitest/test_crash_notify.xul
+++ b/modules/plugin/test/mochitest/test_crash_notify.xul
@@ -87,21 +87,18 @@ function onPluginCrashed(aEvent) {
   var os = Components.classes["@mozilla.org/observer-service;1"].
            getService(Components.interfaces.nsIObserverService);
   os.removeObserver(testObserver, "plugin-crashed");
 
   SimpleTest.finish();
 }
 
 function runTests() {
-  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-  var prefs = Components.classes['@mozilla.org/preferences-service;1']
-    .getService(Components.interfaces.nsIPrefBranch);
-  if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-    ok(true, "Skipping this test when IPC plugins are not enabled.");
+  if (!SimpleTest.testPluginIsOOP()) {
+    ok(true, "Skipping this test when test plugin is not OOP.");
     SimpleTest.finish();
     return;
   }
 
   var os = Components.classes["@mozilla.org/observer-service;1"].
            getService(Components.interfaces.nsIObserverService);
   os.addObserver(testObserver, "plugin-crashed", true);
   
--- a/modules/plugin/test/mochitest/test_crash_notify_no_report.xul
+++ b/modules/plugin/test/mochitest/test_crash_notify_no_report.xul
@@ -89,21 +89,18 @@ function onPluginCrashed(aEvent) {
   // re-set MOZ_CRASHREPORTER_NO_REPORT
   let env = Components.classes["@mozilla.org/process/environment;1"]
                       .getService(Components.interfaces.nsIEnvironment);
   env.set("MOZ_CRASHREPORTER_NO_REPORT", "1");
   SimpleTest.finish();
 }
 
 function runTests() {
-  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-  var prefs = Components.classes['@mozilla.org/preferences-service;1']
-    .getService(Components.interfaces.nsIPrefBranch);
-  if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-    ok(true, "Skipping this test when IPC plugins are not enabled.");
+  if (!SimpleTest.testPluginIsOOP()) {
+    ok(true, "Skipping this test when test plugin is not OOP.");
     SimpleTest.finish();
     return;
   }
   // the test harness will have set MOZ_CRASHREPORTER_NO_REPORT,
   // ensure that we can change the setting and have our minidumps
   // wind up in Crash Reports/pending
   let env = Components.classes["@mozilla.org/process/environment;1"]
                       .getService(Components.interfaces.nsIEnvironment);
--- a/modules/plugin/test/mochitest/test_crash_submit.xul
+++ b/modules/plugin/test/mochitest/test_crash_submit.xul
@@ -88,20 +88,18 @@ function onPluginCrashed(aEvent) {
 
   let pleaseLink = document.getAnonymousElementByAttribute(
                             aEvent.target, "class", "pleaseSubmitLink");
   // try to submit this report
   sendMouseEvent({type:'click'}, pleaseLink, window);
 }
 
 function runTests() {
-  var prefs = Components.classes['@mozilla.org/preferences-service;1']
-    .getService(Components.interfaces.nsIPrefBranch);
-  if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-    ok(true, "Skipping this test when IPC plugins are not enabled.");
+  if (!SimpleTest.testPluginIsOOP()) {
+    ok(true, "Skipping this test when test plugin is not OOP.");
     SimpleTest.finish();
     return;
   }
   // the test harness will have set MOZ_CRASHREPORTER_NO_REPORT,
   // ensure that we can change the setting and have our minidumps
   // wind up in Crash Reports/pending
   let env = Components.classes["@mozilla.org/process/environment;1"]
                       .getService(Components.interfaces.nsIEnvironment);
--- a/modules/plugin/test/mochitest/test_crashing.html
+++ b/modules/plugin/test/mochitest/test_crashing.html
@@ -7,21 +7,18 @@
   <iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
 
   var iframe = document.getElementById('iframe1');
 
   window.frameLoaded = function frameLoaded_toCrash() {
-    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-    var prefs = Components.classes['@mozilla.org/preferences-service;1']
-      .getService(Components.interfaces.nsIPrefBranch);
-    if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-      ok(true, "Skipping this test when IPC plugins are not enabled.");
+    if (!SimpleTest.testPluginIsOOP()) {
+      ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
     }
 
     var p = iframe.contentDocument.getElementById('plugin1');
 
     p.setColor("FFFF00FF");
 
--- a/modules/plugin/test/mochitest/test_crashing2.html
+++ b/modules/plugin/test/mochitest/test_crashing2.html
@@ -7,21 +7,18 @@
   <iframe id="iframe1" src="about:blank" width="600" height="600"></iframe>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
 
   var iframe = document.getElementById('iframe1');
 
   function mainLoaded() {
-    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-    var prefs = Components.classes['@mozilla.org/preferences-service;1']
-      .getService(Components.interfaces.nsIPrefBranch);
-    if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-      ok(true, "Skipping this test when IPC plugins are not enabled.");
+    if (!SimpleTest.testPluginIsOOP()) {
+      ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
     }
 
     var p = iframe.contentDocument.createElement('embed');
     p.setAttribute('id', 'plugin1');
     p.setAttribute('type', 'application/x-test');
     p.setAttribute('width', '400');
--- a/modules/plugin/test/mochitest/test_hanging.html
+++ b/modules/plugin/test/mochitest/test_hanging.html
@@ -7,25 +7,26 @@
   <iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
 
   var iframe = document.getElementById('iframe1');
 
   window.frameLoaded = function frameLoaded_toCrash() {
-    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-    var prefs = Components.classes['@mozilla.org/preferences-service;1']
-      .getService(Components.interfaces.nsIPrefBranch);
-    if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
-      ok(true, "Skipping this test when IPC plugins are not enabled.");
+    if (!SimpleTest.testPluginIsOOP()) {
+      ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
     }
 
+    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+    var prefs = Components.classes['@mozilla.org/preferences-service;1']
+        .getService(Components.interfaces.nsIPrefBranch);
+
     // the default timeout is annoying high for mochitest runs
     var timeoutPref = "dom.ipc.plugins.timeoutSecs";
     prefs.setIntPref(timeoutPref, 5);
 
     var p = iframe.contentDocument.getElementById('plugin1');
 
     p.setColor("FFFF00FF");
 
--- a/modules/plugin/test/reftest/reftest.list
+++ b/modules/plugin/test/reftest/reftest.list
@@ -1,12 +1,12 @@
 # basic sanity checking
 random-if(!haveTestPlugin) != plugin-sanity.html about:blank
 fails-if(!haveTestPlugin) == plugin-sanity.html div-sanity.html
 fails-if(!haveTestPlugin) == plugin-alpha-zindex.html div-alpha-zindex.html
 fails-if(!haveTestPlugin) == plugin-alpha-opacity.html div-alpha-opacity.html
 fails-if(!haveTestPlugin) == windowless-clipping-1.html windowless-clipping-1-ref.html
 fails-if(!haveTestPlugin) == border-padding-1.html border-padding-1-ref.html
 fails-if(!haveTestPlugin) == border-padding-2.html border-padding-2-ref.html
-random-if(cocoaWidget||d2d) fails-if(!haveTestPlugin) skip-if(!prefs.getBoolPref("dom.ipc.plugins.enabled")) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html
-fails-if(!haveTestPlugin) skip-if(!prefs.getBoolPref("dom.ipc.plugins.enabled")) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html
+random-if(cocoaWidget||d2d) fails-if(!haveTestPlugin) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html
+fails-if(!haveTestPlugin) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html
 # Disabled for now to investigate Windows/Linux test failures
 # fails-if(!haveTestPlugin) == border-padding-3.html border-padding-3-ref.html
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -27,16 +27,51 @@ if (typeof(parent) != "undefined" && par
 }
 
 //Simple test to see if we are running in e10s IPC
 var ipcMode = false;
 if (parentRunner) {
   ipcMode = parentRunner.ipcMode;
 }
 
+/**
+ * Check for OOP test plugin
+**/
+SimpleTest.testPluginIsOOP = function () {
+    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+    var prefservice = Components.classes["@mozilla.org/preferences-service;1"]
+                                .getService(CI.nsIPrefBranch);
+
+    var testPluginIsOOP = false;
+    if (navigator.platform.indexOf("Mac") == 0) {
+        var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+                                   .getService(CI.nsIXULAppInfo)
+                                   .QueryInterface(CI.nsIXULRuntime);
+        if (xulRuntime.XPCOMABI.match(/x86-/)) {
+            try {
+                testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.i386.test.plugin");
+            } catch (e) {
+                testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.i386");
+            }
+        }
+        else if (xulRuntime.XPCOMABI.match(/x86_64-/)) {
+            try {
+                testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.x86_64.test.plugin");
+            } catch (e) {
+                testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled.x86_64");
+            }
+        }
+    }
+    else {
+        testPluginIsOOP = prefservice.getBoolPref("dom.ipc.plugins.enabled");
+    }
+
+    return testPluginIsOOP;
+};
+
 // Check to see if the TestRunner is present and has logging
 if (parentRunner) {
     SimpleTest._logEnabled = parentRunner.logEnabled;
 }
 
 SimpleTest._tests = [];
 SimpleTest._stopOnLoad = true;
 
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -78,17 +78,27 @@ mochitest-chrome:
 	$(RUN_MOCHITEST) --chrome
 	$(CHECK_TEST_ERROR)
 
 mochitest-a11y:
 	$(RUN_MOCHITEST) --a11y
 	$(CHECK_TEST_ERROR)
 
 mochitest-ipcplugins:
+#ifdef XP_MACOSX
+#if defined(__i386__)
+	$(RUN_MOCHITEST) --setpref=dom.ipc.plugins.enabled.i386.test.plugin=true --test-path=modules/plugin/test
+#elif defined(__x86_64__)
+	$(RUN_MOCHITEST) --setpref=dom.ipc.plugins.enabled.x86_64.test.plugin=true --test-path=modules/plugin/test
+#elif defined(__ppc__)
+	$(RUN_MOCHITEST) --setpref=dom.ipc.plugins.enabled.ppc.test.plugin=true --test-path=modules/plugin/test
+#endif
+#else
 	$(RUN_MOCHITEST) --setpref=dom.ipc.plugins.enabled=true --test-path=modules/plugin/test
+#endif
 	$(CHECK_TEST_ERROR)
 
 # Usage: |make [EXTRA_TEST_ARGS=...] *test|.
 RUN_REFTEST = rm -f ./$@.log && $(PYTHON) _tests/reftest/runreftest.py \
   $(SYMBOLS_PATH) $(EXTRA_TEST_ARGS) $(1) | tee ./$@.log
 
 reftest: TEST_PATH=layout/reftests/reftest.list
 reftest: