Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#901 closed defect (fixed)

dojo.io.RhinoIO implementation

Reported by: dsnopek@… Owned by: James Burke
Priority: high Milestone:
Component: General Version: 0.3
Keywords: Cc: dsnopek@…
Blocked By: Blocking:

Description

I implemented a transport for Rhino in dojo.io.RhinoIO. I can perform synchronise HTTP requests and supports the following arguments to dojo.io.bind():

  • url
  • method (correctly supports both 'get' and 'post')
  • sync (really, we can only do synchronise, but this checked by canHandle)
  • content
  • postContent
  • headers
  • contentType
  • mimetype (text/plain, text/html, text/javascript, text/json)
  • sendTransport

Unfortunately, it won't work the way you expect right out of the box because of problems with dojo.io under Rhino in relation to this bug: http://trac.dojotoolkit.org/ticket/900

You have to specify *all* of the handlers or Rhino will throw an exception, like:

dojo.io.bind({
   // .... other stuff
   load:    function (type, data) { },
   timeout: function (type, data) { },
   error:   function (type, data) { },
   handle:  function (type, data) { }
});

I have attached a patch to fix dojo.io so that this operates normally. However, this is related to a general problem with Rhino and instanceof that might be better fixed in dojo.lang. See the above mentioned bug for more information on this.

Attachments (3)

RhinoIO.js (3.4 KB) - added by dsnopek@… 13 years ago.
The transport source.
dojo.io.patch (547 bytes) - added by dsnopek@… 13 years ago.
Patch against dojo/src/io.js
test_rhinoio.js (746 bytes) - added by dsnopek@… 13 years ago.
A rhino script to test (*not* a unit test)

Download all attachments as: .zip

Change History (9)

Changed 13 years ago by dsnopek@…

Attachment: RhinoIO.js added

The transport source.

Changed 13 years ago by dsnopek@…

Attachment: dojo.io.patch added

Patch against dojo/src/io.js

comment:1 Changed 13 years ago by James Burke

David, you wouldn't happen to have a unit test for this would you? If you just have a sample script and a file that is loaded via RhinoIO that would be enough.

Also, was this triaged as a 0.3.1 bug, or just a guess on the milestone? If it has been triaged as a 0.3.1 bug, I am willing to apply the patch (particularly if there are unit test files for it).

comment:2 Changed 13 years ago by dsnopek@…

I would be happy to write a unit test, however, I can't make sense of the unit test framework. I know that if I run "ant -f build test" in buildscripts/ it will somehow magically run some unit tests somewhere, but I don't know where the tests are or how to make such a thing. The files in tests/ appear just to be html/js for the browser? If you could point me to an existing unit test I could use as an example and let me know how to register it with the test manager, I'll throw something together as soon as possible. For the time being I can attach the script that I used to test it while writting it.

As far as being "triaged as a 0.3.1 bug", I just guessed at that value. What should I have put there?

Changed 13 years ago by dsnopek@…

Attachment: test_rhinoio.js added

A rhino script to test (*not* a unit test)

comment:3 Changed 13 years ago by James Burke

Milestone: 0.3.10.4
Owner: changed from anonymous to James Burke
Status: newassigned

David, I'm not too concerned with haveing an automated unit test (besides I'm still figuring that part out too). I just wanted some sort of unit test that could be run at least manually. We have a similar case with at least two of the other IO tests: they require CGI files to run, and the test_IframeIO.html page actually requires the user to select a file in the web browser to verify the test.

Thanks for ths test_rhinio.js. Are you comfortable also attaching the posttest.cgi server script that does the response? I think with that file then this will be a complete package.

It was OK to guess at the Milestone value -- since we are getting so close to getting 0.3.1, I wasn't sure if there was a particular reason for putting it in the 0.3.1 short list. I'm going to move it to 0.4, but I am planning to review it within the next couple of days.

comment:4 Changed 13 years ago by adam@…

David, all you should have to do to register your test is put it somewhere under the tests/* tree. I'm new to the unit tests myself, but anything matching test_*.js will get run. I moved your test to tests/io/test_rhinoio.js on my machine, removed the load(dojo.js), and it ran fine.

You can use the "jum" object to do asserts. There don't appear to be any in the tests/io directory, but look at the toplevel tests/* for examples.

comment:5 Changed 13 years ago by James Burke

Cc: dsnopek@… added
Resolution: fixed
Status: assignedclosed

David, Thank you for waiting patiently, I finally applied the patch. Although I did do some modifications to bring it inline with the dojo style guide, and I renamed the actual transport class to RhinoHTTPTransport. SyncHTTPTransport seemed too generic, and applicable outside of the Rhino arena. But feel free to offer feedback if you feel I did anything incorrectly.

Also, if you could pass on the source for the posttest.cgi, I can get it up on the Dojo site and enable the POST tests in the unit test file. If you are feeling particularly generous, you could write up something for the Dojo Book for this transport. It would go into this section:

http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book31

Thanks again for the patch and the patience.

comment:6 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.