1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_996364_registerArea_different_properties.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Calling CustomizableUI.registerArea twice with no 1.11 +// properties should not throw an exception. 1.12 +add_task(function() { 1.13 + try { 1.14 + CustomizableUI.registerArea("area-996364", {}); 1.15 + CustomizableUI.registerArea("area-996364", {}); 1.16 + } catch (ex) { 1.17 + ok(false, ex.message); 1.18 + } 1.19 + 1.20 + CustomizableUI.unregisterArea("area-996364", true); 1.21 +}); 1.22 + 1.23 +add_task(function() { 1.24 + let exceptionThrown = false; 1.25 + try { 1.26 + CustomizableUI.registerArea("area-996364-2", {type: CustomizableUI.TYPE_TOOLBAR, defaultCollapsed: "false"}); 1.27 + } catch (ex) { 1.28 + exceptionThrown = true; 1.29 + } 1.30 + ok(exceptionThrown, "defaultCollapsed is not allowed as an external property"); 1.31 + 1.32 + // No need to unregister the area because registration fails. 1.33 +}); 1.34 + 1.35 +add_task(function() { 1.36 + let exceptionThrown; 1.37 + try { 1.38 + CustomizableUI.registerArea("area-996364-3", {type: CustomizableUI.TYPE_TOOLBAR}); 1.39 + CustomizableUI.registerArea("area-996364-3", {type: CustomizableUI.TYPE_MENU_PANEL}); 1.40 + } catch (ex) { 1.41 + exceptionThrown = ex; 1.42 + } 1.43 + ok(exceptionThrown, "Exception expected, an area cannot change types: " + (exceptionThrown ? exceptionThrown : "[no exception]")); 1.44 + 1.45 + CustomizableUI.unregisterArea("area-996364-3", true); 1.46 +}); 1.47 + 1.48 +add_task(function() { 1.49 + let exceptionThrown; 1.50 + try { 1.51 + CustomizableUI.registerArea("area-996364-4", {type: CustomizableUI.TYPE_MENU_PANEL}); 1.52 + CustomizableUI.registerArea("area-996364-4", {type: CustomizableUI.TYPE_TOOLBAR}); 1.53 + } catch (ex) { 1.54 + exceptionThrown = ex; 1.55 + } 1.56 + ok(exceptionThrown, "Exception expected, an area cannot change types: " + (exceptionThrown ? exceptionThrown : "[no exception]")); 1.57 + 1.58 + CustomizableUI.unregisterArea("area-996364-4", true); 1.59 +}); 1.60 + 1.61 +add_task(function() { 1.62 + let exceptionThrown; 1.63 + try { 1.64 + CustomizableUI.registerArea("area-996899-1", { anchor: "PanelUI-menu-button", 1.65 + type: CustomizableUI.TYPE_MENU_PANEL, 1.66 + defaultPlacements: [] }); 1.67 + CustomizableUI.registerArea("area-996899-1", { anchor: "home-button", 1.68 + type: CustomizableUI.TYPE_MENU_PANEL, 1.69 + defaultPlacements: [] }); 1.70 + } catch (ex) { 1.71 + exceptionThrown = ex; 1.72 + } 1.73 + ok(!exceptionThrown, "Changing anchors shouldn't throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); 1.74 + CustomizableUI.unregisterArea("area-996899-1", true); 1.75 +}); 1.76 + 1.77 +add_task(function() { 1.78 + let exceptionThrown; 1.79 + try { 1.80 + CustomizableUI.registerArea("area-996899-2", { anchor: "PanelUI-menu-button", 1.81 + type: CustomizableUI.TYPE_MENU_PANEL, 1.82 + defaultPlacements: [] }); 1.83 + CustomizableUI.registerArea("area-996899-2", { anchor: "PanelUI-menu-button", 1.84 + type: CustomizableUI.TYPE_MENU_PANEL, 1.85 + defaultPlacements: ["feed-button"] }); 1.86 + } catch (ex) { 1.87 + exceptionThrown = ex; 1.88 + } 1.89 + ok(!exceptionThrown, "Changing defaultPlacements shouldn't throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); 1.90 + CustomizableUI.unregisterArea("area-996899-2", true); 1.91 +}); 1.92 + 1.93 +add_task(function() { 1.94 + let exceptionThrown; 1.95 + try { 1.96 + CustomizableUI.registerArea("area-996899-3", { legacy: true }); 1.97 + CustomizableUI.registerArea("area-996899-3", { legacy: false }); 1.98 + } catch (ex) { 1.99 + exceptionThrown = ex; 1.100 + } 1.101 + ok(exceptionThrown, "Changing 'legacy' should throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); 1.102 + CustomizableUI.unregisterArea("area-996899-3", true); 1.103 +}); 1.104 + 1.105 +add_task(function() { 1.106 + let exceptionThrown; 1.107 + try { 1.108 + CustomizableUI.registerArea("area-996899-4", { overflowable: true }); 1.109 + CustomizableUI.registerArea("area-996899-4", { overflowable: false }); 1.110 + } catch (ex) { 1.111 + exceptionThrown = ex; 1.112 + } 1.113 + ok(exceptionThrown, "Changing 'overflowable' should throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); 1.114 + CustomizableUI.unregisterArea("area-996899-4", true); 1.115 +});