Archive for the ‘Web’ Category

Nutty Expando Bug (JavaScript)

Tuesday, July 13th, 2010

I do a lot of JavaScript development. I’ve seen my share of browser bugs. This one takes the cake from the perspective of annoying and unexpected. From what I can tell right now, this only affects Mozilla. Allow me to set the stage:

We use the window.name property to persist data across pages. We rarely have a problem with this except when other components that we’re using also use window.name for storage. Fortunately we have tricks to help with this. What we haven’t seen before was a bug inside the TeaLeaf JavaScript code, which accidentally created a local variable in the global scope. A common mistake.  A bit surprising, coming from the likes of TeaLeaf but common nonetheless.

This (approximated) one line of code inside Tealeaf has been causing us problems in Mozilla:

Tealeaf.somerandomfunction = function() {
name = “bla”;
}

So they’ve created a variable here, but accidentally in the global scope.

Now open Firefox and try this:

  1. Load a random web page (google.com or something)
  2. Open firebug
  3. Type “window.name = ‘apple’;”
  4. Refresh the page
  5. Type “window.name” (see “apple”)

Works as expected, right? Now, try this:

  1. Load random web page and open firebug
  2. Type “window.name = ‘apple’;”
  3. Type “name = ‘orange’;”
  4. Type “window.name” (see “orange”)
  5. Type “window.name = ‘Pear’;”
  6. Refresh the page
  7. Type “window.name” (see ‘apple’)

Note that the issue is not merely that they have leaked their local variable into the global scope, but that it seems to obliterate the reference to the DOM extension window.name (which still exists, but with no references to it). Even if we access window.name directly now, we are reading and writing to the new expando property. Thus, when we go to the next page, we are left with the original value we first wrote to window.name

To solve this, every time you want to use window.name you should do this first:

delete(name);

VanJS: Offline Storage and Server-Side JavaScript

Saturday, December 5th, 2009

UPDATE: I’ve posted the slides for this here.

Live in Vancouver? Want to learn more about JavaScript? Check out the VanJS users group. Incidentally, I’ll be giving a talk on Jan 9 on Offline Storage. Jim Pick will also be talking about Server-Side JS and no doubt some Joyent goodness! I’ll post the slides here afterward.

Sub-topics will include:

  • HTML5 Offline Storage Options
  • UserData
  • Flash Local Shared Object
  • Window.name
  • probably more.

Also I’ll be giving away a copy of my book to anyone who cares.

PhoneGap given Apple Seal of Approval

Wednesday, November 25th, 2009

Over the past year or so there has been a lot of consternation on the part of developers writing applications for iPhone using the PhoneGap framework. The problem seemed to be that Apple was unpredictably rejecting applications on the sole basis that they used a 3rd party framework, or that they suspected PhoneGap used techniques they prohibited (like downloading program logic at runtime). Recently, Apple sat down and did a proper technical analysis of the framework to evaluate whether or not they should continue to discriminate based on the use of this framework, or simply evaluate these applications on their own merits instead. According to Jesse MacFadyen of Nitobi:

  • Apple has given PhoneGap a technical analysis , and PhoneGap does not violate the Terms & Conditions of the App Store.
  • Apple will review PhoneGap applications based on their own merits and not on their use of PhoneGap.

This is great news for the development community because it means we can continue to write simple cross-platform applications using HTML, CSS, and JavaScript, and deploy them natively to a number or devices without having to do tonnes of rewrite for each one.

Slides from Max 2009 Talk

Tuesday, October 6th, 2009

Here are the slides from my Adobe Max 2009 talk on “JavaScript 2.0 in Dreamweaver CS4″:

Catch my JavaScript Talk at Adobe Max ‘09

Monday, September 28th, 2009

