Mozilla Nederland LogoDe Nederlandse

Akıllı TV'de Mozilla Firefox OS dönemi - Sözcü

Nieuws verzameld via Google - ma, 11/05/2015 - 04:15


Akıllı TV'de Mozilla Firefox OS dönemi
Mozilla Firefox OS işletim sisteminin yer aldığı akıllı televizyonlar görücüye çıktı. Merakla beklenen televizyonların nasıl bir görünüme sahip olacağı gösterildi. Arayüzünde yuvarlak hatlarla dikkat çeken uygulamalar dikkat çekiyor. Canlı TV, yüklü ...

en meer »
Categorieën: Mozilla-nl planet

The Rust Programming Language Blog: Abstraction without overhead: traits in Rust

Mozilla planet - ma, 11/05/2015 - 02:00

Previous posts have covered two pillars of Rust’s design:

  • Memory safety without garbage collection
  • Concurrency without data races

This post begins exploring the third pillar:

  • Abstraction without overhead

One of the mantras of C++, one of the qualities that make it a good fit for systems programming, is its principle of zero-cost abstraction:

C++ implementations obey the zero-overhead principle: What you don’t use, you don’t pay for [Stroustrup, 1994]. And further: What you do use, you couldn’t hand code any better.

– Stroustrup

This mantra did not always apply to Rust, which for example used to have mandatory garbage collection. But over time Rust’s ambitions have gotten ever lower-level, and zero-cost abstraction is now a core principle.

The cornerstone of abstraction in Rust is traits:

  • Traits are Rust’s sole notion of interface. A trait can be implemented by multiple types, and in fact new traits can provide implementations for existing types. On the flip side, when you want to abstract over an unknown type, traits are how you specify the few concrete things you need to know about that type.

  • Traits can be statically dispatched. Like C++ templates, you can have the compiler generate a separate copy of an abstraction for each way it is instantiated. This comes back to the C++ mantra of “What you do use, you couldn’t hand code any better” – the abstraction ends up completely erased.

  • Traits can be dynamically dispatched. Sometimes you really do need an indirection, and so it doesn’t make sense to “erase” an abstraction at runtime. The same notion of interface – the trait – can also be used when you want to dispatch at runtime.

  • Traits solve a variety of additional problems beyond simple abstraction. They are used as “markers” for types, like the Send marker described in a previous post. They can be used to define “extension methods” – that is, to add methods to an externally-defined type. They largely obviate the need for traditional method overloading. And they provide a simple scheme for operator overloading.

All told, the trait system is the secret sauce that gives Rust the ergonomic, expressive feel of high-level languages while retaining low-level control over code execution and data representation.

This post will walk through each of the above points at a high level, to give you a sense for how the design achieves these goals, without getting too bogged down in the details.

Background: methods in Rust

Before delving into traits, we need to look at a small but important detail of the language: the difference between methods and functions.

Rust offers both methods and free-standing functions, which are very closely related:

struct Point { x: f64, y: f64, } // a free-standing function that converts a (borrowed) point to a string fn point_to_string(point: &Point) -> String { ... } // an "inherent impl" block defines the methods available directly on a type impl Point { // this method is available on any Point, and automatically borrows the // Point value fn to_string(&self) -> String { ... } }

Methods like to_string above are called “inherent” methods, because they:

  • Are tied to a single concrete “self” type (specified via the impl block header).
  • Are automatically available on any value of that type – that is, unlike functions, inherent methods are always “in scope”.

The first parameter for a method is always an explicit “self”, which is either self, &mut self, or &self depending on the level of ownership required. Methods are invoked using the . notation familiar from object-oriented programming, and the self parameter is implicitly borrowed as per the form of self used in the method:

let p = Point { x: 1.2, y: -3.7 }; let s1 = point_to_string(&p); // calling a free function, explicit borrow let s2 = p.to_string(); // calling a method, implicit borrow as &p

Methods and their auto-borrowing are an important aspect of the ergonomics of Rust, supporting “fluent” APIs like the one for spawning processes:

let child = Command::new("/bin/cat") .arg("rusty-ideas.txt") .current_dir("/Users/aturon") .stdout(Stdio::piped()) .spawn(); Traits are interfaces

Interfaces specify the expectations that one piece of code has on another, allowing each to be switched out independently. For traits, this specification largely revolves around methods.

Take, for example, the following simple trait for hashing:

trait Hash { fn hash(&self) -> u64; }

In order to implement this trait for a given type, you must provide a hash method with matching signature:

impl Hash for bool { fn hash(&self) -> u64 { if *self { 0 } else { 1 } } } impl Hash for i64 { fn hash(&self) -> u64 { *self as u64 } }

Unlike interfaces in languages like Java, C# or Scala, new traits can be implemented for existing types (as with Hash above). That means abstractions can be created after-the-fact, and applied to existing libraries.

Unlike inherent methods, trait methods are in scope only when their trait is. But assuming Hash is in scope, you can write true.hash(), so implementing a trait extends the set of methods available on a type.

And… that’s it! Defining and implementing a trait is really nothing more than abstracting out a common interface satisfied by more than one type.

Static dispatch

Things get more interesting on the other side – consuming a trait. The most common way of doing so is through generics:

fn print_hash<T: Hash>(t: &T) { println!("The hash is {}", t.hash()) }

The print_hash function is generic over an unknown type T, but requires that T implements the Hash trait. That means we can use it with bool and i64 values:

print_hash(&true); // instantiates T = bool print_hash(&12_i64); // instantiates T = i64

Generics are compiled away, resulting in static dispatch. That is, as with C++ templates, the compiler will generate two copies of the print_hash method to handle the above code, one for each concrete argument type. That in turn means that the internal call to t.hash() – the point where the abstraction is actually used – has zero cost: it will be compiled to a direct, static call to the relevant implementation:

// The compiled code: __print_hash_bool(&true); // invoke specialized bool version directly __print_hash_i64(&12_i64); // invoke specialized i64 version directly

This compilation model isn’t so useful for a function like print_hash, but it’s very useful for more realistic uses of hashing. Suppose we also introduce a trait for equality comparison:

trait Eq { fn eq(&self, other: &Self) -> bool; }

(The reference to Self here will resolve to whatever type we implement the trait for; in impl Eq for bool it will refer to bool.)

We can then define a hash map that is generic over a type T implementing both Hash and Eq:

