Closed Bug 941544 Opened 11 years ago Closed 10 years ago

Running self.apps.runningApps().keys() again after launching an app throws a TypeError message

Categories

(Firefox OS Graveyard :: Gaia::UI Tests, defect)

All
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(b2g-v2.0 fixed)

RESOLVED FIXED
Tracking Status
b2g-v2.0 --- fixed

People

(Reporter: gkw, Unassigned, Mentored)

References

Details

(Keywords: testcase, Whiteboard: [fuzzblocker] [lang=py])

Attachments

(2 files, 1 obsolete file)

Attached file marionette log (obsolete) —
After B2G Desktop launches, self.apps.runningApps().keys() # No TypeError here. self.apps.launch('browser') self.apps.runningApps().keys() # TypeError appears here. is a Marionette testcase that causes the following TypeError: 1385030340610 Marionette INFO sendToClient: {"from":"0","error":{"message":"TypeError: window.wrappedJSObject.WindowManager is undefined","status":17,"stacktrace":"execute_script @gaia_test.py, line 119\ninline javascript, line 73\nsrc: \" let runningApps = window.wrappedJSObject.WindowManager.getRunningApps();\""}}, {30f3fca8-d151-3f45-b048-79d86647dc68}, {30f3fca8-d151-3f45-b048-79d86647dc68} on gaia rev e8fc65323606c4b0df848c23b13a483d0da37baf with lockscreen disabled via: https://developer.mozilla.org/en-US/Firefox_OS/Using_the_B2G_desktop_client#Creating_a_custom-settings.json Tested on a local B2G Desktop build on Mac, running gaiatest 0.19 from pip, with the following application.ini info: [App] Vendor=Mozilla Name=B2G Version=26.0 BuildID=20131121001711 SourceRepository=http://hg.mozilla.org/releases/mozilla-b2g26_v1_2 SourceStamp=36c4c667b9f2 ID={3c2e2abc-06d4-11e1-ac3b-374f68613e61}
Flags: needinfo?(mdas)
(From the attachment) We can see that the first call to self.apps.runningApps().keys() succeeds: DEBUG Got request: execute, data: {"to":"0","sessionId":"6-b2g","name":"executeScript","parameters":{"specialPowers":false,"scriptTimeout":null,"newSandbox":true,"args":[],"filename":"gaia_test.py","script":"return GaiaApps.getRunningApps()","line":119}}, id: {4c6c01df-68ce-a942-b789-8acfc5763a1c} INFO sendToClient: {"from":"0","value":{"homescreen":{"origin":"http://homescreen.gaiamobile.org:8080","name":"Homescreen","manifest":{"name":"Homescreen","description":"Gaia Homescreen","launch_path":"/index.html#root","type":"certified","role":"homescreen","developer":{"name":"The Gaia Team","url":"https://github.com/andreasgal/gaia"},"permissions":{"mobileconnection":{},"webapps-manage":{},"systemXHR":{},"settings":{"access":"readwrite"},"open-remote-window":{},"storage":{},"geolocation":{},"alarms":{},"power":{}},"locales":{"ar":{"name":"الشاشة الرئيسية","description":"Gaia الشاشة الرئيسية"},"en-US":{"name":"Homescreen","description":"Gaia Homescreen"},"fr":{"name":"Écran d’accueil","description":"Écran d’accueil Gaia"},"zh-TW":{"name":"主畫面","description":"Gaia 主畫面"}},"default_locale":"en-US","icons":{"30":"/style/icons/HomeScreen.png"},"orientation":"default","activities":{"save-bookmark":{"filters":{"type":"url","url":{"required":true,"pattern":"https?:.{1,16384}"}},"disposition":"inline","href":"/save-bookmark.html","returnValue":true}},"messages":[{"alarm":"/index.html"}]}}}}, {4c6c01df-68ce-a942-b789-8acfc5763a1c}, {4c6c01df-68ce-a942-b789-8acfc5763a1c} but not the second call, which fails with a TypeError: DEBUG Got request: execute, data: {"to":"0","sessionId":"6-b2g","name":"executeScript","parameters":{"specialPowers":false,"scriptTimeout":null,"newSandbox":true,"args":[],"filename":"gaia_test.py","script":"return GaiaApps.getRunningApps()","line":119}}, id: {30f3fca8-d151-3f45-b048-79d86647dc68} INFO sendToClient: {"from":"0","error":{"message":"TypeError: window.wrappedJSObject.WindowManager is undefined","status":17,"stacktrace":"execute_script @gaia_test.py, line 119\ninline javascript, line 73\nsrc: \" let runningApps = window.wrappedJSObject.WindowManager.getRunningApps();\""}}, {30f3fca8-d151-3f45-b048-79d86647dc68}, {30f3fca8-d151-3f45-b048-79d86647dc68} No matter how many times self.apps.runningApps().keys() is run, when we launch new apps, we should be able to use runningApps() to get the state of apps that are currently launched at any given point in time.
... and I realise that this may not be a bug in Marionette, but rather in gaiatest? Not sure - or this could have its component changed to Gaia::UI Tests.
Component: Marionette → Gaia::UI Tests
Product: Testing → Firefox OS
Flags: needinfo?(mdas)
Whiteboard: [fuzzblocker]
Our CI is seeing this, here: http://qa-selenium.mv.mozilla.com:8080/view/B2G%20Hamachi/job/b2g.hamachi.mozilla-central.master.perf.fps/899/console Pretty much, all stacks in that job look like this: 15:37:18 2013-12-12 15:37:18 | B2GPerfRunner | INFO | Running B2GPerfScrollContactsTest 15:37:18 2013-12-12 15:37:18 | B2GPopulate | INFO | Populating 200 contacts 15:38:45 Traceback (most recent call last): 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/b2gperf/b2gperf.py", line 244, in measure_app_perf 15:38:45 test.run() 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/b2gperf/b2gperf.py", line 355, in run 15:38:45 self.setup() 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/b2gperf/b2gperf.py", line 461, in setup 15:38:45 B2GPerfTest.setup(self) 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/b2gperf/b2gperf.py", line 347, in setup 15:38:45 self.apps.kill_all() 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/gaiatest/gaia_test.py", line 116, in kill_all 15:38:45 self.marionette.execute_async_script("GaiaApps.killAll()") 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/marionette/marionette.py", line 1073, in execute_async_script 15:38:45 filename=os.path.basename(frame[0])) 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/marionette/marionette.py", line 577, in _send_message 15:38:45 self._handle_error(response) 15:38:45 File "/var/jenkins/workspace/b2g.hamachi.mozilla-central.master.perf.fps/.env/local/lib/python2.7/site-packages/marionette/marionette.py", line 612, in _handle_error 15:38:45 raise JavascriptException(message=message, status=status, stacktrace=stacktrace) 15:38:45 JavascriptException: TypeError: window.wrappedJSObject.WindowManager is undefined 15:38:45 stacktrace: 15:38:45 execute_async_script @gaia_test.py, line 116 15:38:45 inline javascript, line 154 15:38:45 src: " let runningApps = window.wrappedJSObject.WindowManager.getRunningApps();"
Dave, do you know what needs to be done here? This blocks fuzzing (at least our prototype) and now it's also showing up in CI automation.
Flags: needinfo?(dave.hunt)
Comment 4 will be fixed when I release a b2gperf version with the latest gaiatest and therefore include the atoms after having been updated with the app window manager. Your issue may be related Gary - try upgrading to gaiatest 0.21 or later. See also bug 949459 for making the gaia atoms backwards compatible.
Flags: needinfo?(dave.hunt)
No, the issue has not gone away. Using: https://ftp.mozilla.org/pub/mozilla.org/b2g/tinderbox-builds/mozilla-aurora-macosx64_gecko/1388788745/b2g-28.0a2.multi.mac64.dmg I ran: /path/to/B2G.app/Contents/MacOS/b2g-bin -profile /path/to/B2G.app/Contents/MacOS/gaia/profile/ with the testcase (named "test_gaiatest_bug.py"): === import gaiatest import marionette mari = marionette.Marionette() mari.start_session() apps = gaiatest.GaiaApps(mari) # gaiatest bug print apps.running_apps apps.launch('browser') print apps.running_apps # fails === then used gaiatest 0.21.2: $ gaiatest --address=localhost:2828 --testvars=testVars.json --restart test_gaiatest_bug.py starting httpd running webserver on http://10.250.7.83:49527/ [<gaiatest.gaia_test.GaiaApp object at 0x10608fad0>, <gaiatest.gaia_test.GaiaApp object at 0x10608fc10>] Traceback (most recent call last): File "/Users/skywalker/trees/virtualenv-b2g/bin/gaiatest", line 9, in <module> load_entry_point('gaiatest==0.21.2', 'console_scripts', 'gaiatest')() File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/gaiatest/runtests.py", line 49, in main cli(runner_class=GaiaTestRunner, parser_class=GaiaTestOptions) File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/runtests.py", line 28, in cli runner = startTestRunner(runner_class, options, tests) File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/runtests.py", line 19, in startTestRunner runner.run_tests(tests) File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/runner/base.py", line 718, in run_tests self.run_test(test) File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/runner/base.py", line 836, in run_test **self.test_kwargs) File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/marionette_test.py", line 297, in add_tests_to_suite test_mod = imp.load_source(mod_name, filepath) File "/Users/skywalker/fuzzing/experimental/prototype-marifuzz/test_gaiatest_bug.py", line 11, in <module> print apps.running_apps # fails File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/gaiatest/gaia_test.py", line 142, in running_apps 'return GaiaApps.getRunningApps();') File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/marionette.py", line 1025, in execute_script filename=os.path.basename(frame[0])) File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/marionette.py", line 577, in _send_message self._handle_error(response) File "/Users/skywalker/trees/virtualenv-b2g/lib/python2.7/site-packages/marionette/marionette.py", line 612, in _handle_error raise JavascriptException(message=message, status=status, stacktrace=stacktrace) marionette.errors.JavascriptException: TypeError: manager is undefined stacktrace: execute_script @gaia_test.py, line 142 inline javascript, line 21 src: " let runningApps = manager.getRunningApps();"
Attachment #8335944 - Attachment is obsolete: true
Flags: needinfo?(dave.hunt)
The running_apps property requires you to be in the system app frame, which you can switch to using marionette.switch_to_frame(). You can either include this in your test code before calling running_apps, or we could add it as the first line in the running_apps code. Note that this will mean you are no longer in the launched app frame, and you may need to use switch_to_displayed_app to switch back. Another option is to not switch to the app frame in the first place, using: apps.launch('browser', switch_to_frame=False). Also, are you aware of the --binary and --profile command line options in gaiatest? These will take care of cloning the profile and launching the application so you don't have to do that beforehand, and don't need to use --address.
Flags: needinfo?(dave.hunt)
(In reply to Dave Hunt (:davehunt) from comment #8) > or we could add it as > the first line in the running_apps code. Note that this will mean you are no > longer in the launched app frame, and you may need to use > switch_to_displayed_app to switch back. I like this idea, but it seems confusing for the user to switch to the right app after using running_apps. We should be able to figure out what app we're in now, so we can switch back into it after we go to the system app, right? It sounds like this would be a useful addition to running_apps, but I'm not sure if we're missing any caveats.
We already have switch_to_displayed_app, and during running_apps we don't change the displayed app, so we should be able to switch back within the method. It would be cool if we could run things like running_apps in a separate process so we don't interfere with the Marionette object in use by the tests, but I'm not sure if this is even possible.
Yeah problem is I am losing confidence in displayed_app because it does not handle activities at all. (in that scenario we need the displayed_frame, not app, they are different). I'm comfortable using switch_to_displayed_app in a known/trusted UI flow but using it on a 'global' property/method like this I think would lead to some uncomfortable assumptions about what frame we're in after running it. If we manage to get the displayed_frame in a reliable way then I'm all for it. For Gary to work around this now I like Malini's suggestion of: # switch_to_frame=False will cause stay in System frame after launching app browser_frame = self.apps.launch('blah', switch_to_frame=False) self.apps.runningApps().keys() # Now we've got the keys can switch into browser self.marionette.switch_to_frame(browser_frame)
Whiteboard: [fuzzblocker] → [fuzzblocker] [mentor=bebe][lang=py]
Mentor: florin.strugariu
Whiteboard: [fuzzblocker] [mentor=bebe][lang=py] → [fuzzblocker] [lang=py]
Attached file github pr
Attachment #8442063 - Flags: review?(florin.strugariu)
Attachment #8442063 - Flags: feedback?(gary)
Attachment #8442063 - Flags: review?(florin.strugariu) → review+
Comment on attachment 8442063 [details] [review] github pr I haven't been poking this recently, so clearing feedback. However I'd say go ahead and land it - will file a new bug should I encounter other issues in the future.
Attachment #8442063 - Flags: feedback?(gary)
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: