Last Comment Bug 735589 - B2G SMS: ctypes undefined error in systemlib.js in xpcshell tests for SMS
: B2G SMS: ctypes undefined error in systemlib.js in xpcshell tests for SMS
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: DOM: Device Interfaces (show other bugs)
: unspecified
: x86_64 Linux
: -- minor (vote)
: mozilla14
Assigned To: Vicamo Yang [:vicamo][:vyang]
:
Mentors:
Depends on:
Blocks: 734299
  Show dependency treegraph
 
Reported: 2012-03-14 01:19 PDT by Vicamo Yang [:vicamo][:vyang]
Modified: 2012-03-15 18:02 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
import ctyps.jsm (810 bytes, patch)
2012-03-14 10:07 PDT, Vicamo Yang [:vicamo][:vyang]
no flags Details | Diff | Splinter Review
import ctyps.jsm : V2 (909 bytes, patch)
2012-03-14 19:24 PDT, Vicamo Yang [:vicamo][:vyang]
philipp: review+
Details | Diff | Splinter Review

Description Vicamo Yang [:vicamo][:vyang] 2012-03-14 01:19:46 PDT
Attachement 604277 in bug 734299 breaks xpcshell tests with error "resource://gre/modules/systemlibs.js:101: ReferenceError: ctypes is not defined". In systemlibs.js line 20, the already existing libcutils returns a dummy on error catched, while libnetutils still try to create an working object for return at line 100.

This error is found within x86_x64 b2g build.
Comment 1 Philipp von Weitershausen [:philikon] 2012-03-14 01:28:07 PDT
The xpcshell test can easily import resource://gre/modules/ctypes.jsm and pass that into the worker scope.
Comment 2 Vicamo Yang [:vicamo][:vyang] 2012-03-14 10:07:41 PDT
Created attachment 605819 [details] [diff] [review]
import ctyps.jsm

verified with existing test scripts
Comment 3 Philipp von Weitershausen [:philikon] 2012-03-14 13:23:05 PDT
Comment on attachment 605819 [details] [diff] [review]
import ctyps.jsm

Hmm, does this even work? The worker only sees 'worker_ns' created in 'newWorker()', no? I was thinking of importing it directly into the worker namespace, like so:

  function newWorker(custom_ns) {
    let worker_ns = {
      ...
    };
    Cu.import("resource://gre/modules/ctypes.jsm", worker_ns);
    ...
    return worker_ns;
  }

I think that's more elegant, too...
Comment 4 Vicamo Yang [:vicamo][:vyang] 2012-03-14 19:21:00 PDT
(In reply to Philipp von Weitershausen [:philikon] from comment #3)
> Comment on attachment 605819 [details] [diff] [review]
> import ctyps.jsm
> 
> Hmm, does this even work? The worker only sees 'worker_ns' created in
> 'newWorker()', no?

Strange, but it does :)

> I was thinking of importing it directly into the worker
> namespace, like so:
> 
>   function newWorker(custom_ns) {
>     let worker_ns = {
>       ...
>     };
>     Cu.import("resource://gre/modules/ctypes.jsm", worker_ns);
>     ...
>     return worker_ns;
>   }
> 
> I think that's more elegant, too...

Perfect!
Comment 5 Vicamo Yang [:vicamo][:vyang] 2012-03-14 19:24:14 PDT
Created attachment 606075 [details] [diff] [review]
import ctyps.jsm : V2
Comment 6 Philipp von Weitershausen [:philikon] 2012-03-15 18:02:55 PDT
https://hg.mozilla.org/mozilla-central/rev/29e6ffe61193

Note You need to log in before you can comment on or make changes to this bug.