mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-11-04 10:18:41 +02:00 
			
		
		
		
	The draw-background key was removed from gsettings-desktop-schemas in
2013 [0], but was patched into Ubuntu until 21.10. Since it was
apparently unused over a decade ago, remove all reference to the key.
Removing the references in the tests would be sufficient to fix the bug,
but then (a) running the test on older systems wouldn't restore the
key's value, and (b) it just errors on new systems, so there's no point
in running it.
[0]: a59b45e766
Differential Revision: https://phabricator.services.mozilla.com/D251353
		
	
			
		
			
				
	
	
		
			103 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			103 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const DG_BACKGROUND = "/desktop/gnome/background";
 | 
						|
const DG_IMAGE_KEY = DG_BACKGROUND + "/picture_filename";
 | 
						|
const DG_OPTION_KEY = DG_BACKGROUND + "/picture_options";
 | 
						|
const DG_DRAW_BG_KEY = DG_BACKGROUND + "/draw_background";
 | 
						|
 | 
						|
const GS_BG_SCHEMA = "org.gnome.desktop.background";
 | 
						|
const GS_IMAGE_KEY = "picture-uri";
 | 
						|
const GS_OPTION_KEY = "picture-options";
 | 
						|
const GS_DRAW_BG_KEY = "draw-background";
 | 
						|
 | 
						|
add_task(async function () {
 | 
						|
  await BrowserTestUtils.withNewTab(
 | 
						|
    {
 | 
						|
      gBrowser,
 | 
						|
      url: "about:logo",
 | 
						|
    },
 | 
						|
    () => {
 | 
						|
      var brandName = Services.strings
 | 
						|
        .createBundle("chrome://branding/locale/brand.properties")
 | 
						|
        .GetStringFromName("brandShortName");
 | 
						|
 | 
						|
      var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(
 | 
						|
        Ci.nsIDirectoryServiceProvider
 | 
						|
      );
 | 
						|
      var homeDir = dirSvc.getFile("Home", {});
 | 
						|
 | 
						|
      var wpFile = homeDir.clone();
 | 
						|
      wpFile.append(brandName + "_wallpaper.png");
 | 
						|
 | 
						|
      // Backup the existing wallpaper so that this test doesn't change the user's
 | 
						|
      // settings.
 | 
						|
      var wpFileBackup = homeDir.clone();
 | 
						|
      wpFileBackup.append(brandName + "_wallpaper.png.backup");
 | 
						|
 | 
						|
      if (wpFileBackup.exists()) {
 | 
						|
        wpFileBackup.remove(false);
 | 
						|
      }
 | 
						|
 | 
						|
      if (wpFile.exists()) {
 | 
						|
        wpFile.copyTo(null, wpFileBackup.leafName);
 | 
						|
      }
 | 
						|
 | 
						|
      var shell = Cc["@mozilla.org/browser/shell-service;1"].getService(
 | 
						|
        Ci.nsIShellService
 | 
						|
      );
 | 
						|
 | 
						|
      // For simplicity, we're going to reach in and access the image on the
 | 
						|
      // page directly, which means the page shouldn't be running in a remote
 | 
						|
      // browser. Thankfully, about:logo runs in the parent process for now.
 | 
						|
      Assert.ok(
 | 
						|
        !gBrowser.selectedBrowser.isRemoteBrowser,
 | 
						|
        "image can be accessed synchronously from the parent process"
 | 
						|
      );
 | 
						|
 | 
						|
      var image = content.document.images[0];
 | 
						|
 | 
						|
      let checkWallpaper, restoreSettings;
 | 
						|
      try {
 | 
						|
        // Try via GSettings first
 | 
						|
        const gsettings = Cc["@mozilla.org/gsettings-service;1"]
 | 
						|
          .getService(Ci.nsIGSettingsService)
 | 
						|
          .getCollectionForSchema(GS_BG_SCHEMA);
 | 
						|
 | 
						|
        const prevImage = gsettings.getString(GS_IMAGE_KEY);
 | 
						|
        const prevOption = gsettings.getString(GS_OPTION_KEY);
 | 
						|
 | 
						|
        checkWallpaper = function (position, expectedGSettingsPosition) {
 | 
						|
          shell.setDesktopBackground(image, position, "");
 | 
						|
          ok(wpFile.exists(), "Wallpaper was written to disk");
 | 
						|
          is(
 | 
						|
            gsettings.getString(GS_IMAGE_KEY),
 | 
						|
            encodeURI("file://" + wpFile.path),
 | 
						|
            "Wallpaper file GSettings key is correct"
 | 
						|
          );
 | 
						|
          is(
 | 
						|
            gsettings.getString(GS_OPTION_KEY),
 | 
						|
            expectedGSettingsPosition,
 | 
						|
            "Wallpaper position GSettings key is correct"
 | 
						|
          );
 | 
						|
        };
 | 
						|
 | 
						|
        restoreSettings = function () {
 | 
						|
          gsettings.setString(GS_IMAGE_KEY, prevImage);
 | 
						|
          gsettings.setString(GS_OPTION_KEY, prevOption);
 | 
						|
        };
 | 
						|
      } catch (e) {}
 | 
						|
 | 
						|
      checkWallpaper(Ci.nsIShellService.BACKGROUND_TILE, "wallpaper");
 | 
						|
      checkWallpaper(Ci.nsIShellService.BACKGROUND_STRETCH, "stretched");
 | 
						|
      checkWallpaper(Ci.nsIShellService.BACKGROUND_CENTER, "centered");
 | 
						|
      checkWallpaper(Ci.nsIShellService.BACKGROUND_FILL, "zoom");
 | 
						|
      checkWallpaper(Ci.nsIShellService.BACKGROUND_FIT, "scaled");
 | 
						|
      checkWallpaper(Ci.nsIShellService.BACKGROUND_SPAN, "spanned");
 | 
						|
 | 
						|
      restoreSettings();
 | 
						|
 | 
						|
      // Restore files
 | 
						|
      if (wpFileBackup.exists()) {
 | 
						|
        wpFileBackup.moveTo(null, wpFile.leafName);
 | 
						|
      }
 | 
						|
    }
 | 
						|
  );
 | 
						|
});
 |