struct HashMap<Key: Hash + Eq, Value> { ... }

The static compilation model for generics will then yield several benefits:

  • Each use of HashMap with concrete Key and Value types will result in a different concrete HashMap type, which means that HashMap can lay out the keys and values in-line (without indirection) in its buckets. This saves on space and indirections, and improves cache locality.

  • Each method on HashMap will likewise generate specialized code. That means there is no extra cost dispatching to calls to hash and eq, as above. It also means that the optimizer gets to work with the fully concrete code – that is, from the point of view of the optimizer, there is no abstraction. In particular, static dispatch allows for inlining across uses of generics.

Altogether, just as in C++ templates, these aspects of generics mean that you can write quite high-level abstractions that are guaranteed to compile down to fully concrete code that “you couldn’t hand code any better”.

But, unlike with C++ templates, clients of traits are fully type-checked in advance. That is, when you compile HashMap in isolation, its code is checked once for type correctness against the abstract Hash and Eq traits, rather than being checked repeatedly when applied to concrete types. That means earlier, clearer compilation errors for library authors, and less typechecking overhead (i.e., faster compilation) for clients.

Dynamic dispatch

We’ve seen one compilation model for traits, where all abstraction is compiled away statically. But sometimes abstraction isn’t just about reuse or modularity – sometimes abstraction plays an essential role at runtime that can’t be compiled away.

For example, GUI frameworks often involve callbacks for responding to events, such as mouse clicks:

trait ClickCallback { fn on_click(&self, x: i64, y: i64); }

It’s also common for GUI elements to allow multiple callbacks to be registered for a single event. With generics, you might imagine writing:

struct Button<T: ClickCallback> { listeners: Vec<T>, ... }

but the problem is immediately apparent: that would mean that each button is specialized to precisely one implementor of ClickCallback, and that the type of the button reflects that type. That’s not at all what we wanted! Instead, we’d like a single Button type with a set of heterogeneous listeners, each potentially a different concrete type, but each one implementing ClickCallback.

One immediate difficulty here is that, if we’re talking about a heterogeneous group of types, each one will have a distinct size – so how can we even lay out the internal vector? The answer is the usual one: indirection. We’ll store pointers to callbacks in the vector:

struct Button { listeners: Vec<Box<ClickCallback>>, ... }

Here, we are using the ClickCallback trait as if it were a type. Actually, in Rust, traits are types, but they are “unsized”, which roughly means that they are only allowed to show up behind a pointer like Box (which points onto the heap) or & (which can point anywhere).

In Rust, a type like &ClickCallback or Box<ClickCallback> is called a “trait object”, and includes a pointer to an instance of a type T implementing ClickCallback, and a vtable: a pointer to T’s implementation of each method in the trait (here, just on_click). That information is enough to dispatch calls to methods correctly at runtime, and to ensure uniform representation for all T. So Button is compiled just once, and the abstraction lives on at runtime.

Static and dynamic dispatch are complementary tools, each appropriate for different scenarios. Rust’s traits provide a single, simple notion of interface that can be used in both styles, with minimal, predictable costs. Trait objects satisfy Stroustrup’s “pay as you go” principle: you have vtables when you need them, but the same trait can be compiled away statically when you don’t.

The many uses of traits

We’ve seen a lot of the mechanics and basic use of traits above, but they also wind up playing a few other important roles in Rust. Here’s a taste:

  • Closures. Somewhat like the ClickCallback trait, closures in Rust are simply particular traits. You can read more about how this works in Huon Wilson’s in-depth post on the topic.

  • Conditional APIs. Generics make it possible to implement a trait conditionally:

struct Pair<A, B> { first: A, second: B } impl<A: Hash, B: Hash> Hash for Pair<A, B> { fn hash(&self) -> u64 { self.first.hash() ^ self.second.hash() } }

Here, the Pair type implements Hash if, and only if, its components do – allowing the single Pair type to be used in different contexts, while supporting the largest API available for each context. It’s such a common pattern in Rust that there is built-in support for generating certain kinds of “mechanical” implementations automatically:

#[derive(Hash)] struct Pair<A, B> { .. }
  • Extension methods. Traits can be used to extend an existing type (defined elsewhere) with new methods, for convenience, similarly to C#’s extension methods. This falls directly out of the scoping rules for traits: you just define the new methods in a trait, provide an implementation for the type in question, and voila, the method is available.

  • Markers. Rust has a handful of “markers” that classify types: Send, Sync, Copy, Sized. These markers are just traits with empty bodies, which can then be used in both generics and trait objects. Markers can be defined in libraries, and they automatically provide #[derive]-style implementations: if all of a types components are Send, for example, so is the type. As we saw before, these markers can be very powerful: the Send marker is how Rust guarantees thread safety.

  • Overloading. Rust does not support traditional overloading where the same method is defined with multiple signatures. But traits provide much of the benefit of overloading: if a method is defined generically over a trait, it can be called with any type implementing that trait. Compared to traditional overloading, this has two advantages. First, it means the overloading is less ad hoc: once you understand a trait, you immediately understand the overloading pattern of any APIs using it. Second, it is extensible: you can effectively provide new overloads downstream from a method by providing new trait implementations.

  • Operators. Rust allows you to overload operators like + on your own types. Each of the operators is defined by a corresponding standard library trait, and any type implementing the trait automatically provides the operator as well.

The point: despite their seeming simplicity, traits are a unifying concept that supports a wide range of use cases and patterns, without having to pile on additional language features.

The future

One of the primary ways that languages tend to evolve is in their abstraction facilities, and Rust is no exception: many of our post-1.0 priorities are extensions of the trait system in one direction or another. Here are some highlights.

  • Statically dispatched outputs. Right now, it’s possible for functions to use generics for their parameters, but there’s no equivalent for their results: you cannot say “this function returns a value of some type that implements the Iterator trait” and have that abstraction compiled away. This is particularly problematic when you want to return a closure that you’d like to be statically-dispatched – you simply can’t, in today’s Rust. We want to make this possible, and have some ideas already.

  • Specialization. Rust does not allow overlap between trait implementations, so there is never ambiguity about which code to run. On the other hand, there are some cases where you can give a “blanket” implementation for a wide range of types, but would then like to provide a more specialized implementation for a few cases, often for performance reasons. We hope to propose a design in the near future.

  • Higher-kinded types (HKT). Traits today can only be applied to types, not type constructors – that is, to things like Vec<u8>, not to Vec itself. This limitation makes it difficult to provide a good set of container traits, which are therefore not included in the current standard library. HKT is a major, cross-cutting feature that will represent a big step forward in Rust’s abstraction capabilities.

  • Efficient re-use. Finally, while traits provide some mechanisms for reusing code (which we didn’t cover above), there are still some patterns of reuse that don’t fit well into the language today – notably, object-oriented hierarchies found in things like the DOM, GUI frameworks, and many games. Accommodating these use cases without adding too much overlap or complexity is a very interesting design problem, and one that Niko Matsakis has started a separate blog series about. It’s not yet clear whether this can all be done with traits, or whether some other ingredients are needed.