If you’re going to Adobe MAX this year and are interested in JavaScript development, you may be interested in my talk “JavaScript 2.0 in Dreamweaver” which will be held @ October 6 at 03:00PM in room 506 (Capacity: 90). While you’re at it, here are a few other JavaScript or Dreamweaver related talks that might interest y’all:

  • Using the Spry Framework in Dreamweaver CS4 (Arnout Kazemier) Oct 5th 3:30pm 403B
  • Spry Widgets and Dreamweaver CS4 (BYOL) (Chris Converse) Oct 6th 1:00pm 408A
  • Ajax for Designers (Greg Rewis) Oct 5th 11:30am 405 + Others
  • Skinning JavaScript Framework Widgets in Dreamweaver (Joe Lowery) Oct 7th 3:30pm 402A
  • Best Practices in Cross-Browser Testing with Adobe BrowserLab (Kristin Long) Oct 7th 2:00pm 406A + Others
  • Roadmap: Web Professional Tools and Services in Creative Suite (Lea Hickman) Oct 7th 5:00pm 504

Basically I’ll be discussing ways that serious JS dev can approached in Dreamweaver, giving demos of some cool new stuff including:

  • BrowserLab
  • DOM and CSS debugging features
  • Framework support
  • Web Widgets
  • Spry

I’ll also talk about some things to watch out for and talk about where I would like to DW go in the future. MAX is Adobe’s annual conference and will be held between Oct 3-7 in Los Angeles this year.

What the Heck Happened to My Template?

Wednesday, June 17th, 2009

So I foolishly decided to update Wordpress to 2.8 using the one-click update this morning and it happily obliterated my custom template! Thanks a LOT wordpress developers! Although I suppose its my fault for not backing it up.

Anyway I need to redo the template anyway so I guess its a blessing in disguise – its just not something I wanted to do this week. :( . This temporary one will have to suffice for now.

Will Apple Permit JavaScript-based Apps?

Monday, May 25th, 2009

There seems to be a real movement afoot to provide means for developers to write native or near-native phone applications in ECMAScript. PhoneGap is doing it, Rhomobile is doing it, Palm Pre is doing it, and now Haxe is doing it.

HaXe has always been an interesting project. It’s basically a JavaScript compiler with targets for Flash 6-10, PHP, C++, Java, etc. Now you can write HaXe projects for the iPhone. Pretty cool stuff. This is certainly along the lines of PhoneGap in that it helps democratize the platform – however – I suspect it probably violates the iPhone terms of use in that it basically becomes an interpreter:

Usage of such non-public API, as outlined in the iPhone SDK Agreement section 3.3.2 is prohibited:

"An Application may not itself install or launch other executable code by any means, including without limitation through use of a plug-in architecture, calling other frameworks, other APIs or otherwise. No interpreted code may be downloaded and used in an Application except for code that is interpreted and run by Apple’s Published APIs and built-in interpreter(s)."

This seems to be sortof the same problem suffered by apps written using the popular phone framework PhoneGap (http://ajaxian.com/archives/someone-at-apple-please-review-stance-on-phonegap). While I see the need to control how code is executed when running outside the normal security sandbox of a browser, HaXe seems fairly tame because as far as I can tell, the application code is not being altered after the program is compiled (could it??). In any case, you’re still compelled to operate within the same runtime sandbox as a normal Objective-C based application.

In any case, if Apple is going to continue to crack down on frameworks like this, I hope they pick on the way the wind is blowing and provide something to the community that lets people marry the familiar world of ECMAScript, HTML, and/or CSS with the powerful features of the iPhone.

Free Adobe Flex Builder 3 (if you’re unemployed)

Sunday, April 12th, 2009

In a pretty-smooth move sure to be emulated, Adobe has announced they are giving out free copies of Flex Builder 3 if you are a developer and are unemployed. Although accepting the free $700 license has the following catches:

  1. Developers must not be currently employed or being paid to develop software applications or web pages
  2. Adobe Flex Builder 3 Software they receive under this program is for their personal use to learn about Adobe Flex and improve their skills
  3. Their license to use Flex Builder 3 under this program cannot be used for production or commercial purposes, nor will it be transferred to any other person or entity, including to their employer should they become employed.

So… they can get Flex 3 to learn a new skill but NOT to get a new job..  great.. Wouldn’t it be great if they just said “here you go, use this to get back on your feet again – use it to earn some money while you’re unemployed, and please think of us during your next tech purchase.” instead of “here you go.. just don’t use this to earn any money or do anything to help put food on your table.. we’re generous, but not THAT generous!”

Actually all-in-all it’s a pretty classy move and I suspect a lot of people will take them up on it. Get your copy here.



© All rights reserved.