forked from mirrors/gecko-dev
		
	 4a4c4fdfd4
			
		
	
	
		4a4c4fdfd4
		
	
	
	
	
		
			
			MozReview-Commit-ID: LxLDWlsIlSk --HG-- extra : rebase_source : 5762bdf08ff6c09c1b29f87366bddb552e4c74b2 extra : amend_source : 922a0c03722bd5a81daace7f0289ec3228191cfb
		
			
				
	
	
		
			52 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| "use strict";
 | |
| 
 | |
| // This test checks whether applied WebExtension themes are persisted and applied
 | |
| // on newly opened windows.
 | |
| 
 | |
| add_task(async function setup() {
 | |
|   await SpecialPowers.pushPrefEnv({
 | |
|     set: [["extensions.webextensions.themes.enabled", true]],
 | |
|   });
 | |
| });
 | |
| 
 | |
| add_task(async function test_multiple_windows() {
 | |
|   let extension = ExtensionTestUtils.loadExtension({
 | |
|     manifest: {
 | |
|       "theme": {
 | |
|         "images": {
 | |
|           "headerURL": "image1.png",
 | |
|         },
 | |
|         "colors": {
 | |
|           "accentcolor": ACCENT_COLOR,
 | |
|           "textcolor": TEXT_COLOR,
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     files: {
 | |
|       "image1.png": BACKGROUND,
 | |
|     },
 | |
|   });
 | |
| 
 | |
|   await extension.startup();
 | |
| 
 | |
|   let docEl = window.document.documentElement;
 | |
|   let style = window.getComputedStyle(docEl);
 | |
| 
 | |
|   Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
 | |
|   Assert.equal(docEl.getAttribute("lwthemetextcolor"), "bright",
 | |
|                "LWT text color attribute should be set");
 | |
|   Assert.ok(style.backgroundImage.includes("image1.png"), "Expected background image");
 | |
| 
 | |
|   // Now we'll open a new window to see if the theme is also applied there.
 | |
|   let window2 = await BrowserTestUtils.openNewBrowserWindow();
 | |
|   docEl = window2.document.documentElement;
 | |
|   style = window2.getComputedStyle(docEl);
 | |
| 
 | |
|   Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
 | |
|   Assert.equal(docEl.getAttribute("lwthemetextcolor"), "bright",
 | |
|                "LWT text color attribute should be set");
 | |
|   Assert.ok(style.backgroundImage.includes("image1.png"), "Expected background image");
 | |
| 
 | |
|   await BrowserTestUtils.closeWindow(window2);
 | |
|   await extension.unload();
 | |
| });
 |