How to use alert method in autotest

Best Python code snippet using autotest_python

UiAlert.jsx

Source:UiAlert.jsx Github

copy

Full Screen

1import React from "react";2import {3 Alert,4 Col,5 Row,6 Card,7 CardBody,8 CardTitle,9 CardSubtitle,10 UncontrolledAlert,11 Container,12} from "reactstrap";13import { Link } from "react-router-dom";14//Import Breadcrumb15import Breadcrumbs from "../../components/Common/Breadcrumb";16const UiAlert = () => {17 //meta title18 document.title = "Alert | Skote - Vite React Admin & Dashboard Template";19 return (20 <React.Fragment>21 <div className="page-content">22 <Container fluid={true}>23 <Breadcrumbs title="UI Elements" breadcrumbItem="Alerts" />24 <Row>25 <Col lg={6}>26 <Card>27 <CardBody>28 <CardTitle className="mb-2">Default Alerts </CardTitle>29 <CardSubtitle className="mb-4">30 Alerts are available for any length of31 text, as well as an optional dismiss button. For proper styling, use one32 of the four <strong>required</strong> contextual classes (e.g., <code33 >.alert-success</code>). For inline dismissal, use the alerts jQuery plugin.34 </CardSubtitle>35 <div >36 <Alert color="primary">37 A simple primary alert—check it out!38 </Alert>39 <Alert color="secondary" role="alert">40 A simple secondary alert—check it out!41 </Alert>42 <Alert color="success" role="alert">43 A simple success alert—check it out!44 </Alert>45 <Alert color="danger" role="alert">46 A simple danger alert—check it out!47 </Alert>48 <Alert color="warning" role="alert">49 A simple warning alert—check it out!50 </Alert>51 <Alert color="info" className="mb-0" role="alert">52 A simple info alert—check it out!53 </Alert>54 </div>55 </CardBody>56 </Card>57 </Col>58 <Col lg={6}>59 <Card>60 <CardBody>61 <CardTitle className="mb-2">Link color </CardTitle>62 <CardSubtitle className="mb-4">63 Use the{" "}64 <code className="highlighter-rouge">.alert-link</code>{" "}65 utility className to quickly provide matching colored links66 within any alert.67 </CardSubtitle>68 <div >69 <Alert color="primary">70 A simple primary alert with{" "}71 <Link to="#" className="alert-link">72 an example link73 </Link>74 . Give it a click if you like.75 </Alert>76 <Alert color="secondary">77 A simple secondary alert with{" "}78 <Link to="#" className="alert-link">79 an example link80 </Link>81 . Give it a click if you like.82 </Alert>83 <Alert color="success">84 A simple success alert with{" "}85 <Link to="#" className="alert-link">86 an example link87 </Link>88 . Give it a click if you like.89 </Alert>90 <Alert color="danger">91 A simple danger alert with{" "}92 <Link to="#" className="alert-link">93 an example link94 </Link>95 . Give it a click if you like.96 </Alert>97 <Alert color="warning">98 A simple warning alert with{" "}99 <Link to="#" className="alert-link">100 an example link101 </Link>102 . Give it a click if you like.103 </Alert>104 <Alert color="info" className="mb-0">105 A simple info alert with{" "}106 <Link to="#" className="alert-link">107 an example link108 </Link>109 . Give it a click if you like.110 </Alert>111 </div>112 </CardBody>113 </Card>114 </Col>115 </Row>116 <Row>117 <Col lg={6}>118 <Card>119 <CardBody>120 <CardTitle className="mb-2">Dismissing </CardTitle>121 <CardSubtitle className="mb-4">122 Add a dismiss button and the <code>.alert-dismissible</code> class, which adds extra padding123 to the right of the alert and positions the <code>.btn-close</code> button.124 </CardSubtitle>125 <div >126 <UncontrolledAlert color="primary">127 A simple primary alert—check it out!128 </UncontrolledAlert>129 <UncontrolledAlert color="secondary" role="alert">130 A simple secondary alert—check it out!131 </UncontrolledAlert>132 <UncontrolledAlert color="success" role="alert">133 A simple success alert—check it out!134 </UncontrolledAlert>135 <UncontrolledAlert color="danger" role="alert">136 A simple danger alert—check it out!137 </UncontrolledAlert>138 <UncontrolledAlert color="warning" role="alert">139 A simple warning alert—check it out!140 </UncontrolledAlert>141 <UncontrolledAlert142 color="info"143 className="mb-0"144 role="alert"145 >146 A simple info alert—check it out!147 </UncontrolledAlert>148 </div>149 </CardBody>150 </Card>151 </Col>152 <Col lg={6}>153 <Card>154 <CardBody>155 <CardTitle className="mb-4">With Icon </CardTitle>156 <div >157 <UncontrolledAlert158 color="primary"159 className="alert-dismissible fade show"160 role="alert"161 >162 <i className="mdi mdi-bullseye-arrow me-2"></i>A simple163 primary alert—check it out!164 </UncontrolledAlert>165 <UncontrolledAlert166 color="secondary"167 className="alert-dismissible fade show"168 role="alert"169 >170 <i className="mdi mdi-grease-pencil me-2"></i>A simple171 secondary alert—check it out!172 </UncontrolledAlert>173 <UncontrolledAlert174 color="success"175 className="alert-dismissible fade show"176 role="alert"177 >178 <i className="mdi mdi-check-all me-2"></i>A simple success179 alert—check it out!180 </UncontrolledAlert>181 <UncontrolledAlert182 color="danger"183 className="alert-dismissible fade show"184 role="alert"185 >186 <i className="mdi mdi-block-helper me-2"></i>A simple187 danger alert—check it out!188 </UncontrolledAlert>189 <UncontrolledAlert190 color="warning"191 className="alert-dismissible fade show"192 role="alert"193 >194 <i className="mdi mdi-alert-outline me-2"></i>A simple195 warning alert—check it out!196 </UncontrolledAlert>197 <UncontrolledAlert198 color="info"199 className="alert-dismissible fade show mb-0"200 role="alert"201 >202 <i className="mdi mdi-alert-circle-outline me-2"></i>A203 simple info alert—check it out!204 </UncontrolledAlert>205 </div>206 </CardBody>207 </Card>208 </Col>209 </Row>210 <Row>211 <Col xl={6}>212 <Card>213 <CardBody>214 <h4 className="card-title">Additional content</h4>215 <p className="card-title-desc">Alerts can also contain additional HTML elements like headings, paragraphs and dividers.</p>216 <div >217 <Alert className="alert-success" role="alert">218 <h4 className="alert-heading">Well done!</h4>219 <p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so220 that you can see how spacing within an alert works with this kind of content.</p>221 <hr />222 <p className="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>223 </Alert>224 </div>225 </CardBody>226 </Card>227 </Col>228 </Row>229 </Container>230 </div>231 </React.Fragment>232 );233};...

