From 50c56145071bdb09f52364480e6019a46c807a10 Mon Sep 17 00:00:00 2001 From: Scott Greenlay Date: Mon, 20 Sep 2010 20:21:55 -0400 Subject: [PATCH] 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 | 14 +++++------ layout/tools/reftest/reftest.js | 21 ++++++++++++++++ modules/plugin/base/src/nsNPAPIPlugin.cpp | 20 ++++++++++++++++ .../plugin/test/mochitest/test_GCrace.html | 5 +--- .../mochitest/test_crash_nested_loop.html | 5 +--- .../test/mochitest/test_crash_notify.xul | 5 +--- .../mochitest/test_crash_notify_no_report.xul | 5 +--- .../test/mochitest/test_crash_submit.xul | 4 +--- .../plugin/test/mochitest/test_crashing.html | 5 +--- .../plugin/test/mochitest/test_crashing2.html | 5 +--- .../plugin/test/mochitest/test_hanging.html | 9 +++---- modules/plugin/test/reftest/reftest.list | 4 ++-- .../mochitest/tests/SimpleTest/SimpleTest.js | 24 +++++++++++++++++++ testing/testsuite-targets.mk | 10 ++++++++ 14 files changed, 95 insertions(+), 41 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index f854b0d1880..38906b4ce5d 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -936,14 +936,12 @@ pref("toolbar.customization.usesheet", false); // 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); #elifdef MOZ_IPC pref("dom.ipc.plugins.enabled", true); #else diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index b6dfcab784d..23c26a2e51c 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -441,6 +441,27 @@ function BuildConditionSandbox(aURL) { getBoolPref: function(p) { return this._prefs.getBoolPref(p); }, getIntPref: function(p) { return this._prefs.getIntPref(p); } } + + sandbox.areOOPPenabled = function () { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var prefservice = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + + var pref = false; + + if (navigator.platform == "Mac") { + if (navigator.platform == "i386") { + pref = prefservice.getBoolPref("dom.ipc.plugins.enabled.i386"); + } + else if (navigator.platform == "x86_64") { + pref = prefservice.getBoolPref("dom.ipc.plugins.enabled.x86_64"); + } + } + else { + pref = prefservice.getBoolPref("dom.ipc.plugins.enabled") + } + return pref; + }; dump("REFTEST INFO | Dumping JSON representation of sandbox \n"); dump("REFTEST INFO | " + JSON.stringify(sandbox) + " \n"); diff --git a/modules/plugin/base/src/nsNPAPIPlugin.cpp b/modules/plugin/base/src/nsNPAPIPlugin.cpp index b907fe981c7..e181db3f89a 100644 --- a/modules/plugin/base/src/nsNPAPIPlugin.cpp +++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp @@ -373,7 +373,17 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) 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; @@ -413,7 +423,17 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) 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; diff --git a/modules/plugin/test/mochitest/test_GCrace.html b/modules/plugin/test/mochitest/test_GCrace.html index dd16bcb7faa..2907877c92b 100644 --- a/modules/plugin/test/mochitest/test_GCrace.html +++ b/modules/plugin/test/mochitest/test_GCrace.html @@ -16,10 +16,7 @@ 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')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); SimpleTest.finish(); return; diff --git a/modules/plugin/test/mochitest/test_crash_nested_loop.html b/modules/plugin/test/mochitest/test_crash_nested_loop.html index d9c60dea0ba..38cd8cf6fc6 100644 --- a/modules/plugin/test/mochitest/test_crash_nested_loop.html +++ b/modules/plugin/test/mochitest/test_crash_nested_loop.html @@ -12,10 +12,7 @@ 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')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); SimpleTest.finish(); return; diff --git a/modules/plugin/test/mochitest/test_crash_notify.xul b/modules/plugin/test/mochitest/test_crash_notify.xul index 48b09c83127..259af9de95a 100644 --- a/modules/plugin/test/mochitest/test_crash_notify.xul +++ b/modules/plugin/test/mochitest/test_crash_notify.xul @@ -92,10 +92,7 @@ function onPluginCrashed(aEvent) { } 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')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); SimpleTest.finish(); return; diff --git a/modules/plugin/test/mochitest/test_crash_notify_no_report.xul b/modules/plugin/test/mochitest/test_crash_notify_no_report.xul index 896249c18f5..6d55071156f 100644 --- a/modules/plugin/test/mochitest/test_crash_notify_no_report.xul +++ b/modules/plugin/test/mochitest/test_crash_notify_no_report.xul @@ -94,10 +94,7 @@ function onPluginCrashed(aEvent) { } 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')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); SimpleTest.finish(); return; diff --git a/modules/plugin/test/mochitest/test_crash_submit.xul b/modules/plugin/test/mochitest/test_crash_submit.xul index 67ac520b778..ca9a848b90c 100644 --- a/modules/plugin/test/mochitest/test_crash_submit.xul +++ b/modules/plugin/test/mochitest/test_crash_submit.xul @@ -93,9 +93,7 @@ function onPluginCrashed(aEvent) { } function runTests() { - var prefs = Components.classes['@mozilla.org/preferences-service;1'] - .getService(Components.interfaces.nsIPrefBranch); - if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); SimpleTest.finish(); return; diff --git a/modules/plugin/test/mochitest/test_crashing.html b/modules/plugin/test/mochitest/test_crashing.html index d678ff00e16..f2c666eedcf 100644 --- a/modules/plugin/test/mochitest/test_crashing.html +++ b/modules/plugin/test/mochitest/test_crashing.html @@ -12,10 +12,7 @@ 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')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); SimpleTest.finish(); return; diff --git a/modules/plugin/test/mochitest/test_crashing2.html b/modules/plugin/test/mochitest/test_crashing2.html index d2a2db79c34..fde29f4f318 100644 --- a/modules/plugin/test/mochitest/test_crashing2.html +++ b/modules/plugin/test/mochitest/test_crashing2.html @@ -12,10 +12,7 @@ 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')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); SimpleTest.finish(); return; diff --git a/modules/plugin/test/mochitest/test_hanging.html b/modules/plugin/test/mochitest/test_hanging.html index 2a2b4e30405..4dbae3f0f76 100644 --- a/modules/plugin/test/mochitest/test_hanging.html +++ b/modules/plugin/test/mochitest/test_hanging.html @@ -12,15 +12,16 @@ 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')) { + if (!SimpleTest.areOOPPenabled()) { ok(true, "Skipping this test when IPC plugins are not enabled."); 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); diff --git a/modules/plugin/test/reftest/reftest.list b/modules/plugin/test/reftest/reftest.list index 81274e0511e..a1c05f7576a 100644 --- a/modules/plugin/test/reftest/reftest.list +++ b/modules/plugin/test/reftest/reftest.list @@ -6,7 +6,7 @@ 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 -asserts-if(http.oscpu.match(/Linux/),0-1) random-if(d2d) fails-if(!haveTestPlugin) skip-if(!prefs.getBoolPref("dom.ipc.plugins.enabled")) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html # assertion is bug 585394 -asserts-if(http.oscpu.match(/Linux/),0-1) fails-if(!haveTestPlugin) skip-if(!prefs.getBoolPref("dom.ipc.plugins.enabled")) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html # assertion is bug 585394 +asserts-if(http.oscpu.match(/Linux/),0-1) random-if(d2d) fails-if(!haveTestPlugin) skip-if(!areOOPPenabled()) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html # assertion is bug 585394 +asserts-if(http.oscpu.match(/Linux/),0-1) fails-if(!haveTestPlugin) skip-if(!areOOPPenabled()) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html # assertion is bug 585394 # Disabled for now to investigate Windows/Linux test failures # fails-if(!haveTestPlugin) == border-padding-3.html border-padding-3-ref.html diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js index fa05fb0e53f..9d9429f8646 100644 --- a/testing/mochitest/tests/SimpleTest/SimpleTest.js +++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js @@ -32,6 +32,30 @@ if (parentRunner) { ipcMode = parentRunner.ipcMode; } +/** + * Check for OOPP preferences +**/ +SimpleTest.areOOPPenabled = function () { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var prefservice = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + + var pref = false; + + if (navigator.platform == "Mac") { + if (navigator.platform == "i386") { + pref = prefservice.getBoolPref("dom.ipc.plugins.enabled.i386"); + } + else if (navigator.platform == "x86_64") { + pref = prefservice.getBoolPref("dom.ipc.plugins.enabled.x86_64"); + } + } + else { + pref = prefservice.getBoolPref("dom.ipc.plugins.enabled") + } + return pref; +}; + // Check to see if the TestRunner is present and has logging if (parentRunner) { SimpleTest._logEnabled = parentRunner.logEnabled; diff --git a/testing/testsuite-targets.mk b/testing/testsuite-targets.mk index 28fc48d8b92..a9c951bc43e 100644 --- a/testing/testsuite-targets.mk +++ b/testing/testsuite-targets.mk @@ -83,7 +83,17 @@ mochitest-a11y: $(CHECK_TEST_ERROR) mochitest-ipcplugins: +#ifdef XP_MACOSX +#if defined(__i386__) + $(RUN_MOCHITEST) --setpref=dom.ipc.plugins.enabled.i386=true --test-path=modules/plugin/test +#elif defined(__x86_64__) + $(RUN_MOCHITEST) --setpref=dom.ipc.plugins.enabled.x86_64=true --test-path=modules/plugin/test +#elif defined(__ppc__) + $(RUN_MOCHITEST) --setpref=dom.ipc.plugins.enabled.ppc=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|.