Of course, we’re at the eve of the 1.0 release, and it will take some time for the dust to settle, and for the community to have enough experience to start landing these extensions. But that makes it an exciting time to get involved: from influencing the design at this early stage, to working on implementation, to trying out different use cases in your own code – we’d love to have your help!

Categorieën: Mozilla-nl planet

Joel Maher: intermittent oranges- missing a real definition

Mozilla planet - zo, 10/05/2015 - 23:49

There are all kinds of great ideas folks have for fixing intermittent issues.  In fact each idea in and of itself is a worthwhile endeavor.   I have spent some time over the last couple of months fixing them, filing bugs on them, and really discussing them.  One question that remains- what is the definition of an intermittent.

I don’t plan to lay out a definition, instead I plan to ask some questions and lay out some parameters.  According to orange factor, there are 4640 failures in the last week (May 3 -> May 10) all within 514 unique bugs.  These are all failures that the sheriffs have done some kind of manual work on to star on treeherder.  I am not sure anybody can find a way to paint a pretty picture to make it appear we don’t have intermittent failures.

Looking at a few bugs, there are many reasons for intermittent failures:

  • core infrastructure (networking, power, large classes of machines (ec2), etc.)
  • machine specific (specific machine is failing a lot of jobs)
  • CI specific (buildbot issues, twisted issues, puppet issues, etc.)
  • CI Harness (usually mozharness)
  • Platforms (old platforms/tests we are phasing out, new platforms/tests we are phasing in)
  • Test harness (mochitest + libraries, common code for tests, reftest)
  • Test Cases (test cases actually causing failures, poorly written, new test cases, etc.)
  • Firefox Code (we actually have introduced conditions to cause real failures- just not every time)
  • Real regressions (failures which happen every time we run a test)

There are a lot of reasons, many of these have nothing to do with poor test cases or bad code in Firefox.  But many of these are showing up many times a day and as a developer who wants to fix a bad test, many are not really actionable.  Do we need to have some part of a definition to include something that is actionable?

Looking at the history of ‘intermittent-failure’ bugs in Bugzilla, many occur once and never occur again.  In fact this is the case for over half of the bugs filed (we file upwards of 100 new bugs/week).  While there are probably reasons for a given test case to fail, if it failed in August 2014 and has never failed again, is that test case intermittent?  As a developer could you really do anything about this given the fact that reproducing it is virtually impossible?

This is where I start to realize we need to find a way to identify real intermittent bugs/tests and not clutter the statistics with tests which are virtually impossible to reproduce.  Thinking back to what is actionable- I have found that while filing bugs for Talos regressions the closer the bug is filed to the original patch landing, the better the chance it will get fixed.  Adding to that point, we only keep 30 days of builds/test packages around for our CI automation.  I really think a definition of an intermittent needs to have some kind of concept of time.  Should we ignore intermittent failures which occur only once in 90 days?  Maybe ignore ones that don’t reproduce after 1000 iterations?  Some could argue that we look in a smaller or larger window of time/iterations.

Lastly, when looking into specific bugs, I find many times they are already fixed.  Many of the intermittent failures are actually fixed!  Do we track how many get fixed?  How many have patches and have debugging already taking place?  For example in the last 28 days, we have filed 417 intermittents, of which 55 are already resolved and of the remaining 362 only 25 have occurred >=20 times.  Of these 25 bugs, 4 already have patches.  It appears a lot of work is done to fix intermittent failures which are actionable.  Are the ones which are not being fixed not actionable?  Are they in a component where all the developers are busy and heads down?

In a perfect world a failure would never occur, all tests would be green, and all users would use Firefox.  In reality we have to deal with thousands of failures every week, most of which never happen again.  This quarter I would like to see many folks get involved in discussions and determine:

  • what is too infrequent to be intermittent? we can call this noise
  • what is the general threshold where something is intermittent?
  • what is the general threshold where we are too intermittent and need to backout a fix or disable a test?
  • what is a reasonable timeframe to track these failures such that we can make them actionable?

Thanks for reading, I look forward to hearing from many who have ideas on this subject.  Stay tuned for an upcoming blog post about re-trigging intermittent failures to find the root cause.

Categorieën: Mozilla-nl planet

Mike Conley: Things I’ve Learned This Week (May 4 – May 8, 2015)

Mozilla planet - zo, 10/05/2015 - 22:00
How to convert an NSString to a Gecko nsAString

I actually discovered this during my most recent Joy of Coding episode – there is a static utility method to convert between native Cocoa NSStrings and Gecko nsAStrings – nsCocoaUtils::GetStringForNSString. Very handy, and works exactly as advertised.

An “Attach to Process by pid” Keyboard Shortcut for XCode

I actually have colleague Garvan Keeley to thank for this one, and technically I learned this on April 24th. It was only this week that I remembered I had learned it!

When I’m debugging Firefox on OS X, I tend to use XCode, and I usually attach to Firefox after it has started running. I have to navigate some menus in order to bring up the dialog to attach to a process by pid, and I was getting tired of doing that over and over again.

So, as usual, I tweeted my frustration:

Dear lazyweb – is there an XCode keyboard shortcut for “Attach to Process” > “By Process Identifier (PID) or Name”? Mousing it blows.

— Mike Conley (@mike_conley) April 24, 2015


@mike_conley Yes. Shift-cmd-/, type ‘attach’, down arrow, enter, type proc name. next time, ‘attach’ and proc name is remembered. — Garvan Keeley (@garvankeeley) April 24, 2015

It seems small, but the savings in time for something that I do so frequently quickly adds up. And it always feels good to go faster!

Categorieën: Mozilla-nl planet

