wyantb / HashMask

A browser addon for password fields, adding a visual hash to aid in memorability.
5 stars 0 forks source link

Can't load more than one JavaScript file (ignoring page mods) #38

Closed nickserv closed 12 years ago

nickserv commented 12 years ago

I'm having a hard time figuring out how to import the required libraries without copy-pasting all of our code into one file (except for inject scripts). Jetpack's docs don't seem to offer any useful information on how to properly require your own files.

error: An exception occurred.
Traceback (most recent call last):
  File "chrome://browser/content/browser.js", line 5215, in delayedStartu
    .init(window);
  File "resource:///components/nsSessionStore.js", line 440, in sss_ini
    this.onLoad(aWindow);
  File "resource:///components/nsSessionStore.js", line 627, in sss_onLoa
    Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
  File "resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/api-utils/lib/system/events.js", line 58, in 
    data: data
  File "resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/api-utils/lib/addon/runner.js", line 57, in 
    startup(null, options);
  File "resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/api-utils/lib/addon/runner.js", line 84, in startu
    let program = load(loader, loader.main).exports;
  File "resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/api-utils/lib/cuddlefish.js", line 177, in loa
    evaluate(sandbox, module.uri);
  File "resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/api-utils/lib/cuddlefish.js", line 142, in evaluat
    : scriptLoader.loadSubScript(uri, sandbox, encoding);
  File "resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/hashmask/lib/main.js", line 6, in 
    var sjcl = require(self.data.url("sjcl.js"));
  File "resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/api-utils/lib/cuddlefish.js", line 207, in requir
    base + " has no authority to load: " + id);
Error: Module: main located at hashmask/lib/main.js has no authority to load: resource://hashmask-at-sse-dot-se-dot-rit-dot-edu/hashmask/data/sjcl.js
wyantb commented 12 years ago

Their docs don't, perhaps. Do you have version 1.7 of the SDK? The annotator example shows how to include multiple files, requires from different folders, and so on. I'd suggest looking at that one.

EDIT: nevermind, my comment is meaningless.

wyantb commented 12 years ago

Instead of loading it directly in main.js, put it in a background page. More specifically...if simpleStorage has values defined for everything we need, don't create the background page. If it doesn't, create a background page, which generates those values, and sends it back using 'port' (second link).

Appropriate logic as necessary to get these hijinks running.

https://github.com/mozilla/addon-sdk/blob/master/packages/addon-kit/docs/page-worker.md https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/guides/content-scripts/using-port.html

wyantb commented 12 years ago

See firefox branch, works on my machine (not Dan's, I'm guessing because of the port stuff not being valid in page workers, or getting destroyed too early).

nickserv commented 12 years ago

I tried on Linux, Dan tried on Windows, and I also tried on a Mac and I haven't seen Hash Mask display on any pages. I didn't get any error messages or warnings either.

And thanks, I'll look into the injecting stuff more.

nickserv commented 12 years ago

Oh also, in your third to last comment, why did you say it was meaningless?

wyantb commented 12 years ago

You mean my first comment? I said it was meaningless because the example I thought existed didn't apply to the specific issue you were talking about, which was our ability to require("sjcl.js"). The example just had page scripts that were packaged in the extension.

And, yeah, I'm not really sure why it only works on my machine. It's obviously not done in general, just should be a start for you for some time. Hell, if you can just figure out how to properly and meaningfully debug stuff, that would be a big boon.

nickserv commented 12 years ago

This is fixed, right?

wyantb commented 12 years ago

You made the issue, I have no opinion on whether or not you close this issue. I just know that I haven't actually tested the Firefox port on a number of pages, like we've done for Chrome.

nickserv commented 12 years ago

Well, it seems like this is working now, yes? Or at least we found a good way around it with the background page.

wyantb commented 12 years ago

Yes, it appears to work. I still have no opinion on whether or not you close your issue. All I'm saying is that I haven't really given it any decent testing.

nickserv commented 12 years ago

Well, it seems to work for me, too. I'll close this, and we can make another issue if we notice something breaking.