Closed Bug 485269 Opened 15 years ago Closed 14 years ago

add head.js and cleanup functions to browser chrome tests

Categories

(Testing :: Mochitest, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9.3a1

People

(Reporter: ddahl, Assigned: mak)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file, 4 obsolete files)

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
Attached patch patch v1.0 (obsolete) — Splinter Review
i thought this was harder, looks like just so easy.
Attached patch patch v1.1 (obsolete) — Splinter Review
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
Attached patch patch v1.2 (obsolete) — Splinter Review
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
Attached patch patch v1.3 (obsolete) — Splinter Review
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
Attached patch patch v1.4Splinter Review
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
Closed: 14 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
Component: BrowserTest → Mochitest
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: