06.05.10

Dear Lawzyweb

(Joining the recent stream of lazyweb posts on p.m.o…)

If you’ve paid even the slightest attention to tech news, you know Apple lost an iPhone prototype in a bar in the Bay Area. The finder sold it to Gizmodo for $5000, and Jason Chen of Gizmodo published a story with photos and details of it (and numerous followups) — a juicy tech story. More recently, San Mateo police, pursuant to a warrant, searched Jason Chen’s house, seizing numerous pieces of technology hardware. It thus becomes a juicy law story: trade secrets, protection of journalists’ sources, freedom of speech and the First Amendment, handling of lost or stolen property, lots of possible angles. In a number of them it approaches the clearly-defined boundaries of state and federal laws. Great popcorn fodder all around.

There are enough legal questions to satisfy anyone looking to argue them. There are correct answers and incorrect answers, but for a legal novice like me for whom the unknown unknowns are considerable, it’s far more productive to read others’ arguments than to hazard speculation. Also, some parts are matters of fact potentially for a jury to decide, further imperiling predictions.

Every so often, however, it’s possible to pass into realms where my knowledge is less patchy. One commentator, Peter Scheer of the First Amendment Coalition, thinks the police should have obtained a subpoena rather than a warrant, thereby according a journalist what one might claim is his due “delicacy”. Scheer closes an argument for this course of action by speculating as to why it was not taken:

Perhaps there is a more mundane explanation for the failure to use a subpoena in this case: The DA [district attorney] may have been under intense pressure (from whom? Apple, which reported the phone was stolen?) to act even before he could convene a grand jury to issue a subpoena.

If so, the DA may come to regret his haste: If a court rules he shouldn’t have used a warrant, the DA’s possession of evidence seized from Chen’s home may undermine any possible prosecution of other, more culpable, parties.

Assume arguendo that a court does indeed at some point rule the DA shouldn’t have used a warrant. Scheer then claims the seized evidence “may undermine any possible prosecution” of other parties (most likely referring to the original finder, as there is some question of whether the finder actually made a good-faith effort to return the iPhone prototype to its owner, potentially falling afoul of California law). Is this correct? The exclusionary rule forbids admissibility of evidence gained through unreasonable search or seizure in court, following straightforwardly from Weeks v. United States, 232 U. S. 383 (1914), and the Fourth Amendment. The exclusionary rule is then applicable to the states (and to local government such as San Mateo County) under Mapp v. Ohio, 367 U. S. 643 (1961). If case law stopped here it seems to me Scheer would be right — but it doesn’t. Prior to Mapp the Supreme Court held that:

In order to qualify as a “person aggrieved by an unlawful search and seizure,” [for whom evidence from an illegal search or seizure could be suppressed] one must have been a victim of a search or seizure, one against whom the search was directed, as distinguished from one who claims prejudice only through the use of evidence gathered as a consequence of a search or seizure directed at someone else.

Frankfurter, J. in Jones v. United States, 362 U. S. 257, 261 (1960)

It seems to me that, were the warrant declared invalid, evidence from the search would be suppressed in any potential prosecution of Jason Chen (and maybe Gizmodo — but in Alderman v. United States, 394 U. S. 165 (1968), the Court explicitly declined to apply the exclusionary rule with respect to evidence gained through illegal search of a “coconspirator”; Gizmodo or its other employees might or might not be such, maybe depending on whom a case targeted). However, I don’t see how evidence would be suppressed in the prosecution of anyone else — most particularly of the finder of the prototype.

The question for the la[w]zyweb: would evidence from Jason Chen’s computers, pursuant to an illegal search and seizure, be admissible in court against the original finder of the iPhone prototype? I think it would be admissible, and I think Peter Scheer is mistaken if he is suggesting that it wouldn’t.

Speculation’s fine, but as I already provide the less-educated kind I’d prefer if comments consisted of the more-educated kind. 🙂

05.05.10

New Mozilla developer feature: Components.utils.getGlobalForObject(obj)

Suppose you’re an extension developer implementing some sort of event listener-like interface corresponding to browser windows. You’d like listeners to stick around as long as the original browser window is open, so when the browser window’s unload event fires when the browser window is closed, you want to remove the listener. Further, for simplicity, you’d like to be able to reuse the same interface as the DOM uses: EventTarget.addEventListener(eventName, listener, bubbles). But if you do that, how do you know what browser window to associate with a listener? One possibility is that you could associate event listeners with windows if you could determine the global object that corresponded to the event listener in question. (Assume arguendo that you control all use of listeners, so every listener is straightforwardly created in the window with which it’s associated — no shenanigans passing listeners across windows.) This isn’t the only situation where one might wish to know the global object, but it does happen to be a somewhat common one.

Is it possible to determine the global object corresponding to an arbitrary object? You can through a convoluted sequence of actions involving prototype hopping using Object.getPrototypeOf and walking the “scope chain” for the object (using an obscure Mozilla-specific feature whose details I omit). More simply, if the object in question is a DOM node, you could use node.ownerDocument.defaultView, which, while quite understandable, is still DOM-specific. But wouldn’t it be much better if there were some simpler, universal way to determine this value, rather than skirting the edges of feature intentionality?

Firefox nightlies now implement support for a new method available to extensions and other privileged code: Components.utils.getGlobalForObject(obj). It’s designed to support the specific need of determining the window where an object was created. (XPCOM components of course have a global object that isn’t a window, and that global object will be returned by the method in those circumstances.) Its functionality needs little explanation:

/* in the global scope */
var global = this;
var obj = {};
function foo() { }
assertEq(Components.utils.getGlobalForObject(foo), global);
assertEq(Components.utils.getGlobalForObject(obj), global);

If you’re using the previously-noted method involving prototype- and scope-chain-hopping, you should change your code to use Components.utils.getGlobalForObject(obj) instead. This new method is much simpler and clearer, and upcoming changes mean that the old method will no longer work in future nightlies and releases. The next release is still several months out, so you should have plenty of time to adjust.

As always, you can experiment with a bleeding-edge version of Firefox that supports Components.utils.getGlobalForObject(obj) by downloading a nightly from nightly.mozilla.org. (Don’t forget to use the profile manager if you want to keep the settings you use with your primary Firefox installation pristine.)

A last note: the method as currently implemented in nightlies suffers from a small bug when used with objects from unprivileged code — objects from scripts in web pages, that sort of thing. It’s fixed in the TraceMonkey repository, and the adjustment should make its way into the mozilla-central repository (and thus into nightlies) in short order. If you only use the method on objects from privileged scripts, I don’t believe you’ll encounter any problems.

04.05.10

« Newer