Firefox OS en Afrique : Mozilla et Orange déploient des mobiles -

Nieuws verzameld via Google - zo, 10/05/2015 - 18:05

Firefox OS en Afrique : Mozilla et Orange déploient des mobiles
Des smartphones fonctionnant avec le système mobile Firefox OS ont été déployés en Afrique. Cela fait écho à l'annonce faite par Mozilla au MWC de Barcelone en mars dernier. On trouve déjà le mobile Klif disponible au Sénégal et dans l'île de ...
Firefox OS arrive en Afrique, avec OrangeNumerama
Les premiers smartphones sous Firefox OS sont disponibles en AfriqueKultureGeek (Blog)
Firefox OS : les smartphones ont été lancés en AfriqueInfos Mobiles
alle 7 nieuwsartikelen »Google Nieuws
Categorieën: Mozilla-nl planet

Deze budgettelefoon brengt Mozilla naar Afrika - Apparata

Nieuws verzameld via Google - zo, 10/05/2015 - 12:38


Deze budgettelefoon brengt Mozilla naar Afrika
Firefox OS gaat de markt op in Afrika om zijn budgetlijn te verkopen. Hun doel: Internet voor iedereen. In een budgetmarkt die gedomineerd wordt door Android is het lastig doorbreken met je nieuwe OS. Dat weet Mozilla ook en daarom wijken ze uit naar ...
Mozilla verkoopt nu ook Firefox OS-telefoons in Madagascar en SenegalAll About Phones

alle 2 nieuwsartikelen »
Categorieën: Mozilla-nl planet

Mozilla verkoopt nu ook Firefox OS-telefoons in Madagascar en Senegal - All About Phones

Nieuws verzameld via Google - zo, 10/05/2015 - 10:46

All About Phones

Mozilla verkoopt nu ook Firefox OS-telefoons in Madagascar en Senegal
All About Phones
Het toestel is voorzien van het open-source besturingssysteem dat Mozilla zelf heeft ontworpen, Firefox OS. Dit op html gebaseerd besturingssysteem is met name bestemd voor low-end mobieltjes, maar biedt wel de gebruikerservaring van een smartphone.

Categorieën: Mozilla-nl planet

Andy McKay: Catching unused Python mocks

Mozilla planet - zo, 10/05/2015 - 09:00

It's easy for mocks to get out of hand and I've seen tests that have many mocks and patches. That in itself is bad enough, but I want to make sure that each mock is there for a reason. Over time tests get been copy and pasted or underlying code has changes - meaning mocks exist but are no longer used.

You can do this my asserting that each mock is called in the test. I've seen tests with that end up being 4 lines of mocks, a call, then 4 lines of checking the mocks are being called. Clearly, something was going wrong with those tests in the first place.

Anyway, I wanted to keep my tests clean in the future, so I added a registration step for mocks. Here's a simplified version:

def setUp(self): self.mocks = {} for name, obj in self.registered_mocks.items(): self.mocks[name] = OurMock(name, spec=obj) self.addCleanup(self.cleanUpMocks)

OurMock is a special mock that registers all the mocks registered against it. This pattern is pretty specific to the type of object I'm mocking in the tests:

class OurMock(mock.Mock): def __getattr__(self, name): if not name.startswith('_'): setattr(self, '_registered', []) self._registered.append(name) return super(OurMock, self).__getattr__(name)

Then on cleanUp:

def cleanUpMocks(self): for k, v in self.mocks.items(): for call in getattr(v, '_registered', []): if not getattr(v, call).called: raise MockError('{0}.{1} registered but not called.' .format(self.registered_mocks[k].__name__, call))

So a test now reads:

class Test(tests.TestCase): self.registered_mocks = {'some': object} def test_ok(self): self.mocks['some'].create.return_value = something()

In this example: create is in the list of _registered on the Mock. When the test completes we check it got called. If you run that test without anything else, it will fail because the mock never actually got called.

If what is passed to the mock is important, all the usual methods like assertcalledwith can be called.

This has already caught a few errors in my tests.

Categorieën: Mozilla-nl planet

Raniere Silva: MathML Accessibility

Mozilla planet - zo, 10/05/2015 - 05:00
MathML Accessibility

Frédéric Wang wrote a nice post about MathML Accessibility that has a comparison table between NVDA, VoiceOver and Orca.

I promised to Frédéric to provide a sample of the support of Firefox OS’ screen reader and you can find it here (it is a ogg file with the video in theora and the audio in vorbis).


For the test I used this app.

Leia mais...

Categorieën: Mozilla-nl planet

Cameron Kaiser: 31.7.0 available

