add head.js and cleanup functions to browser chrome tests

RESOLVED FIXED in mozilla1.9.3a1

Status

Testing
Mochitest
RESOLVED FIXED
9 years ago
3 months ago

People

(Reporter: ddahl, Assigned: mak)

Tracking

({dev-doc-complete})

Trunk
mozilla1.9.3a1
dev-doc-complete
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 4 obsolete attachments)

(Reporter)

Description

9 years ago
It would be nice to have a module or head.js for browser chrome testing, for instance all places tests would want to call this function on end:


var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
         getService(Ci.nsINavHistoryService);
var mDBConn = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;

function cleanDatabase() {
   mDBConn.executeSimpleSQL("DELETE FROM moz_places");
   mDBConn.executeSimpleSQL("DELETE FROM moz_historyvisits");
   mDBConn.executeSimpleSQL("DELETE FROM moz_anno_attributes");
   mDBConn.executeSimpleSQL("DELETE FROM moz_annos");
   mDBConn.executeSimpleSQL("DELETE FROM moz_items_annos");
   mDBConn.executeSimpleSQL("DELETE FROM moz_inputhistory");
   mDBConn.executeSimpleSQL("DELETE FROM moz_keywords");
   mDBConn.executeSimpleSQL("DELETE FROM moz_favicons");
  var sql = "DELETE FROM moz_bookmarks WHERE id NOT IN (SELECT folder_id from moz_bookmarks_roots)";
   mDBConn.executeSimpleSQL(sql);
}
i hope to have some time to take a look at this, no promises though.
Assignee: nobody → mak77
Summary: head.js or javascript module for places browser chrome tests → head.js or javascript module for browser chrome tests
Component: Places → BrowserTest
Product: Firefox → Testing
QA Contact: places → browsertest
Created attachment 412394 [details] [diff] [review]
patch v1.0

i thought this was harder, looks like just so easy.
Created attachment 412395 [details] [diff] [review]
patch v1.1

forgot auto-test files.
Attachment #412394 - Attachment is obsolete: true
Comment on attachment 412395 [details] [diff] [review]
patch v1.1

gavin, feedback about this?
Attachment #412395 - Flags: review?(gavin.sharp)
Summary: head.js or javascript module for browser chrome tests → add head.js and cleanup functions to browser chrome tests
Created attachment 414096 [details] [diff] [review]
patch v1.2

applies on top of bug 528469 (by using this._scriptLoader).

Adds head.js, and support for registerCleanupFunction(aFunction), that is a similar functionality to what we have in xpcshell tests, you can register one or more functions that will be run after the test finishes, and before starting next test.
Attachment #412395 - Attachment is obsolete: true
Attachment #414096 - Flags: review?(gavin.sharp)
Attachment #412395 - Flags: review?(gavin.sharp)
Flags: in-testsuite?
pushed to the tryserver and got green
Status: NEW → ASSIGNED
Created attachment 421859 [details] [diff] [review]
patch v1.3

unbitrot against new patch in bug 528469
Attachment #414096 - Attachment is obsolete: true
Attachment #414096 - Flags: review?(gavin.sharp)
Whiteboard: to be applied on top of patch in bug 528469
Attachment #421859 - Flags: review?(gavin.sharp)
my push of all the three patches about b-c tests has gone green.
Depends on: 528469
Attachment #421859 - Flags: review?(gavin.sharp) → review+
Comment on attachment 421859 [details] [diff] [review]
patch v1.3

>diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js

>   realNextTest: function Test_realNextTest() {
>+    if (this.currentTest) {
>+      // Run registered cleanup functions for the previous test.

"Run cleanup functions for the current test before moving on to the next".

I think this code should go into nextTest() before the call to waitForWindowState, though, since the cleanup functions could potentially be used to clean up windows, right?

>diff --git a/testing/mochitest/tests/browser/Makefile.in b/testing/mochitest/tests/browser/Makefile.in

>-_BROWSER_TEST_FILES = 	  browser_pass.js \
>+_BROWSER_TEST_FILES = \
>+                    head.js \
>+                    browser_head.js \
>+                    browser_pass.js \
> 	                  browser_async.js \

fix the indent here?

r=me with those addressed. Should probably add some documentation to this on the MDC page: https://developer.mozilla.org/En/Browser_chrome_tests
Keywords: dev-doc-needed
Created attachment 423397 [details] [diff] [review]
patch v1.4

Addressed comments.

Yes makes MUCH sense running cleanup functions before checking windows status.
Attachment #421859 - Attachment is obsolete: true
http://hg.mozilla.org/mozilla-central/rev/cd5868a825d8
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Whiteboard: to be applied on top of patch in bug 528469
Hardware: x86 → All
Target Milestone: --- → mozilla1.9.3a1
updated https://developer.mozilla.org/en/Browser_chrome_tests
Keywords: dev-doc-needed → dev-doc-complete
Component: BrowserTest → Mochitest
Product: Testing → Testing
You need to log in before you can comment on or make changes to this bug.