Closed Bug 494492 Opened 16 years ago Closed 16 years ago

"host" undefined in startup() webapp.js

Categories

(Mozilla Labs :: Prism, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: xavid, Unassigned)

Details

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10 Prism/1.0b1 Using Prism 1b1 on Mac 10.5, I tried adding a webapp.js to my application. It is loaded and its startup method is called; however, the example webapp.js given on https://wiki.mozilla.org/Prism/Scripting: function startup() { host.log("hello"); } gives the error: Error: host is not defined Source File: file:///Users/xavid/Library/Application%20Support/Firefox/Profiles/mtayt10t.default/extensions/refractor@developer.mozilla.org/prism/modules/WebAppProperties.jsm -> file:///Applications/PJ%20Gmail.app/Contents/Resources/webapp/webapp.js Line: 2 I get similar errors if I try to use "alert", "setInterval", or window.platform.icon().badgeText = "42", even though at least alert and badgeText work fine when entered interactively on the javascript console. Note that, at least with Gmail, the error console gets cleared several times during startup, so to see this traceback you have to run something like "/Applications/PJ\ Gmail.app/Contents/MacOS/prism -jsconsole" from the command line, quickly bring the console window to the top, and watch closely; the relevant error will disappear if you wait for the page to load. Reproducible: Always Steps to Reproduce: 1. Put a webapp.js file as described above in /Applications/PJ Gmail.app/Contents/Resources/webapp/webapp.js, where "PJ Gmail.app" is your Prisim .app. 2. Run /Applications/PJ\ Gmail.app/Contents/MacOS/prism -jsconsole Actual Results: An error appears in the Javascript Console, and the effects of the startup() do not happen. Expected Results: The message "hello" should be logged to the console without error.
HostUI is no more (see https://bugzilla.mozilla.org/show_bug.cgi?id=476522). The wiki page you point to is hopeless out of date (something I need to deal with, thanks for pointing that out). Please use the MDC page instead: https://developer.mozilla.org/en/Prism. As far as window.platform methods are concerned, startup() is too early since the window hasn't loaded yet. Use load() instead.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
Note that http://prism.mozilla.com/ links to that wiki, so if it's deprecated http://prism.mozilla.com/ should be updated. Thanks, ~Xavid
Excellent point. :-) I'll remove the link.
You need to log in before you can comment on or make changes to this bug.