Mozilla planet - zo, 10/05/2015 - 02:46
31.7.0 is now available for testing (release notes, downloads, hashes). Although there is no new functionality or Power Mac-specific changes in this release, builders will notice some moderate churn in the changesets due to Mozilla invalidating about a third of them with a purely stylistic change to JavaScript code, making this release somewhat more troublesome than it had to be. (I don't know why they bothered doing that with a branch they plan to sunset in only about two more release cycles, but I digress.) It will finalize on Monday evening Pacific time as usual.

38 is on time for a beta release in a few weeks, though I need to do some more prophylactic changes to its changesets as well for the same reason. Once the 38 beta gets off the ground, then we will begin the final exodus from Google Code.

Categorieën: Mozilla-nl planet

Mozilla launches Firefox OS phones in Morocco and Senegal - Engadget

Nieuws verzameld via Google - za, 09/05/2015 - 13:48


Mozilla launches Firefox OS phones in Morocco and Senegal
Firefox OS might be in a distant fourth place (or further?) here domestically, but Mozilla sees plenty of value for it in emerging countries. Specifically? Senegal and Madagascar in Africa, where it recently partnered with French telecom Orange to ...

Categorieën: Mozilla-nl planet

Mozilla、アフリカ市場で「Firefox OS」搭載端末の提供を開始へ - ガジェット速報

Nieuws verzameld via Google - za, 09/05/2015 - 13:34


Mozilla、アフリカ市場で「Firefox OS」搭載端末の提供を開始へ
既に先日には南アフリカ市場に対してもFirefox OS端末の投入が開始されていましたが、今回Mozillaは現地キャリアのOrangeとパートナーを組み、新たにセネガルとマダガスカルの2ヶ国においてFirefox OS端末の提供開始を発表。 Orange独占モデルとなる「Orange Klif」は、 ...

Google Nieuws
Categorieën: Mozilla-nl planet

Andy McKay: Preventing typos with Python mock

Mozilla planet - za, 09/05/2015 - 09:00

Python mock is pretty cool, but there's been a recurring problem for me with mock in that if you access any property on a Mock it returns a method which is truthy. This means simple typos can exist in your testing.

As an example, in this library, there's a method from_nonce. If you just mock the object, then you can typo the method and it continues like normal:

>>> with mock.patch('braintree.CreditCard') as mocked: ... assert mocked.from_none ...

This has happened to me and I didn't notice when I'd typo'd a mock call, like is_called. The test were wrong, but passed quite happily.

The better way is to pass the object to the Mock call as spec. Then only methods on the object can be called, for example:

>>> with mock.patch('braintree.CreditCard', spec=braintree.CreditCard) as mocked: ... assert mocked.from_none ... Traceback (most recent call last): [..snip] File "/Users/andy/.virtualenvs/solitude/lib/python2.7/site-packages/", line 658, in __getattr__ raise AttributeError("Mock object has no attribute %r" % name) AttributeError: Mock object has no attribute 'from_none'

Much better.

Categorieën: Mozilla-nl planet

Mike Conley: The Joy of Coding (Ep. 11): Cleaning up the View Source Patch

Thunderbird - za, 25/04/2015 - 23:22

For this episode, Richard Milewski and I figured out the syncing issue I’d been having in Episode 9, so I had my head floating in the bottom right corner while I hacked. Now you can see what I do with my face while hacking, if that’s a thing you had been interested in.

I’ve also started mirroring the episodes to YouTube, if YouTube is your choice platform for video consumption.

So, like last week, I was under a bit of time pressure because of a meeting scheduled for 2:30PM (actually the meeting I was supposed to have the week before – it just got postponed), so that gave me 1.5 hours to move forward with the View Source work we’d started back in Episode 8.

I started the episode by explaining that the cache key stuff we’d figured out in Episode 9 was really important, and that a bug had been filed by the Necko team to get the issue fixed. At the time of the video, there was a patch up for review in that bug, and when we applied it, we were able to retrieve source code out of the network cache after POST requests! Success!

Now that we had verified that our technique was going to work, I spent the rest of the episode cleaning up the patches we’d written. I started by doing a brief self-code-review to smoke out any glaring problems, and then started to fix those problems.

We got a good chunk of the way before I had to cut off the camera.

I know back when I started working on this particular bug, I had said that I wanted to take you through right to the end on camera – but the truth of the matter is, the priority of the bug went up, and I was moving too slowly on it, since I was restricting myself to a few hours on Wednesdays. So unfortunately, after my meeting, I went back to hacking on the bug off-camera, and yesterday I put up a patch for review. Here’s the review request, if you’re interested in seeing where I got to!

I felt good about the continuity experiment, and I think I’ll try it again for the next few episodes – but I think I’ll choose a lower-priority bug; that way, I think it’s more likely that I can keep the work contained within the episodes.

How did you feel about the continuity between episodes? Did it help to engage you, or did it not matter? I’d love to hear your comments!

Episode Agenda


Bug 1025146 – [e10s] Never load the source off of the network when viewing sourceNotes

Categorieën: Mozilla-nl planet

Meeting Notes: Thunderbird: 2015-04-21

Thunderbird - wo, 22/04/2015 - 05:00

Thunderbird meeting notes 2015-04-21. NOON PT (Pacific). Check for meeting time conversion, previous meeting notes and call-in details


ATTENDEES – put your nick 1. below 2. in comments unless explicit under round table 3. top right of etherpad next to your color

mkmelin, rolandt, pegasus, makemyday jorgk, rkent, gneandr, aceman, merike, Paenglab, wsmwk

Action items from last meetings
  • (rkent, Fallen) AMO addon compat: TheOne said that this late it is probably not worth doing at all. WIth so many other things for me to do, that sounds like a plan.
Friends of the tree
  • glandium, for fixing the various packager bugs that will help package Lightning (nominated by Fallen, who won’t be at the meeting)
Critical Issues

Critical bugs. Leave these here until they’re confirmed fixed. If confirmed, then remove.

  • (rkent) I am enormously frustrated by the inability to get two critical features landed in tb 38: OAuth and Lightning integration. Can we please give this very high priority?
    • OAuth integration: partial landing for beta 2, really REALLY critical that we get this finished.
  • In general, the tracking-tb38 flag shows what are critical issues. In the next week or so, that list will be culled to only include true blockers for the Thunderbird 38 release. There will still be many.
  • I don’t think we have a reasonable chance of shipping a quality release on May 12. More realistic is June 2.
  • We need to decide on how to do release branching. I am uncertain whether Lightning integration requires this or not.
  • Auto-complete improvements – some could go into esr31 (bug 1042561 included in TB38)
  • Lightning integration (below) really REALLY critical that we get this finished.
  • maildir UI: nothing more to do for UI, still want to land a patch for letting IMAP set this.
  • gloda IM search regressions: mostly fixed, some db cleanup necessary for users of TB33+ that nhnt11 will hopefully have ready to land soon.
    • aleth landed a fix to stop duplicated entries from appearing, nhnt11 will take care of the cleaning up the databases of Aurora/Beta/Daily users this weekend and keep us updated
  • bug 1140884, might need late-l10n

removing from critical list/fixed:

  • ldap crash bug 1063829: a patch in beta 37, beta results are unclear – not seen in 38
  • bug 1064230 crashes during LDAP search made worse by Search All Addressbooks bug 170270, needs tracking 38+ and review?rkent/jcranmer – not seen in 38
  • everyone should probably skim version 31-38 regressions for items they can help fix or direct to the right people
  • Past
    • 31.6.0 shipped
    • 38.0b1 shipped 2015-04-03
    • 38.0b2 shipped 2015-04-20
  • Upcoming
    • 38.0b3 (when?)
Lightning to Thunderbird Integration


  • As underpass has pointed out repeatedly (thanks for your patience!) , we need to rewrite / heavily modify the lightning articles on let me know irc: rolandtanglao on #tb-support-crew or rtanglao AT OR simply start editing the articles

Unfortunately not much progress because I was away. I hope to have the packaging bits done until the weekend. Glandium did a great job on the changes, hence I nominated him for Friends of the Tree. (fallen)

MakeMyDay should comment on the opt-out dialog, I think we should get it landed asap. bug 1130852 – Opt-Out dialog had some discussion on prefs

Round Table wsmwk
  • managed shipping of 31.6.0, 38.0b1, 38.0b2
Jorg K rkent
  • We have the beginnings of a business development group (rkent, wsmwk, magnus) that after signing NDAs will be given access to Thunderbird business documentation.
  • bug 1134986 autocomplete bug investigated and landed on trunk +++
aceman Question Time

– PLEASE INCLUDE YOUR NICK with your bullet item —

  • What happened to the Avocet branding? (Jorg K)
    • won’t be persued
  • Info about the meeting with Mitchell Baker on 20th March 2015, funding issues (Jorg K)
  • can we get hiro’s bugs reassigned so the patches contained can get landed, and not lost? (wsmwk)
  • It would be great if some jetpack add-on support were available in thunderbird to share functionality with firefox and fennec. See also bug 1100644. No useful jetpack add-ons seem to exist for thunderbird (earlybird would be fine to use jpm over cfx). Are there any jetpack add-ons available to prove me wrong?

(pegasus) Is it worth looking at going to a 6-week release schedule to avoid the conundrum with getting not-quite-ready features in vs delaying?

Support team
  • Reminder: Roland is leaving Thunderbird May 12, 2015 after the release of Thunderbird 38: working on Thunderbird 38 plan and finally kickstarting Thunderbird User Success Council
    • looking for 3 people: English KB Article Editor, L10N Coordinator and Forum Lead. Is that you we’re looking for? If so email rtanglao AT or ping  :rolandtanglao in #sumo or #tb-support-crew
  • Note – meeting notes must be copied from etherpad to wiki before 5AM CET next day so that they will go public in the meeting notes blog.
Action Items
  • wsmwk to pat glandium
  • wsmwk to email hiro’s bug list to tb-planning
  • rkent to review tracking list
Retrieved from “

Categorieën: Mozilla-nl planet

Rumbling Edge - Thunderbird: 2015-04-20 Calendar builds

Thunderbird - wo, 22/04/2015 - 04:17

Common (excluding Website bugs)-specific: (6)

  • Fixed: 1003196 – Add icons to more imip bar buttons
  • Fixed: 1137673 – extra divider in the options menu of new task dialog
  • Fixed: 1146500 – Wrong first occurrence for monthly recurrence with BYDAY and BYMONTHDAY
  • Fixed: 1150707 – Make use of tags for running only icaljs/libcal tests
  • Fixed: 1150882 – Lightning incorrectly unified after bug 1143163
  • Fixed: 1151404 – Nightly Windows x64 lightning hits 404 when updating

Sunbird will no longer be actively developed by the Calendar team.

Windows builds Official Windows

Linux builds Official Linux (i686), Official Linux (x86_64)

Mac builds Official Mac

Categorieën: Mozilla-nl planet

Rumbling Edge - Thunderbird: 2015-04-20 Thunderbird comm-central builds

Thunderbird - wo, 22/04/2015 - 04:16

Thunderbird-specific: (27)

  • Fixed: 768480 – Mac OSX TB 13 crashes in nsMsgDBFolder::CreateFileForDB when going online. Caused by folder subscribed on server that no longer exists?
  • Fixed: 849540 – Log in to Gmail (IMAP/SMTP) using OAuth in backend
  • Fixed: 939462 – Feature to count and show number of unread e-mails in subfolders should be optional. (because enumeration is slow)
  • Fixed: 1054308 – Investigate switching Thunderbird comm-central MozMill tests to mozharness
  • Fixed: 1118263 – C-C TB: JavaScript 1.6’s for-each-in loops are deprecated in accountprovisioner and about-support
  • Fixed: 1130852 – Add opt-out notification for calendar integration
  • Fixed: 1134234 – resource://app/modules/gloda/mimemsg.js should be resource:///modules/gloda/mimemsg.js in /mail/test/mozmill/shared-modules/test-message-helpers.js
  • Fixed: 1134986 – Address autocomplete sorting wrong – appears to ignore recent use (popularityindex) information in 31.4.0+
  • Fixed: 1138478 – ‘Write’ toolbar button disabled/greyed out after opening the menus in the Saved Files tab
  • Fixed: 1139524 – Font indicator doesn’t update when cursor is placed in text with this font
  • Fixed: 1140720 – Error reading font prefs in the Slovenian locale
  • Fixed: 1145970 – Port Bug 1005105 to TB [Remove noise from tab textures]
  • Fixed: 1145974 – Move more styles to shared addressbook.css
  • Fixed: 1147006 – TB shows instructions with [File] – [Offline] – [Synchronize] instead of [Download/Sync Now]
  • Fixed: 1147526 – Port Bug 1147311: migrateUI() should migrate to a supported value
  • Fixed: 1148369 – “invalid ‘in’ operand colState” when switching folders
  • Fixed: 1148503 – TEST-UNEXPECTED-FAIL | toolkit/components/telemetry/tests/unit/test_TelemetryPing.js | xpcshell return code: 0
  • Fixed: 1149275 – Ensure newly opened conversations get focused
  • Fixed: 1150051 – C-C TB: EXCEPTION: formatted size is not numeric: ‘Read’
  • Fixed: 1150073 – C-C TB: Exception: Found visible column ‘correspondentCol’ but was expecting ‘recipientCol’!
  • Fixed: 1151223 – Reorder mail’s to minimize differences to browser’s version
  • Fixed: 1152045 – Email address missing from “From” field on emails sent through Thunderbird 38 if the identityName pref was set
  • Fixed: 1152852 – Notification sound for highlights in chats not played if chat tab is selected, even when Thunderbird is not the currently active/focused application (in background)
  • Fixed: 1153511 – TEST-UNEXPECTED_FAIL | | build file copies are not in sync: differing file: ./win32/mozconfig.vs2013-win64
  • Fixed: 1153551 – Priority button : description missing
  • Fixed: 1154799 – “this._browser.messageManager is undefined” error just by starting Thunderbird
  • Fixed: 1156049 – Port ‘Bug 1155476 – Update sccache to 155c926′ to fix failure.

MailNews Core-specific: (30)

  • Fixed: 306035 – mail server appended to usernames with “@” (Password dialog for IMAP says <alias>@<domain>@<mailserver> instead of <alias>@<domain> on(at/…) <mailserver>)
  • Fixed: 662907 – web site from RSS feed not rendered correctly (due to noscript tags)
  • Fixed: 810495 – Make the classes which use the XPCOM nsISupports implementation macros final, to avoid the warning about deleting using a pointer to a base class with virtual functions and no virtual dtor
  • Fixed: 1123124 – Remove use of expression closures in mailnews/
  • Fixed: 1126607 – Kill the LDAP build system
  • Fixed: 1132218 – Update comm-central for PLDHashTable changes in bug 1131901
  • Fixed: 1139167 – Some birthdays are off by one day in Thunderbird’s addressbook
  • Fixed: 1139965 – Implement function to export addressbook in vCard format
  • Fixed: 1140652 – deduplicate some JS code writing out a simple string to a file in profile
  • Fixed: 1140884 – An error occurred while sending mail garbled
  • Fixed: 1141735 – unaligned labels in the LDAP server Advanced properties tab
  • Fixed: 1144621 – mimemsg.cpp might leak memory in some instances
  • Fixed: 1144719 – Allow the user to decide whether or not to use libnotify for new-mail alerts on Linux
  • Fixed: 1148887 – Message string for SMTP server connection error is incorrect. File:, key: smtpSendRefused
  • Fixed: 1148888 – Message string for SMTP server connection error is incorrect. File:, key: smtpAuthNotSupported
  • Fixed: 1148957 – Port bug 1148463 by backing out bug 1144128: temporarily disable new performance tools for Aurora uplift
  • Fixed: 1149247 – remove deprecated for-each-in loops in the account manager and account wizard
  • Fixed: 1150176 – Remove nsMemory::Alloc/Free/Realloc from c-c following their removal in bug 1134920
  • Fixed: 1150967 – Port Bug 1147839 to comm-central – Fix building installer on mingw by only including helper.exe if mknsisu is used
  • Fixed: 1150981 – Port Bug 674779 to comm-central – Add per-compartment CPU accounting
  • Fixed: 1151002 – Port Bug 1120308 to comm-central – [Presentation WebAPI] control protocol establishment and offer-answer exchange
  • Fixed: 1151181 – uninitialized error string in mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp
  • Fixed: 1152287 – TEST-UNEXPECTED-FAIL | crypto | Failed to find the appropraite data_path
  • Fixed: 1153187 – Build process is broken while reticulating splines “Variable SHARED_LIBRARY_LIBS” involved.
  • Fixed: 1153543 – when adding a new identity, the smtp server menulist is collapsed with no default item selected
  • Fixed: 1153557 – do away with preprocessing in am-identity-edit.js due to identity.autocompleteToMyDomain
  • Fixed: 1154468 – unused function getServerIdAndPageIdFromTree in am-identity-edit.xul
  • Fixed: 1155951 – Fix a non-array delete for scalars
  • Fixed: 1155953 – Remove Structurally dead code in nsNNTPProtocol.cpp
  • Fixed: 1155955 – remove a self assignment in nsImapUtils.cpp

Windows builds Official Windows, Official Windows installer

Linux builds Official Linux (i686), Official Linux (x86_64)

Mac builds Official Mac

Categorieën: Mozilla-nl planet

Mike Conley: Things I’ve Learned This Week (April 13 – April 17, 2015)

Thunderbird - zo, 19/04/2015 - 00:33
When you send a sync message from a frame script to the parent, the return value is always an array


// Some contrived code in the browser let browser = gBrowser.selectedBrowser; browser.messageManager.addMessageListener("GIMMEFUE,GIMMEFAI", function onMessage(message) { return "GIMMEDABAJABAZA"; }); // Frame script that runs in the browser let result = sendSendMessage("GIMMEFUE,GIMMEFAI"); console.log(result[0]); // Writes to the console: GIMMEDABAJABAZA

From the documentation:

Because a single message can be received by more than one listener, the return value of sendSyncMessage() is an array of all the values returned from every listener, even if it only contains a single value.

I don’t use sync messages from frame scripts a lot, so this was news to me.

You can use [cocoaEvent hasPreciciseScrollingDeltas] to differentiate between scrollWheel events from a mouse and a trackpad

scrollWheel events can come from a standard mouse or a trackpad1. According to this Stack Overflow post, one potential way of differentiating between the scrollWheel events coming from a mouse, and the scrollWheel events coming from a trackpad is by calling:

bool isTrackpad = [theEvent hasPreciseScrollingDeltas];

since mouse scrollWheel is usually line-scroll, whereas trackpads (and Magic Mouse) are pixel scroll.

The srcdoc attribute for iframes lets you easily load content into an iframe via a string

It’s been a while since I’ve done web development, so I hadn’t heard of srcdoc before. It was introduced as part of the HTML5 standard, and is defined as:

The content of the page that the embedded context is to contain. This attribute is expected to be used together with the sandbox and seamless attributes. If a browser supports the srcdoc attribute, it will override the content specified in the src attribute (if present). If a browser does NOT support the srcdoc attribute, it will show the file specified in the src attribute instead (if present).

So that’s an easy way to inject some string-ified HTML content into an iframe.

Primitives on IPDL structs are not initialized automatically

I believe this is true for structs in C and C++ (and probably some other languages) in general, but primitives on IPDL structs do not get initialized automatically when the struct is instantiated. That means that things like booleans carry random memory values in them until they’re set. Having spent most of my time in JavaScript, I found that a bit surprising, but I’ve gotten used to it. I’m slowly getting more comfortable working lower-level.

This was the ultimate cause of this crasher bug that dbaron was running into while exercising the e10s printing code on a debug Nightly build on Linux.

This bug was opened to investigate initializing the primitives on IPDL structs automatically.

Networking is ultimately done in the parent process in multi-process Firefox

All network requests are proxied to the parent, which serializes the results back down to the child. Here’s the IPDL protocol for the proxy.

On bi-directional text and RTL

gw280 and I noticed that in single-process Firefox, a <select> dropdown set with dir=”rtl”, containing an <option> with the value “A)” would render the option as “(A”.

If the value was “A) Something else”, the string would come out unchanged.

