Closed Bug 666223 Opened 14 years ago Closed 14 years ago

Add method to retrieve the value of an element's CSS property

Categories

(Mozilla QA Graveyard :: Mozmill Tests, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: vladmaniac, Assigned: vladmaniac)

References

Details

(Whiteboard: [lib])

Attachments

(2 files, 3 obsolete files)

We must add a function in utils.js to have getComputedStyle(element)
Assignee: nobody → vlad.maniac
Status: NEW → ASSIGNED
A Pivotal Tracker story has been created for this Bug: https://www.pivotaltracker.com/story/show/14876971
Blocks: 664691
OS: Linux → All
Hardware: x86 → All
Summary: Update utils.js with getComputedStyle() → Add method to retrieve the value of an element's CSS property
Whiteboard: [shared module]
Attached patch patch v1.0 (obsolete) — Splinter Review
Asking for r from Henrik since he requested this patch
Attachment #541355 - Flags: review?(hskupin)
Comment on attachment 541355 [details] [diff] [review] patch v1.0 >+ * @param {MozmillController} controller >+ * MozMillController of the window to operate on We don't need the controller as paramter here. You can use el.ownerDocument.defaultView to get the window. >+ * @return value of the CSS property >+ * @type string This can be a single line: @return {String} Description >+function getCSSValue(controller, aElement, aProperty) { Can we rename this function to getElementStyle? >+ var el = aElement.getNode(); How does getComputedStyle handle a null element? >+ return controller.window.getComputedStyle(el, null).getPropertyValue(aProperty); There is no need to have the 2nd parameter to getComputedStyle specified: https://developer.mozilla.org/en/DOM/window.getComputedStyle#Syntax Also please ensure it will fit into the 80 chars limit.
Attachment #541355 - Flags: review?(hskupin) → review-
Attached patch patch v1.1 (obsolete) — Splinter Review
Attachment #541355 - Attachment is obsolete: true
Attachment #542135 - Flags: review?(hskupin)
Comment on attachment 542135 [details] [diff] [review] patch v1.1 >+function getElementStyle(aElement, aProperty) { >+ var el = aElement.getNode(); >+ var elementStyle = el.ownerDocument.defaultView.getComputedStyle(el); You will have to handle the null case of el. In those cases we have to throw a reasonable exception. Also something I forgot last time, please check existing tests which make use of getComputedStyle, so we directly have tests for that API addition.
Attachment #542135 - Attachment is patch: true
Attachment #542135 - Flags: review?(hskupin) → review-
Attached patch patch v1.2Splinter Review
Patch with requested changes
Attachment #542135 - Attachment is obsolete: true
Attachment #542459 - Flags: review?(hskupin)
Comment on attachment 542459 [details] [diff] [review] patch v1.2 Code-wise it's fine but please include the patches for existing tests which can make use of this new API. There are a couple of those.
Attachment #542459 - Flags: review?(hskupin) → review+
Attached patch patch_with_tests v1.0 (obsolete) — Splinter Review
This include modifications in testBlueLarry.js and testGreenLarry.js from /tests/functional/testSecurity
Attachment #542788 - Flags: review?(hskupin)
Comment on attachment 542788 [details] [diff] [review] patch_with_tests v1.0 >+/** >+ * Returns the value of a CSS Property for a specific Element >+ * >+ * @param {ElemBase} aElement >+ * Element to get its property >+ * @param {String} aProperty >+ * Property name to be retrieved >+ * >+ * @return {String} value of the CSS property Nit: please check the capitalization of some of the doc items, i.e. Property, Element, and value. >- var cssInfoLockImage = controller.window.getComputedStyle(lockIcon.getNode(), ""); >- controller.assertJS("subject.getPropertyValue('list-style-image') != 'none'", cssInfoLockImage); >+ var cssInfoLockImage = utils.getElementStyle(lockIcon, 'list-style-image'); >+ >+ controller.assert(function () { >+ return cssInfoLockImage !== 'none'; >+ }, "There is a lock icon - got '" + >+ (cssInfoLockImage !== 'none') + "', expected 'true'."); Lets do the comparison only once, so we can also get the message in a single line too. Please update those parts, otherwise it looks fine.
Attachment #542788 - Flags: review?(hskupin) → review+
Attachment #542788 - Attachment is obsolete: true
Attachment #542841 - Flags: review?(hskupin)
Comment on attachment 542841 [details] [diff] [review] patch_with_tests v1.1 > exports.formatUrl = formatUrl; > exports.formatUrlPref = formatUrlPref; > exports.emptyClipboard = emptyClipboard; > exports.getDefaultHomepage = getDefaultHomepage; > exports.getEntity = getEntity; > exports.getProperty = getProperty; > exports.handleWindow = handleWindow; > exports.removePermission = removePermission; >+exports.getElementStyle = getElementStyle; Please always keep the sorting order and do not add lines at the end of the export list. I will update it right before check-in. Otherwise looks fine and works as expected. Sorry for the delay. Somehow it fell off my radar.
Attachment #542841 - Flags: review?(hskupin) → review+
Component: Mozmill Tests → Mozmill Shared Modules
Component: Mozmill Shared Modules → Mozmill Tests
Whiteboard: [shared module] → [lib]
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: