Categories
Mozilla Web Development

Embedded JavaScript For Web 3.0

John Resig has an interesting blog post on embedded JavaScript. It’s something I’ve been thinking about for a little while.

It would be awesome to see a PHP extension to embed SpiderMonkey into PHP. As far as I’m aware Facebook is the only one that’s taken a step in that direction with FBJS, which uses Mozilla source code. Perhaps that could be a starting point.

Considering the ubiquity of JavaScript, using SpiderMonkey, which is already available for Perl and Python, or Rhino (for Java) would make sense. It would allow for JavaScript to be for logic what XML is for data. In my mind that is nirvana for the web.

XML made our data portable. JavaScript can make our logic portable. Seems practical enough right?

For those who question security, it’s really up to the client to decide if it should parse JS, and what subset it should allow (perhaps no eval()). Having an API based on JS is really no less secure than any other language including one that’s home made. It’s advantage is that it’s used everywhere else and makes your API easier to work with.

This could be cornerstone of Web 3.0. Web 2.0 was largely about shared data and isolated small services. Web 3.0 could be about shared data and shared services.

Categories
Apple Google Mozilla

Safari’s New JS Interpreter: SquirrelFish

There’s an announcement on the Safari blog about SquirrelFish, their new JS interpreter. To sum it up:

SquirrelFish is a register-based, direct-threaded, high-level bytecode engine, with a sliding register window calling convention. It lazily generates bytecodes from a syntax tree, using a simple one-pass compiler with built-in copy propagation.

Some performance data can be found here, as well as here, which even tests against Tamarin (slated for inclusion in Mozilla2). I think the motive for this move might have been best summarized here:

  1. I can imagine the “performance per watt� power consumption for SquirrelFish is also much lower. Good for my iPhone’s battery life.

Especially with the iPhone going 3G next week which will consume more power, making a web browser be as efficient as possible with CPU cycles not only makes the experience better, but will save battery life. This doesn’t just impact the iPhone as Google’s Android also includes WebKit.

David Mandelin has some analysis and comparison to the Mozilla work being done on his blog.

It’s pretty interesting stuff.

Categories
Mozilla Open Source Programming

Benchmarking And Testing Browsers

When people talk about open source they often talk about the products, not the process. That’s not really a bad thing (it is after all about the product), but it overlooks some really interesting things sometimes. For example open source tools used in open development.

A few months ago Jesse Ruderman introduced jsfunfuzz, which is a tool for fuzz testing the js engine in Firefox. It turned up 280 bugs (many already fixed). Because the tool itself is not horded behind a firewall it’s also helped identify several Safari and Opera bugs. It’s a pretty cool way to find some bugs.

The WebKit team has now released SunSpider a javascript benchmarking tool. Something tells me this will lead to some performance improvements in everyone’s engine. How much will be done for Firefox 3.0 is a little questionable considering beta 2 is nearing release, though you never know. There’s been some nice work on removing allocations recently. So just because it’s beta, you can’t always assume fixes will be minor in scope.

Another test that many are familiar with is Acid 2 which essentially is checking CSS support among browsers. Ironically this one too was released when Gecko is somewhat late in the development cycle.

Efforts like this really help web development by allowing browser developers to have a baseline to compare their strengths and weaknesses. Having a little healthy competition as motivation can be pretty helpful too 😉 .

Categories
Mozilla Security

Email Image Protection

Many people think that making an image out of an email is a good way to protect it from being harvested by spam bots. It’s now possible to convert it from an image to email link via a Firefox extension. Guess what, an email harvester can do this just as well. What’s a better solution against email harvesters? Don’t put any trace of an email address online, use a form. Yes you could distort the image a bit to make it more difficult, but using a CAPTCHA as an email isn’t going to make you any friends. JavaScript can also be done, but no reason why it can’t be interpreted (though that may be more difficult in some cases, since a JS engine isn’t the easiest thing to work with, and implementing anything less can easily be defeated by throwing some extra JS in there. Some discussion on the Firefox Extension implementation can also be found on Gerv’s blog where he proposed the idea.

Categories
Around The Web Internet Mozilla Web Development

JavaScript Badges And Widgets Considered Harmful?

Jeremy Zawodny has a great post about common JavaScript usage where he concludes it’s harmful. Whether you agree or not, you have to admit it’s a great blog post. Here comes another long blog post.

Categories
Hardware Software Web Development

Wii Browsing

Now that the Wii Browser is available, I’m really thinking I should check it out. It’s based on Opera. In my mind they needed to have a few things in order for this to not suck:

  • Fairly good HTML/XHTML support – Opera has that
  • Good support for CSS – Opera has that as well, but available for all small-screen versions
  • JavaScript Enabled – Opera has pretty good JS support, but not always available for small devices.
  • Support for Macromedia Flash – Especially with the popularity of YouTube, it’s needed

Apparently it meets these requirements. I really need to check this out. As a web developer, seeing something like this after years of crummy non-PC based browsers could be impressive. Screenshots so far have not disappointed.

Categories
Mozilla Web Development

Firebug 1.0 Beta Is Out!

Firebug 1.0 Beta is available for download. Only played with it for a few minutes, but it looks great so far. I’ll definitely be digging into it and see what’s really new and better in the next day or two.

Categories
Google

Gbrowser Redux

An interesting post on an allegedly new Googlebot. I’ve got no clue about the truth or accuracy of it, but the article thinks Googlebot is no longer a lynx like browser, but based on Mozilla. It would make sense, so Google can take better advantage of things like CSS, JavaScript. Perhaps it’s using <canvas/> to create screenshots for thumbnails?

Again, no clue regarding accuracy, but it’s an interesting read.

Categories
Mozilla

Reporter Status Update

Well, they aren’t done yet, but I thought I’d share some new reporter screenshots. As you can see quite a few refinements. Still a little rough, but I think it illustrates how simple the process is. There’s some obvious UI uglies still in there. It can take well under 30 seconds to submit a report.

Privacy Statement

Form

All done!

We automate the collection of just about all the important data, so we can make sure we get a pretty accurate rundown of what is included.

Still missing is collecting some buildconfig info. So if anyone knows why the following code doesn’t work, let me know:

function getBuildConfig() {
 
  var ioservice =
     Components.classes["@mozilla.org/network/io-service;1"].
       getService(Components.interfaces.nsIIOService);
  var channel = ioservice.newChannel("chrome://global/content/buildconfig.html",
                                     null, null);
  var stream = channel.open();
  var parser = new DOMParser();
  var buildconfig = parser.parseFromStream(stream, "UTF-8", stream.available(),
                                   "application/xhtml+xml");
  return buildconfig.documentElement.firstChild.textContent;
}
< ?pre>
Categories
Mozilla

Write File

Can anyone tell me why this code doesn’t work in Thunderbird 0.9 (I haven’t tried Firefox 1.0).

Note: There is a slash in the directory path C:, for some reason wordpress is fudging it up. MovableType did this crud too. So it’s not showing, but it’s there in the code.

function sync()
{
testFileOutputStream("C:\foo.txt", "la la la \n robert");
}
 
function testFileOutputStream(path, buffer) {
  // file is nsIFile, data is a string
  var stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
    .createInstance(Components.interfaces.nsIFileOutputStream);
 
  // use 0x02 | 0x10 to open file for appending.
  stream.init(nsLocalFile(path), 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
  stream.write(buffer, buffer.length);
  stream.close();
}
 
function nsLocalFile(path)
{
    const LOCALFILE_CTRID = "@mozilla.org/file/local;1";
    const nsILocalFile = Components.interfaces.nsILocalFile;
 
    var localFile =
        Components.classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
    localFile.initWithPath(path);
    return localFile;
}

Keep getting this error:

Error: uncaught exception: [Exception… “Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIFileOutputStream.init]” nsresult: “0x80004005 (NS_ERROR_FAILURE)” location: “JS frame :: chrome://extension/content/extension.js :: testFileOutputStream :: line 12” data: no]

Simply want to be able to write to C: (or any place on my HD that I specify). Prefer not to use JSlib, simply because I don’t want dependencies. It’s really borderline insane to think you can’t do something as simple as write out to a file without depending on other lib’s.

Thanks in advance.

Comments/Email as usual.