We were curious to know why this flipping around was happening. It turned out that this is called “BiDi”, and some documentation for it is here.

If you want to see an interesting demonstration of BiDi, click this link, and then resize the browser window to reflow the text. Interesting to see where the period on that last line goes, no?

It might look strange to someone coming from a LTR language, but apparently it makes sense if you’re used to RTL.

I had not known that.

Some terminal spew Some terminal spew

Now what’s all this?

My friend and colleague Mike Hoye showed me the above screenshot upon coming into work earlier this week. He had apparently launched Nightly from the terminal, and at some point, all that stuff just showed up.

“What is all of that?”, he had asked me.

I hadn’t the foggiest idea – but a quick DXR showed inside Breakpad, the tool used to generate crash reports when things go wrong.

I referred him to bsmedberg, since that fellow knows tons about crash reporting.

Later that day, mhoye got back to me, and told me that apparently this was output spew from Firefox’s plugin hang detection code. Mystery solved!

So if you’re running Firefox from the terminal, and suddenly see some stuff show up… a plugin you’re running probably locked up, and Firefox shanked it.

  1. And probably a bunch of other peripherals as well 

Categorieën: Mozilla-nl planet

Mike Conley: The Joy of Coding (Ep. 10): The Mystery of the Cache Key

Thunderbird - za, 18/04/2015 - 23:40