Full Screen

Full Screen

test_modal_dialogs.py

Source:test_modal_dialogs.py Github

copy

Full Screen

...13 Alert(self.marionette).text14 return True15 except errors.NoAlertPresentException:16 return False17 def wait_for_alert(self, timeout=None):18 Wait(self.marionette, timeout=timeout).until(19 lambda _: self.alert_present())20 def wait_for_alert_closed(self, timeout=None):21 Wait(self.marionette, timeout=timeout).until(22 lambda _: not self.alert_present())23class TestTabModalAlerts(BaseAlertTestCase):24 def setUp(self):25 super(TestTabModalAlerts, self).setUp()26 self.assertTrue(self.marionette.get_pref("prompts.tab_modal.enabled",27 "Tab modal alerts should be enabled by default."))28 self.marionette.navigate(self.marionette.absolute_url("test_tab_modal_dialogs.html"))29 def tearDown(self):30 self.marionette.execute_script("window.onbeforeunload = null;")31 # Ensure to close a possible remaining tab modal dialog32 try:33 alert = self.marionette.switch_to_alert()34 alert.dismiss()35 self.wait_for_alert_closed()36 except:37 pass38 super(TestTabModalAlerts, self).tearDown()39 def test_no_alert_raises(self):40 with self.assertRaises(errors.NoAlertPresentException):41 Alert(self.marionette).accept()42 with self.assertRaises(errors.NoAlertPresentException):43 Alert(self.marionette).dismiss()44 def test_alert_accept(self):45 self.marionette.find_element(By.ID, "tab-modal-alert").click()46 self.wait_for_alert()47 alert = self.marionette.switch_to_alert()48 alert.accept()49 def test_alert_dismiss(self):50 self.marionette.find_element(By.ID, "tab-modal-alert").click()51 self.wait_for_alert()52 alert = self.marionette.switch_to_alert()53 alert.dismiss()54 def test_confirm_accept(self):55 self.marionette.find_element(By.ID, "tab-modal-confirm").click()56 self.wait_for_alert()57 alert = self.marionette.switch_to_alert()58 alert.accept()59 self.wait_for_condition(60 lambda mn: mn.find_element(By.ID, "confirm-result").text == "true")61 def test_confirm_dismiss(self):62 self.marionette.find_element(By.ID, "tab-modal-confirm").click()63 self.wait_for_alert()64 alert = self.marionette.switch_to_alert()65 alert.dismiss()66 self.wait_for_condition(67 lambda mn: mn.find_element(By.ID, "confirm-result").text == "false")68 def test_prompt_accept(self):69 self.marionette.find_element(By.ID, "tab-modal-prompt").click()70 self.wait_for_alert()71 alert = self.marionette.switch_to_alert()72 alert.accept()73 self.wait_for_condition(74 lambda mn: mn.find_element(By.ID, "prompt-result").text == "")75 def test_prompt_dismiss(self):76 self.marionette.find_element(By.ID, "tab-modal-prompt").click()77 self.wait_for_alert()78 alert = self.marionette.switch_to_alert()79 alert.dismiss()80 self.wait_for_condition(81 lambda mn: mn.find_element(By.ID, "prompt-result").text == "null")82 def test_alert_opened_before_session_starts(self):83 self.marionette.find_element(By.ID, "tab-modal-alert").click()84 self.wait_for_alert()85 # Restart the session to ensure we still find the formerly left-open dialog.86 self.marionette.delete_session()87 self.marionette.start_session()88 alert = self.marionette.switch_to_alert()89 alert.dismiss()90 def test_alert_text(self):91 with self.assertRaises(errors.NoAlertPresentException):92 alert = self.marionette.switch_to_alert()93 alert.text94 self.marionette.find_element(By.ID, "tab-modal-alert").click()95 self.wait_for_alert()96 alert = self.marionette.switch_to_alert()97 self.assertEqual(alert.text, "Marionette alert")98 alert.accept()99 def test_prompt_text(self):100 with self.assertRaises(errors.NoAlertPresentException):101 alert = self.marionette.switch_to_alert()102 alert.text103 self.marionette.find_element(By.ID, "tab-modal-prompt").click()104 self.wait_for_alert()105 alert = self.marionette.switch_to_alert()106 self.assertEqual(alert.text, "Marionette prompt")107 alert.accept()108 def test_confirm_text(self):109 with self.assertRaises(errors.NoAlertPresentException):110 alert = self.marionette.switch_to_alert()111 alert.text112 self.marionette.find_element(By.ID, "tab-modal-confirm").click()113 self.wait_for_alert()114 alert = self.marionette.switch_to_alert()115 self.assertEqual(alert.text, "Marionette confirm")116 alert.accept()117 def test_set_text_throws(self):118 with self.assertRaises(errors.NoAlertPresentException):119 Alert(self.marionette).send_keys("Foo")120 self.marionette.find_element(By.ID, "tab-modal-alert").click()121 self.wait_for_alert()122 alert = self.marionette.switch_to_alert()123 with self.assertRaises(errors.ElementNotInteractableException):124 alert.send_keys("Foo")125 alert.accept()126 def test_set_text_accept(self):127 self.marionette.find_element(By.ID, "tab-modal-prompt").click()128 self.wait_for_alert()129 alert = self.marionette.switch_to_alert()130 alert.send_keys("Some text!")131 alert.accept()132 self.wait_for_condition(133 lambda mn: mn.find_element(By.ID, "prompt-result").text == "Some text!")134 def test_set_text_dismiss(self):135 self.marionette.find_element(By.ID, "tab-modal-prompt").click()136 self.wait_for_alert()137 alert = self.marionette.switch_to_alert()138 alert.send_keys("Some text!")139 alert.dismiss()140 self.wait_for_condition(141 lambda mn: mn.find_element(By.ID, "prompt-result").text == "null")142 def test_onbeforeunload_dismiss(self):143 start_url = self.marionette.get_url()144 self.marionette.find_element(By.ID, "onbeforeunload-handler").click()145 self.wait_for_condition(146 lambda mn: mn.execute_script("""147 return window.onbeforeunload !== null;148 """))149 self.marionette.navigate("about:blank")150 self.wait_for_alert()151 alert = self.marionette.switch_to_alert()152 self.assertTrue(alert.text.startswith("This page is asking you to confirm"))153 alert.dismiss()154 self.assertTrue(self.marionette.get_url().startswith(start_url))155 def test_onbeforeunload_accept(self):156 self.marionette.find_element(By.ID, "onbeforeunload-handler").click()157 self.wait_for_condition(158 lambda mn: mn.execute_script("""159 return window.onbeforeunload !== null;160 """))161 self.marionette.navigate("about:blank")162 self.wait_for_alert()163 alert = self.marionette.switch_to_alert()164 self.assertTrue(alert.text.startswith("This page is asking you to confirm"))165 alert.accept()166 self.wait_for_condition(lambda mn: mn.get_url() == "about:blank")167 def test_unrelated_command_when_alert_present(self):168 self.marionette.find_element(By.ID, "tab-modal-alert").click()169 self.wait_for_alert()170 with self.assertRaises(errors.UnexpectedAlertOpen):171 self.marionette.find_element(By.ID, "click-result")172class TestModalAlerts(BaseAlertTestCase):173 def setUp(self):174 super(TestModalAlerts, self).setUp()175 def tearDown(self):176 # Ensure to close a possible remaining modal dialog177 self.close_all_windows()178 super(TestModalAlerts, self).tearDown()179 def test_http_auth_dismiss(self):180 self.marionette.navigate(self.marionette.absolute_url("http_auth"))181 self.wait_for_alert(timeout=self.marionette.timeout.page_load)182 alert = self.marionette.switch_to_alert()183 alert.dismiss()184 self.wait_for_alert_closed()185 status = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(186 element_present(By.ID, "status")187 )188 self.assertEqual(status.text, "restricted")189 def test_alert_opened_before_session_starts(self):190 self.marionette.navigate(self.marionette.absolute_url("http_auth"))191 self.wait_for_alert(timeout=self.marionette.timeout.page_load)192 # Restart the session to ensure we still find the formerly left-open dialog.193 self.marionette.delete_session()194 self.marionette.start_session()195 alert = self.marionette.switch_to_alert()196 alert.dismiss()...

