On maemo we found that it is better to simply cleanup LayerManagerOGL resources when browser goes to background, and call Initialize() again when it comes to foreground. (instead of LayerManager switch HW->SW which has some problems with ShadowLayers). It works mostly fine, but we should also cleanup Texture based resources which are keeping reference to GLContext (invalid after CleanupResources call) and later might crash.
Created attachment 588605 [details] [diff] [review] Cleanup texture resources This should cleanup most of resources.
Created attachment 588824 [details] [diff] [review] Minor modification for reftests (Null check for root layer)
https://hg.mozilla.org/mozilla-central/rev/797896e68634 (merge from inbound)