In this episode, I kept my camera off, since I was having some audio-sync issues1.

I was also under some time-pressure, because I had a meeting scheduled for 2:30 ET2, giving me exactly 1.5 hours to do what I needed to do.

And what did I need to do?

I needed to figure out why an nsISHEntry, when passed to nsIWebPageDescriptor’s loadPage, was not enough to get the document out from the HTTP cache in some cases. 1.5 hours to figure it out – the pressure was on!

I don’t recall writing a single line of code. Instead, I spent most of my time inside XCode, walking through various scenarios in the debugger, trying to figure out what was going on. And I eventually figured it out! Read this footnote for the TL;DR:3

Episode Agenda


Bug 1025146 – [e10s] Never load the source off of the network when viewing sourceNotes

  1. I should have those resolved for Episode 11! 

  2. And when the stream finished, I found out the meeting had been postponed to next week, meaning that next week will also be a short episode. :( 

  3. Basically, the nsIChannel used to retrieve data over the network is implemented by HttpChannelChild in the content process. HttpChannelChild is really just a proxy to a proper nsIChannel on the parent-side. On the child side, HttpChannelChild does not implement nsICachingChannel, which means we cannot get a cache key from it when creating a session history entry. With no cache key, comes no ability to retrieve the document from the network cache via nsIWebDescriptor’s loadPage. 

Categorieën: Mozilla-nl planet

Mike Conley: Things I’ve Learned This Week (April 6 – April 10, 2015)

Thunderbird - zo, 12/04/2015 - 16:50
It’s possible to synthesize native Cocoa events and dispatch them to your own app

For example, here is where we synthesize native mouse events for OS X. I think this is mostly used for testing when we want to simulate mouse activity.

Note that if you attempt to replay a queue of synthesized (or cached) native Cocoa events to trackSwipeEventWithOptions, those events might get coalesced and not behave the way you want. mstange and I ran into this while working on this bug to get some basic gesture support working with Nightly+e10s (Specifically, the history swiping gesture on OS X).

We were able to determine that OS X was coalescing the events because we grabbed the section of code that implements trackSwipeEventWithOptions, and used the Hopper Disassembler to decompile the assembly into some pseudocode. After reading it through, we found some logging messages in there referring to coalescing. We noticed that those log messages were only sent when NSDebugSwipeTrackingLogic was set to true, we executed this:

defaults write org.mozilla.nightlydebug NSDebugSwipeTrackingLogic -bool YES

In the console, and then re-ran our swiping test in a debug build of Nightly to see what messages came out. Sure enough, this is what we saw:

2015-04-09 15:11:55.395 firefox[5203:707] ___trackSwipeWithScrollEvent_block_invoke_0 coalescing scrollevents 2015-04-09 15:11:55.395 firefox[5203:707] ___trackSwipeWithScrollEvent_block_invoke_0 cumulativeDelta:-2.000 progress:-0.002 2015-04-09 15:11:55.395 firefox[5203:707] ___trackSwipeWithScrollEvent_block_invoke_0 cumulativeDelta:-2.000 progress:-0.002 adjusted:-0.002 2015-04-09 15:11:55.396 firefox[5203:707] ___trackSwipeWithScrollEvent_block_invoke_0 call trackingHandler(NSEventPhaseChanged, gestureAmount:-0.002)

This coalescing means that trackSwipeEventWithOptions is only getting a subset of the events that we’re sending, which is not what we had intended. It’s still not clear what triggers the coalescing – I suspect it might have to do with how rapidly we flush our native event queue, but mstange suspects it might be more sophisticated than that. Unfortunately, the pseudocode doesn’t make it too clear.

String templates and toSource might run the risk of higher memory use?

I’m not sure I “learned” this so much, but I saw it in passing this week in this bug. Apparently, there was some section of the Marionette testing framework that was doing request / response logging with toSource and some string templates, and this caused a 20MB regression on AWSY. Doing away with those in favour of old-school string concatenation and JSON.stringify seems to have addressed the issue.

When you change the remote attribute on a <xul:browser> you need to re-add the <xul:browser> to the DOM tree

I think I knew this a while back, but I’d forgotten it. I actually re-figured it out during the last episode of The Joy of Coding. When you change the remoteness of a <xul:browser>, you can’t just flip the remote attribute and call it a day. You actually have to remove it from the DOM and re-add it in order for the change to manifest properly.

You also have to re-add any frame scripts you had specially loaded into the previous incarnation of the browser before you flipped the remoteness attribute.1

Using Mercurial, and want to re-land a patch that got backed out? hg graft is your friend!

Suppose you got backed out, and want to reland your patch(es) with some small changes. Try this:

hg update -r tip hg graft --force BASEREV:ENDREV

This will re-land your changes on top of tip. Note that you need –force, otherwise Mercurial will skip over changes it notices have already landed in the commit ancestry.

These re-landed changes are in the draft stage, so you can update to them, and assuming you are using the evolve extension2, and commit –amend them before pushing. Voila!

Here’s the documentation for hg graft.

  1. We sidestep this with browser tabs by putting those browsers into “groups”, and having any new browsers, remote or otherwise, immediately load a particular set of framescripts. 

  2. And if you’re using Mercurial, you probably should be. 

Categorieën: Mozilla-nl planet