Bug 1263784 - Fix test_modal_prompts.html and test_modal_select.html to run under E10S. r=adw draft
authorJustin Dolske <dolske@mozilla.com>
Fri, 15 Apr 2016 13:43:25 -0700
changeset 352163 f9842066a0ad5dde957e1084cdbe3d858b34ea56
parent 352162 8daded4813871ecc8deea2c5543f6c4f52a45542
child 352164 fd30b56983e4d7f7236c66be4ff075fca714b6e8
push id15634
push userjdolske@mozilla.com
push dateFri, 15 Apr 2016 20:44:40 +0000
reviewersadw
bugs1263784
milestone48.0a1
Bug 1263784 - Fix test_modal_prompts.html and test_modal_select.html to run under E10S. r=adw Move all expected-ui state checks into state object. MozReview-Commit-ID: AKV0z4G3R7d
toolkit/components/prompts/test/test_modal_prompts.html
--- a/toolkit/components/prompts/test/test_modal_prompts.html
+++ b/toolkit/components/prompts/test/test_modal_prompts.html
@@ -41,16 +41,25 @@ function checkExpectedState(ui, state, a
     is(ui.checkboxContainer.hidden,   state.checkHidden, "Checking checkbox visibility");
     is(ui.checkbox.label,             state.checkMsg,    "Checking checkbox label");
     is(ui.checkbox.checked,           state.checked,     "Checking checkbox checked");
     if (!isTabModal)
       is(ui.infoIcon.className,       "spaced " + state.iconClass, "Checking expected icon CSS class");
     is(ui.loginTextbox.getAttribute("value"),     state.textValue, "Checking textbox value");
     is(ui.password1Textbox.getAttribute("value"), state.passValue, "Checking passbox value");
 
+    if (state.butt0Label) {
+        is(ui.button0.label, state.butt0Label, "Checking accept-button label");
+    }
+    if (state.butt1Label) {
+        is(ui.button1.label, state.butt1Label, "Checking cancel-button label");
+    }
+    if (state.butt2Label) {
+        is(ui.button2.label, state.butt2Label, "Checking extra1-button label");
+    }
 
     function isDefaultButton(b) {
         return (b.hasAttribute("default") &&
                 b.getAttribute("default") == "true");
     }
 
     let shouldBeDefault;
     shouldBeDefault = SpecialPowers.compare(state.defButton, ui.button0);
@@ -88,16 +97,21 @@ function checkExpectedState(ui, state, a
     if (action.textField) {
         ui.loginTextbox.setAttribute("value", action.textField);
     }
 
     if (action.passField) {
         ui.password1Textbox.setAttribute("value", action.passField);
     }
 
+    if (action.buttonClick == "pollOk") {
+        is(ui.button0.disabled, true,  "Checking accept-button is disabled");
+        is(ui.button1.disabled, false, "Checking cancel-button isn't disabled ");
+    }
+
     switch (action.buttonClick) {
         case "ok":
         case 0:
             ui.button0.click();
             break;
         case "cancel":
         case 1:
             ui.button1.click();
@@ -584,22 +598,22 @@ function handleDialog(ui, testNum) {
             passHidden  : true,
             checkHidden : true,
             textValue   : "",
             passValue   : "",
             checkMsg    : "",
             checked     : false,
             focused     : ui.button0,
             defButton   : ui.button0,
+            butt0Label  : "OK",
+            butt1Label  : "Cancel",
         };
         action = {
             buttonClick: "ok",
         };
-        is(ui.button0.label, "OK",     "Checking accept-button label");
-        is(ui.button1.label, "Cancel", "Checking cancel-button label");
         checkExpectedState(ui, state, action);
         break;
 
       case 21:
         // ConfirmEx (yes/no, cancel)
         state = {
             msg   : "This is the confirmEx text.",
             title : "TestTitle",
@@ -608,22 +622,22 @@ function handleDialog(ui, testNum) {
             passHidden  : true,
             checkHidden : true,
             textValue   : "",
             passValue   : "",
             checkMsg    : "",
             checked     : false,
             focused     : ui.button0,
             defButton   : ui.button0,
+            butt0Label  : "Yes",
+            butt1Label  : "No",
         };
         action = {
             buttonClick: "cancel",
         };
-        is(ui.button0.label, "Yes", "Checking accept-button label");
-        is(ui.button1.label, "No",  "Checking cancel-button label");
         checkExpectedState(ui, state, action);
         break;
 
       case 22:
         // ConfirmEx (buttons from args, checkbox, ok)
         state = {
             msg   : "This is the confirmEx text.",
             title : "TestTitle",
@@ -632,24 +646,24 @@ function handleDialog(ui, testNum) {
             passHidden  : true,
             checkHidden : false,
             textValue   : "",
             passValue   : "",
             checkMsg    : "Check me out!",
             checked     : false,
             focused     : ui.button0,
             defButton   : ui.button0,
+            butt0Label  : "butt0",
+            butt1Label  : "butt1",
+            butt2Label  : "butt2",
         };
         action = {
             buttonClick: "ok",
             setCheckbox: true,
         };
-        is(ui.button0.label, "butt0", "Checking accept-button label");
-        is(ui.button1.label, "butt1", "Checking cancel-button label");
-        is(ui.button2.label, "butt2", "Checking extra1-button label");
         checkExpectedState(ui, state, action);
         break;
 
       case 23:
         // ConfirmEx (buttons from args, checkbox, cancel)
         state = {
             msg   : "This is the confirmEx text.",
             title : "TestTitle",
@@ -658,25 +672,25 @@ function handleDialog(ui, testNum) {
             passHidden  : true,
             checkHidden : false,
             textValue   : "",
             passValue   : "",
             checkMsg    : "Check me out!",
             checked     : false,
             focused     : ui.button1, // Default changed!
             defButton   : ui.button1,
+            butt0Label  : "butt0",
+            butt1Label  : "butt1",
+            butt2Label  : "butt2",
         };
         action = {
             buttonClick: "cancel",
             setCheckbox: true,
         };
         // XXX check button1 is default
-        is(ui.button0.label, "butt0", "Checking accept-button label");
-        is(ui.button1.label, "butt1", "Checking cancel-button label");
-        is(ui.button2.label, "butt2", "Checking extra1-button label");
         checkExpectedState(ui, state, action);
         break;
 
       case 24:
         // ConfirmEx (buttons from args, checkbox, button3)
         state = {
             msg   : "This is the confirmEx text.",
             title : "TestTitle",
@@ -685,25 +699,25 @@ function handleDialog(ui, testNum) {
             passHidden  : true,
             checkHidden : false,
             textValue   : "",
             passValue   : "",
             checkMsg    : "Check me out!",
             checked     : false,
             focused     : ui.button2, // Default changed!
             defButton   : ui.button2,
+            butt0Label  : "butt0",
+            butt1Label  : "butt1",
+            butt2Label  : "butt2",
         };
         action = {
             buttonClick: 2,
             setCheckbox: true,
         };
         // XXX check button2 is default
-        is(ui.button0.label, "butt0", "Checking accept-button label");
-        is(ui.button1.label, "butt1", "Checking cancel-button label");
-        is(ui.button2.label, "butt2", "Checking extra1-button label");
         checkExpectedState(ui, state, action);
         break;
 
       case 25:
         // Alert, null window
         state = {
             msg   : "This is the alert text.",
             title : "TestTitle",
@@ -734,31 +748,28 @@ function handleDialog(ui, testNum) {
             passHidden  : true,
             checkHidden : true,
             textValue   : "",
             passValue   : "",
             checkMsg    : "",
             checked     : false,
             focused     : null, // nothing focused until after delay fires
             defButton   : ui.button0,
+            butt0Label  : "OK",
+            butt1Label  : "Cancel",
         };
 
         // OS X doesn't initially focus the button, but rather the infoBody.
         // The focus stays there even after the button-enable delay has fired.
         if (isOSX)
             state.focused = ui.infoBody;
 
         action = {
             buttonClick: "pollOK",
         };
-
-        is(ui.button0.label, "OK",     "Checking accept-button label");
-        is(ui.button1.label, "Cancel", "Checking cancel-button label");
-        is(ui.button0.disabled, true,  "Checking accept-button is disabled");
-        is(ui.button1.disabled, false, "Checking cancel-button isn't disabled ");
         checkExpectedState(ui, state, action);
         break;
 
 
       case 100:
         // PromptAuth (no realm, ok, with checkbox)
         state = {
             msg : 'Enter username and password for http://example.com',