Full Screen

Full Screen

alerts.js

Source:alerts.js Github

copy

Full Screen

1import alertsData from '../lib/alerts/index.jsx';2import {AlertTypes, AlertLevels} from '../lib/alerts/index.jsx';3import extensionData from '../lib/libraries/extensions/index.jsx';4const SHOW_ALERT = 'scratch-gui/alerts/SHOW_ALERT';5const SHOW_EXTENSION_ALERT = 'scratch-gui/alerts/SHOW_EXTENSION_ALERT';6const CLOSE_ALERT = 'scratch-gui/alerts/CLOSE_ALERT';7const CLOSE_ALERTS_WITH_ID = 'scratch-gui/alerts/CLOSE_ALERTS_WITH_ID';8const CLOSE_ALERT_WITH_ID = 'scratch-gui/alerts/CLOSE_ALERT_WITH_ID';9/**10 * Initial state of alerts reducer11 *12 * {bool} visible - whether the alerts are visible13 * {array} alertsList - list of alerts, each with properties:14 * * alertType (required): one of AlertTypes15 * * closeButton (optional): bool indicating that we should show close button16 * * content (optional): react element (a <FormattedMessage />)17 * * extentionId (optional): id string that identifies the extension18 * * iconURL (optional): string19 * * level (required): string, one of AlertLevels20 * * message (optional): string21 * * showReconnect (optional): bool22 */23const initialState = {24 visible: true,25 alertsList: []26};27const filterPopupAlerts = alertsList => (28 alertsList.filter(curAlert => (29 curAlert.alertType === AlertTypes.STANDARD ||30 curAlert.alertType === AlertTypes.EXTENSION31 ))32);33const filterInlineAlerts = alertsList => (34 alertsList.filter(curAlert => (35 curAlert.alertType === AlertTypes.INLINE36 ))37);38const reducer = function (state, action) {39 if (typeof state === 'undefined') state = initialState;40 switch (action.type) {41 case SHOW_ALERT: { // intended to show standard and inline alerts, but not extensions42 const alertId = action.alertId;43 if (alertId) {44 const newAlert = {45 alertId: alertId,46 level: AlertLevels.WARN // default level47 };48 const alertData = alertsData.find(thisAlertData => thisAlertData.alertId === alertId);49 if (alertData) {50 const newList = state.alertsList.filter(curAlert => (51 !alertData.clearList || alertData.clearList.indexOf(curAlert.alertId) === -152 ));53 if (action.data && action.data.message) {54 newAlert.message = action.data.message;55 }56 newAlert.alertType = alertData.alertType || AlertTypes.STANDARD;57 newAlert.closeButton = alertData.closeButton;58 newAlert.content = alertData.content;59 newAlert.iconURL = alertData.iconURL;60 newAlert.iconSpinner = alertData.iconSpinner;61 newAlert.level = alertData.level;62 newAlert.showDownload = alertData.showDownload;63 newAlert.showSaveNow = alertData.showSaveNow;64 newList.push(newAlert);65 return Object.assign({}, state, {66 alertsList: newList67 });68 }69 }70 return state; // if alert not found, show nothing71 }72 case SHOW_EXTENSION_ALERT: {73 const extensionId = action.data.extensionId;74 if (extensionId) {75 const extension = extensionData.find(ext => ext.extensionId === extensionId);76 if (extension) {77 const newList = state.alertsList.slice();78 const newAlert = {79 alertType: AlertTypes.EXTENSION,80 closeButton: true,81 extensionId: extensionId,82 extensionName: extension.name,83 iconURL: extension.connectionSmallIconURL,84 level: AlertLevels.WARN,85 showReconnect: true86 };87 newList.push(newAlert);88 return Object.assign({}, state, {89 alertsList: newList90 });91 }92 }93 return state; // if alert not found, show nothing94 }95 case CLOSE_ALERT_WITH_ID:96 case CLOSE_ALERT: {97 if (action.alertId) {98 action.index = state.alertsList.findIndex(a => a.alertId === action.alertId);99 if (action.index === -1) return state;100 }101 const newList = state.alertsList.slice();102 newList.splice(action.index, 1);103 return Object.assign({}, state, {104 alertsList: newList105 });106 }107 case CLOSE_ALERTS_WITH_ID: {108 return Object.assign({}, state, {109 alertsList: state.alertsList.filter(curAlert => (110 curAlert.alertId !== action.alertId111 ))112 });113 }114 default:115 return state;116 }117};118/**119 * Action creator to close an alert with the given index.120 *121 * @param {object} index - the index of the alert to close.122 * @return {object} - an object to be passed to the reducer.123 */124const closeAlert = function (index) {125 return {126 type: CLOSE_ALERT,127 index128 };129};130/**131 * Action creator to close all alerts with a given ID.132 *133 * @param {string} alertId - id string of the alert to close134 * @return {object} - an object to be passed to the reducer.135 */136const closeAlertsWithId = function (alertId) {137 return {138 type: CLOSE_ALERTS_WITH_ID,139 alertId140 };141};142/**143 * Action creator to close a single alert with a given ID.144 *145 * @param {string} alertId - id string of the alert to close146 * @return {object} - an object to be passed to the reducer.147 */148const closeAlertWithId = function (alertId) {149 return {150 type: CLOSE_ALERT_WITH_ID,151 alertId152 };153};154/**155 * Action creator to show an alert with the given alertId.156 *157 * @param {string} alertId - id string of the alert to show158 * @return {object} - an object to be passed to the reducer.159 */160const showStandardAlert = function (alertId) {161 return {162 type: SHOW_ALERT,163 alertId164 };165};166/**167 * Action creator to show an alert with the given input data.168 *169 * @param {object} data - data for the alert170 * @param {string} data.message - message for the alert171 * @param {string} data.extensionId - extension ID for the alert172 * @return {object} - an object to be passed to the reducer.173 */174const showExtensionAlert = function (data) {175 return {176 type: SHOW_EXTENSION_ALERT,177 data178 };179};180/**181 * Function to dispatch showing an alert, with optional182 * timeout to make it close/go away.183 *184 * @param {object} dispatch - dispatch function185 * @param {string} alertId - the ID of the alert186 */187const showAlertWithTimeout = function (dispatch, alertId) {188 const alertData = alertsData.find(thisAlertData => thisAlertData.alertId === alertId);189 if (alertData) {190 dispatch(showStandardAlert(alertId));191 if (alertData.maxDisplaySecs) {192 setTimeout(() => {193 dispatch(closeAlertsWithId(alertId));194 }, alertData.maxDisplaySecs * 1000);195 }196 }197};198export {199 reducer as default,200 initialState as alertsInitialState,201 closeAlert,202 closeAlertWithId,203 filterInlineAlerts,204 filterPopupAlerts,205 showAlertWithTimeout,206 showExtensionAlert,207 showStandardAlert...

Full Screen

Full Screen

alert.js

Source:alert.js Github

copy

Full Screen

1// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-2/* This Source Code Form is subject to the terms of the Mozilla Public3 * License, v. 2.0. If a copy of the MPL was not distributed with this4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */5Components.utils.import("resource://gre/modules/Services.jsm");6const Ci = Components.interfaces;7const Cc = Components.classes;8var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]9 .getService(Ci.nsIWindowMediator);10// Copied from nsILookAndFeel.h, see comments on eMetric_AlertNotificationOrigin11const NS_ALERT_HORIZONTAL = 1;12const NS_ALERT_LEFT = 2;13const NS_ALERT_TOP = 4;14const WINDOW_MARGIN = 10;15var gOrigin = 0; // Default value: alert from bottom right.16var gReplacedWindow = null;17var gAlertListener = null;18var gAlertTextClickable = false;19var gAlertCookie = "";20var gIsReplaced = false;21function prefillAlertInfo() {22 // unwrap all the args....23 // arguments[0] --> the image src url24 // arguments[1] --> the alert title25 // arguments[2] --> the alert text26 // arguments[3] --> is the text clickable?27 // arguments[4] --> the alert cookie to be passed back to the listener28 // arguments[5] --> the alert origin reported by the look and feel29 // arguments[6] --> bidi30 // arguments[7] --> lang31 // arguments[8] --> replaced alert window (nsIDOMWindow)32 // arguments[9] --> an optional callback listener (nsIObserver)33 switch (window.arguments.length) {34 default:35 case 10:36 gAlertListener = window.arguments[9];37 case 9:38 gReplacedWindow = window.arguments[8];39 case 6:40 gOrigin = window.arguments[5];41 case 5:42 gAlertCookie = window.arguments[4];43 case 4:44 gAlertTextClickable = window.arguments[3];45 if (gAlertTextClickable) {46 document.getElementById('alertNotification').setAttribute('clickable', true);47 document.getElementById('alertTextLabel').setAttribute('clickable', true);48 }49 case 3:50 document.getElementById('alertTextLabel').textContent = window.arguments[2];51 case 2:52 document.getElementById('alertTitleLabel').setAttribute('value', window.arguments[1]);53 case 1:54 if (window.arguments[0]) {55 document.getElementById('alertImage').setAttribute('src', window.arguments[0]);56 }57 case 0:58 break;59 }60}61function onAlertLoad() {62 const ALERT_DURATION_IMMEDIATE = 4000;63 let alertTextBox = document.getElementById("alertTextBox");64 let alertImageBox = document.getElementById("alertImageBox");65 alertImageBox.style.minHeight = alertTextBox.scrollHeight + "px";66 sizeToContent();67 if (gReplacedWindow && !gReplacedWindow.closed) {68 moveWindowToReplace(gReplacedWindow);69 gReplacedWindow.gIsReplaced = true;70 gReplacedWindow.close();71 } else {72 moveWindowToEnd();73 }74 window.addEventListener("XULAlertClose", function() { window.close(); });75 if (Services.prefs.getBoolPref("alerts.disableSlidingEffect")) {76 setTimeout(function() { window.close(); }, ALERT_DURATION_IMMEDIATE);77 return;78 }79 let alertBox = document.getElementById("alertBox");80 alertBox.addEventListener("animationend", function hideAlert(event) {81 if (event.animationName == "alert-animation") {82 alertBox.removeEventListener("animationend", hideAlert, false);83 window.close();84 }85 }, false);86 alertBox.setAttribute("animate", true);87 if (gAlertListener) {88 gAlertListener.observe(null, "alertshow", gAlertCookie);89 }90}91function moveWindowToReplace(aReplacedAlert) {92 let heightDelta = window.outerHeight - aReplacedAlert.outerHeight;93 // Move windows that come after the replaced alert if the height is different.94 if (heightDelta != 0) {95 let windows = windowMediator.getEnumerator('alert:alert');96 while (windows.hasMoreElements()) {97 let alertWindow = windows.getNext();98 // boolean to determine if the alert window is after the replaced alert.99 let alertIsAfter = gOrigin & NS_ALERT_TOP ?100 alertWindow.screenY > aReplacedAlert.screenY :101 aReplacedAlert.screenY > alertWindow.screenY;102 if (alertIsAfter) {103 // The new Y position of the window.104 let adjustedY = gOrigin & NS_ALERT_TOP ?105 alertWindow.screenY + heightDelta :106 alertWindow.screenY - heightDelta;107 alertWindow.moveTo(alertWindow.screenX, adjustedY);108 }109 }110 }111 let adjustedY = gOrigin & NS_ALERT_TOP ? aReplacedAlert.screenY :112 aReplacedAlert.screenY - heightDelta;113 window.moveTo(aReplacedAlert.screenX, adjustedY);114}115function moveWindowToEnd() {116 // Determine position117 let x = gOrigin & NS_ALERT_LEFT ? screen.availLeft :118 screen.availLeft + screen.availWidth - window.outerWidth;119 let y = gOrigin & NS_ALERT_TOP ? screen.availTop :120 screen.availTop + screen.availHeight - window.outerHeight;121 // Position the window at the end of all alerts.122 let windows = windowMediator.getEnumerator('alert:alert');123 while (windows.hasMoreElements()) {124 let alertWindow = windows.getNext();125 if (alertWindow != window) {126 if (gOrigin & NS_ALERT_TOP) {127 y = Math.max(y, alertWindow.screenY + alertWindow.outerHeight);128 } else {129 y = Math.min(y, alertWindow.screenY - window.outerHeight);130 }131 }132 }133 // Offset the alert by WINDOW_MARGIN pixels from the edge of the screen134 y += gOrigin & NS_ALERT_TOP ? WINDOW_MARGIN : -WINDOW_MARGIN;135 x += gOrigin & NS_ALERT_LEFT ? WINDOW_MARGIN : -WINDOW_MARGIN;136 window.moveTo(x, y);137}138function onAlertBeforeUnload() {139 if (!gIsReplaced) {140 // Move other alert windows to fill the gap left by closing alert.141 let heightDelta = window.outerHeight + WINDOW_MARGIN;142 let windows = windowMediator.getEnumerator('alert:alert');143 while (windows.hasMoreElements()) {144 let alertWindow = windows.getNext();145 if (alertWindow != window) {146 if (gOrigin & NS_ALERT_TOP) {147 if (alertWindow.screenY > window.screenY) {148 alertWindow.moveTo(alertWindow.screenX, alertWindow.screenY - heightDelta);149 }150 } else {151 if (window.screenY > alertWindow.screenY) {152 alertWindow.moveTo(alertWindow.screenX, alertWindow.screenY + heightDelta);153 }154 }155 }156 }157 }158 if (gAlertListener) {159 gAlertListener.observe(null, "alertfinished", gAlertCookie);160 }161}162function onAlertClick() {163 if (gAlertListener && gAlertTextClickable) {164 gAlertListener.observe(null, "alertclickcallback", gAlertCookie);165 }166 window.close();...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful