Closed
Bug 508670
Opened 16 years ago
Closed 16 years ago
[mozmill] Test for checking the warning when submitting unencrypted info
Categories
(Mozilla QA Graveyard :: Mozmill Tests, defect)
Mozilla QA Graveyard
Mozmill Tests
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: u279076, Assigned: u279076)
References
Details
Attachments
(1 file, 2 obsolete files)
8.11 KB,
patch
|
whimboo
:
review+
aakashd
:
review+
|
Details | Diff | Splinter Review |
This is a placeholder bug for creating a Mozmill test script for https://litmus.mozilla.org/show_test.cgi?id=7678 - Warn about submitting unencrypted information
Attachment #396019 -
Flags: review?
Attachment #396019 -
Flags: review? → review?(adesai)
Updated•16 years ago
|
Attachment #396019 -
Flags: review?(adesai) → review-
Comment 2•16 years ago
|
||
Comment on attachment 396019 [details] [diff] [review]
Initial patch
>+/**
>+ * Litmus test #7678: Submit unencrypted info warning [1.9.1]
>+ * Litmus test #9295: Submit unencrypted info warning [1.9.2]
>+ */
Remember to put these on top of each test module from now on :)
>+var teardownModule = function(module) {
>+ try {
>+ // Reset the warning prefs
>+ var prefs = new Array("security.warn_entering_secure",
>+ "security.warn_entering_weak",
>+ "security.warn_leaving_secure",
>+ "security.warn_submit_insecure",
>+ "security.warn_viewing_mixed");
>+ for each (p in prefs) {
>+ PrefsAPI.preferences.branch.clearUserPref(p);
>+ }
>+ } catch(e) {
>+ }
We're going to be moving away from try/catch statements, so be mindful about using them. Ask whimboo for the new implementation.
>+ controller.waitThenClick(new elementslib.ID(controller.tabs.activeTab, "searchbutton"));
You don't need to waiThenClick as click will work just as well.
>+ var pane = new elementslib.Lookup(controller.window.document,
>+ '/id("BrowserPreferences")/anon({"orient":"vertical"})/' +
>+ 'anon({"anonid":"selector"})/{"pane":"paneSecurity"}');
>+ controller.waitThenClick(pane);
>+ controller.sleep(gDelay);
>+
>+ // Create a listener for the Warning Messages Settings dialog
>+ var md = new ModalDialogAPI.modalDialog(handleSecurityWarningSettingsDialog);
>+ md.start();
>+
>+ // Click the Warning Messages Settings button
>+ controller.click(new elementslib.ID(controller.window.document, "warningSettings"));
>+ controller.sleep(gDelay);
>+
Take out both sleeps and use waitThenClick instead as this is causing a failure on command line runs.
>+ // Make sure the "encrypted page" pref is checked
>+ for each (p in prefs) {
>+ var element = new elementslib.ID(controller.window.document, p);
>+ controller.sleep(gDelay);
>+ // Check the "submit unencrypted info" pref if it isn't already
>+ if (p == "warn_submit_insecure") {
>+ if (!element.getNode().checked) {
>+ controller.click(element);
>+ }
>+ // Uncheck all other prefs
>+ } else {
>+ if (element.getNode().checked) {
>+ controller.click(element);
Can waitThenClick 's work instead of using sleep(gDelay)?
>+ // Verify the message text
>+ controller.assertProperty(new elementslib.ID(controller.window.document, "info.body"),
>+ "textContent",
>+ "The information you have entered is to be sent over an unencrypted " +
>+ "connection and could easily be read by a third party.\n\n" +
>+ "Are you sure you want to continue sending this information?");
>+
Just like the review in bug 508669, use something other than comparing literal text due to localization issues.
>+ '{"dlgtype":"accept","xbl:inherits":"disabled=buttondisabledaccept",' +
>+ '"icon":"accept","default":"true"}'));
>+}
Also, just like the review in bug 508669, remove everything after "dlgtype":"accept"
Attachment #396019 -
Attachment is obsolete: true
Attachment #396919 -
Flags: review?(adesai)
Comment 4•16 years ago
|
||
Comment on attachment 396919 [details] [diff] [review]
Rev1
Looks great and testscripts passed via IDE and command line on OSX.
Attachment #396919 -
Flags: review?(adesai) → review+
Comment on attachment 396919 [details] [diff] [review]
Rev1
Pushing over to Henrik for additional review
Attachment #396919 -
Flags: review?(hskupin)
Updated•16 years ago
|
Attachment #396919 -
Flags: review?(hskupin) → review-
Comment 6•16 years ago
|
||
Comment on attachment 396919 [details] [diff] [review]
Rev1
This test fails for me when I run it from the command line on Windows. See the two errors below:
ERROR - Test Failure: {'function': {'message': 'element.getNode() is null', 'lin
eNumber': 151, 'stack': '([object Object])@file:///c:/docume~1/mozilla/locals~1/
ERROR - Test Failure: {'function': {'message': 'timeout exceeded for waitForElem
ent ID: warningSettings', 'lineNumber': 306, 'stack': 'Error("timeout exceeded f
or waitForElement ID: warningSettings")@:0\n([object Object],(void 0),(void 0))@
>+var teardownModule = function(module) {
>+ try {
>+ // Reset the warning prefs
>+ var prefs = new Array("security.warn_entering_secure",
>+ "security.warn_entering_weak",
>+ "security.warn_leaving_secure",
>+ "security.warn_submit_insecure",
>+ "security.warn_viewing_mixed");
>+ for each (p in prefs) {
>+ PrefsAPI.preferences.branch.clearUserPref(p);
>+ }
>+ } catch(e) {
>+ }
Please create two final patches for 1.9.1 and trunk. For 1.9.1 please move the try/catch block directly around the clearUserPref call. Otherwise later prefs will not be reset. Which of those prefs are set at all during your test run?
>+ // Close the page because the warnings don't appear if you are on the page
>+ // where the warning was triggered
>+ UtilsAPI.closeAllTabs(controller);
Then that should be in setupModule.
>+ PrefsAPI.handlePreferencesDialog(prefDialogCallback);
Can you please move to the new preferencesDialog API?
>+ controller.waitThenClick(new elementslib.ID(controller.tabs.activeTab, "searchbutton"));
You can click immediately. No need to wait. If you will have a wait function somewhere else please remind on putting a gTimeout value in.
>+/**
>+ * Call-back handler for preferences dialog
>+ */
Can you add the @param parameter? Just c&p it.
>+ var pane = new elementslib.Lookup(controller.window.document,
>+ '/id("BrowserPreferences")/anon({"orient":"vertical"})/' +
>+ 'anon({"anonid":"selector"})/{"pane":"paneSecurity"}');
>+ controller.waitThenClick(pane);
Please replace those lines with PrefsAPI.preferencesDialog.setPane.
>+ // Click the Warning Messages Settings button
>+ controller.waitThenClick(new elementslib.ID(controller.window.document, "warningSettings"));
That's one of the errors above. Please check if the new pref dialog API solves this problem.
>+ // Close the preferences dialog
>+ if (mozmill.isWindows) {
>+ okButton = new elementslib.Lookup(controller.window.document,
>+ '/id("BrowserPreferences")/anon({"anonid":"dlg-buttons"})/{"dlgtype":"accept"}');
>+ controller.click(okButton);
>+ } else {
>+ controller.keypress(null, 'VK_ESCAPE', {});
>+ }
That block can be replaced by PrefsAPI.preferencesDialog.close
>+ var prefs = new Array("warn_entering_secure",
>+ "warn_entering_weak",
nit: indentation
>+ // Make sure the "encrypted page" pref is checked
>+ for each (p in prefs) {
>+ var element = new elementslib.ID(controller.window.document, p);
>+
>+ // Check the "submit unencrypted info" pref if it isn't already
>+ if (p == "warn_submit_insecure") {
>+ if (!element.getNode().checked) {
>+ controller.waitThenClick(element);
>+ }
>+ // Uncheck all other prefs
>+ } else {
>+ if (element.getNode().checked) {
>+ controller.waitThenClick(element);
>+ }
>+ }
>+ }
Can you please use click without a wait?
>+ // Get the message text
>+ var message = UtilsAPI.getProperty("chrome://pipnss/locale/security.properties","PostToInsecureFromInsecureMessage");
nit: please wrap the property name to the next line.
>+ // Strip any "#" from the string and replace them with \n
>+ // XXX: For whatever reason string.replace does not work here
>+ message = message.substring(0, message.length-2);
>+ message = message.substring(0, message.indexOf('#')) + "\n\n" +
>+ message.substring(message.lastIndexOf('#')+1, message.length);
Why did replace not work?
>+ // Verify the message text
>+ controller.assertProperty(new elementslib.ID(controller.window.document, "info.body"),
>+ "textContent", message);
Please use the element from above.
>+ // Click the OK button
>+ controller.waitThenClick(new elementslib.Lookup(controller.window.document,
>+ '/id("commonDialog")/anon({"anonid":"buttons"})/{"dlgtype":"accept"}'));
No need to wait. Please click immediately. Separating into two lines would be nice.
Comment 7•16 years ago
|
||
CC'ing Aakash for reference.
Here is the second revision. I've incorporated some of the additional revisions made in bug 508669. Hopefully this accelerates the review process of this patch.
NOTE: I've only been able to test this on Windows. I don't have access to Mac or Linux ATM. Please run verifications.
Attachment #396919 -
Attachment is obsolete: true
Attachment #404052 -
Flags: review?(hskupin)
Attachment #404052 -
Flags: review?(adesai)
Comment 9•16 years ago
|
||
Comment on attachment 404052 [details] [diff] [review]
Rev2
Looks good and this runs (and passes!) on Fx/Namoroka over XP and OSX. The coding conventions looks good too. So, it's a + from my side.
Attachment #404052 -
Flags: review?(adesai) → review+
Comment 10•16 years ago
|
||
Comment on attachment 404052 [details] [diff] [review]
Rev2
>+ // Create a listener for the warning dialog
>+ var md = new ModalDialogAPI.modalDialog(handleSecurityWarningDialog);
>+ md.start();
>+
>+ // Load an unencrypted page
>+ controller.open("http://www.verisign.com");
>+ controller.waitForPageLoad();
>+
>+ // Get the web page's search box
>+ var searchbox = new elementslib.ID(controller.tabs.activeTab, "searchtext");
>+ controller.waitForElement(searchbox);
>+
>+ // Use the web page search box to submit information
>+ controller.type(searchbox, "mozilla");
The modal dialog listener is created too early as expected. But that's the right way though. If we fail and also display a modal dialog on page load the test will fail due to the element checks in the dialog.
>+ controller.waitThenClick(searchButton);
All wait functions should get the gTimeout value as parameter. I have also updated the missing ones in the encrypted page warning test.
>+ controller.waitForElement(warningSettingsButton, gTimeout);
>+
>+ // Create a listener for the Warning Messages Settings dialog
>+ var md = new ModalDialogAPI.modalDialog(handleSecurityWarningSettingsDialog);
>+ md.start(500);
>+
>+ // Click the Warning Messages Settings button
>+ controller.waitThenClick(warningSettingsButton);
The 2nd wait can be a simple click.
>+ for each (p in prefs) {
>+ var element = new elementslib.ID(controller.window.document, p);
>+ controller.waitForElement(element, gTimeout);
>+
>+ // Check the "submit unencrypted info" pref if it isn't already
>+ if (p == "warn_submit_insecure") {
>+ if (!element.getNode().checked) {
>+ controller.waitThenClick(element);
Same here.
>+ // The message string contains "##" instead of \n for newlines.
>+ // There are two instances in the string. Replace them both.
>+ message = message.replace(/##/g, "\n\n");
>+
>+ /*
>+ message = message.substring(0, message.length-2);
>+ message = message.substring(0, message.indexOf('#')) + "\n\n" +
>+ message.substring(message.lastIndexOf('#')+1, message.length);
>+ */
Ok, so you got it working with multiple replacement. Was that the problem you mentioned 1 or 2 weeks ago? I have removed the commented out lines.
Otherwise I had to remove a lot of tab characters. Anthony, you should tell your editor to always use blanks instead of tabs.
Attachment #404052 -
Flags: review?(hskupin) → review+
Comment 11•16 years ago
|
||
Landed as:
http://hg.mozilla.org/qa/mozmill-tests/rev/ebbe2997b25f
http://hg.mozilla.org/qa/mozmill-tests/rev/86d1df3317cf
Thanks Anthony! That was the last one of the security subgroup.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment 12•15 years ago
|
||
Mass move of Mozmill Test related project bugs to newly created components. You can filter out those emails by using "Mozmill-Tests-to-MozillaQA" as criteria.
Component: Security → Mozmill Tests
Product: Firefox → Mozilla QA
QA Contact: firefox → mozmill-tests
Updated•6 years ago
|
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•