Closed Bug 511317 Opened 11 years ago Closed 11 years ago

Add a SERVER_ROOT object-state mapping to Mochitest harness

Categories

(Testing :: Mochitest, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9.3a1

People

(Reporter: Waldo, Assigned: Waldo)

Details

(Keywords: autotest-issue)

Attachments

(1 file)

SJS files which wanted to access files could then just do something like this (name up for debate, easy to change):

  var file;
  getObjectState("SERVER_ROOT", function(getFile)
  {
    file = getFile("tests/content/media/test/320x240.ogv");
  });

Simple, easy change to expose files to SJS handlers, no API additions or changes necessary...
Attached patch PatchSplinter Review
This is slightly different interaction from comment 0, but it's still easy-peasy:

  var file;
  getObjectState("SERVER_ROOT", function(serverRoot)
  {
    file = serverRoot.getFile("tests/content/media/test/320x240.ogv");
  });

  res.write("file: " + file);
Attachment #424899 - Flags: review?(jonas)
(The reason not to return the function directly is that currently object-state is intended only for XPCOMish things, and as part of error-checking there's a check that typeof == "object" (and functions are typeof == "function").  This isn't much more work, and it preserves the ability to use the server in a slightly more isolated manner than mere direct inclusion.
Mochitest part of this bug:

http://hg.mozilla.org/mozilla-central/rev/27c81f40bdfd

Reftest harness doesn't work the same way, biggest difference being every test is sequestered in its own path-space -- so we need to track all path registrations to be able to return a useful file given a path (which the test would have to determine by |window.location| introspection, I think).  Trickier, sure, but hopefully not too painful.  Working on that now to close this out...
I updated Mochitest docs to explain how to use this:

https://developer.mozilla.org/en/Mochitest
Hm, a little more looking says implementing something like this in reftest is more effort than I have time to make just right now.  I'm going to split this bug into two, declare this the (fixed) Mochitest half and have the reftest half be bug 543896 -- if anyone else feels like taking that on, feel free.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
Summary: Add a SERVER_ROOT object-state mapping to Mochitest, reftest harnesses → Add a SERVER_ROOT object-state mapping to Mochitest harness
You need to log in before you can comment on or make changes to this bug.