author Siddharth Agarwal <sid.bugzilla@gmail.com>
Fri, 09 Sep 2011 02:00:31 +0530
changeset 78045 57d1c50198050d7afdbb28f25a5af803a73c0677
parent 58429 bacd5fbd6456709f64182e6d73afc9eb0f4a6a9a
child 89293 a7f28072d882d4c0ea8b60a3dbdb47c0377b3739
permissions -rw-r--r--
Bug 681659 - Execute mozconfig-find just once and make sure mozconfig detection errors are handled properly. r=ted

package Tests;

use Util;
use strict;

my $objdir = '';

sub global_prefs {
    my ($binary, $embed_binary, $build_dir) = @_;

    my $binary_basename       = File::Basename::basename($binary);
    my $binary_dir            = File::Basename::dirname($binary);
    my $embed_binary_basename = File::Basename::basename($embed_binary);
    my $embed_binary_dir      = File::Basename::dirname($embed_binary);

    my $test_result = 'success';

    # Windows needs this for file: urls.
    my $win32_build_dir = $build_dir;
    if ($Settings::OS =~ /^WIN/ && $win32_build_dir !~ m/^.:\//) {
        chomp($win32_build_dir = `cygpath -w $win32_build_dir`);
        $win32_build_dir =~ s/\\/\//g;

    # Set prefs to run tests properly.
    # Chances are we will be timing these tests.  Bring gettime() into memory
    # by calling it once, before any tests run.

    my $pref_file = 'prefs.js';
    # Some tests need browser.dom.window.dump.enabled set to true, so
    # that JS dump() will work in optimized builds.
    Prefs::set_pref($pref_file, 'browser.dom.window.dump.enabled', 'true');
    # Set security prefs to allow us to close our own window,
    # pageloader test (and possibly other tests) needs this on.
    Prefs::set_pref($pref_file, 'dom.allow_scripts_to_close_windows', 'true');

    # Set security prefs to allow us to resize our windows.
    # DHTML and Tgfx perf tests (and possibly other tests) need this off.
    Prefs::set_pref($pref_file, 'dom.disable_window_flip', 'false');

    # Set prefs to allow us to move, resize, and raise/lower the
    # current window. Tgfx needs this.
    Prefs::set_pref($pref_file, 'dom.disable_window_flip', 'false');
    Prefs::set_pref($pref_file, 'dom.disable_window_move_resize', 'false');

    # Suppress firefox's popup blocking
    if ($Settings::BinaryName =~ /^firefox/) {
        Prefs::set_pref($pref_file, 'dom.disable_open_during_load', 'false');

        # Suppress default browser dialog
        Prefs::set_pref($pref_file, 'browser.shell.checkDefaultBrowser', 'false');

        # Suppress session restore dialog
        Prefs::set_pref($pref_file, 'browser.sessionstore.resume_from_crash', 'false');
    elsif ($Settings::BinaryName eq 'Camino') {
        Prefs::set_pref($pref_file, 'camino.check_default_browser', 'false');

    # Suppress security warnings for QA test.
    if ($Settings::QATest) {
        Prefs::set_pref($pref_file, 'security.warn_submit_insecure', 'true');
    # Assume that we want to test modern skin for all tests.
    if (system("\\grep -s general.skins.selectedSkin \"$pref_file\" > /dev/null")) {
        Util::print_log("Setting general.skins.selectedSkin to modern/1.0\n");
        open PREFS, ">>$pref_file" or die "can't open $pref_file ($?)\n";
        print PREFS "user_pref(\"general.skins.selectedSkin\", \"modern/1.0\");\n";
        close PREFS;
    } else {
        Util::print_log("Modern skin already set.\n");

    if ($Settings::BinaryName eq 'Camino') {
      # stdout will be block-buffered and will not be flushed when the test
      # timeout expires and the process is killed, this would make tests
      # appear to fail.