Closed Bug 1227147 Opened 9 years ago Closed 8 years ago

Can't switch back with switchToShadowRoot() if action inside shadowDOM changed current document

Categories

(Testing Graveyard :: JSMarionette, defect)

defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: azasypkin, Assigned: yzen)

References

Details

Attachments

(3 files)

In Messages app, we're going to move to separate documents pages/documents for every app view (in the scope of NGA). We use gaia-header web component to navigate back to previous page, we trigger this action in tests with the following snippet:

// Switch to gaia-header web component.
client.switchToShadowRoot(this.accessors.header);
// Tap on back button, that triggers window.history.back().
client.headerActionButton.tap();
// Switch back to window context.
client.switchToShadowRoot();

This code throws:
{ [GenericError: GenericError: can't access dead object
Remote Stack:
<none>]
  client: 
   { driver: 
      TcpSync {
        host: 'localhost',
        port: 60534,
        connectionTimeout: 300000,
        isSync: true,
        retryInterval: 300,
        sockit: Sockit {},
        _lastId: 0,
        marionetteProtocol: 2,
        traits: undefined,
        applicationType: 'gecko' },
     defaultCallback: [Function],
     isSync: true,
     _hooks: { startSession: [] },
     _state: 
      { context: 'content',
        scriptTimeout: 20000,
        searchTimeout: 20000 },
     _scope: 
      { context: 'content',
        scriptTimeout: 20000,
        searchTimeout: 20000 },
     protocol: 2,
     apps: 
      MarionetteApps {
        close: [Function: bound close],
        launch: [Function: bound launch],
        list: [Function: bound list],
        switchToApp: [Function: bound switchToApp],
        switchToActivity: [Function: bound switchToActivity],
        getApp: [Function: bound getApp],
        getSelf: [Function: bound getSelf] },
     contentScript: { inject: [Function: bound loadFrameScript] },
     fileManager: 
      { client: [Circular],
        options: [Object],
        deviceStorage: [Object],
        fileManager: [Object] },
     forms: Forms { client: [Circular] },
     helper: { client: [Circular] },
     loader: { client: [Circular] },
     settings: SettingsApi { _client: [Circular] },
     _bypassScopeChecks: false,
     sessionId: '6a150399-b6ba-4708-a184-48a14262ff53',
     capabilities: 
      { browserName: 'Firefox',
        browserVersion: '45.0a1',
        platformName: 'Linux',
        platformVersion: '4.2.0-19-generic',
        specificationLevel: '1',
        raisesAccessibilityExceptions: false,
        rotatable: true,
        acceptSslCerts: false,
        takesElementScreenshot: true,
        takesScreenshot: true,
        proxy: {},
        platform: 'LINUX',
        XULappId: '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}',
        appBuildId: '20151121115636',
        device: 'desktop',
        version: '45.0a1',
        b2g: true } },
  type: 'GenericError',
  name: 'GenericError',
  message: 'GenericError: can\'t access dead object\nRemote Stack:\n<none>' }


After that we're stuck in some ^context^ and if try to find any element, or even call "client.switchToFrame(); client.apps.switchToApp(MESSAGE_APP_ORIGIN_URL);" we get the same exception.

Though I'm not 100% sure what we should do exactly in this case, but I'd say switch back to window context in case web component is not available anymore.
Hey Yura,

Do you have any clue what is going on here?

If it's really necessary I can wrap up quick app with the use case, just let me know.

Thanks!
Flags: needinfo?(yzenevich)
Yeah that would be really helpful. If I have a test case I can debug it a little more.

I tried doing 2 things (see test case patch), that pass just fine:
* navigating from the doc and the switching to parent context from shadow DOM
* deleting host of the current shadow DOM context and then switching out.
Flags: needinfo?(yzenevich)
Sure, ni? myself for the test app + tiny marionette JS test case
Flags: needinfo?(azasypkin)
Hey Yura,

Please look at the test [1] I've added to my gaia branch [2].

To run it locally, just checkout the branch and do "PROFILE_FOLDER=profile-test make && TEST_FILES=./apps/marionette-switch-to-shadow-root/test/marionette/shadow_dom_test.js make test-integration-test".

I've added timeout between "client.helper.waitForElement('.action-button').tap();" and "client.switchToShadowRoot();" so that test will file permanently, with this small app it fails intermittently without timeout.

[1] https://github.com/azasypkin/gaia/blob/bug-marionette/apps/marionette-switch-to-shadow-root/test/marionette/shadow_dom_test.js
[2] https://github.com/azasypkin/gaia/tree/bug-marionette
Flags: needinfo?(azasypkin) → needinfo?(yzenevich)
Thanks this helps a lot!
Assignee: nobody → yzenevich
Status: NEW → ASSIGNED
Flags: needinfo?(yzenevich)
Bug 1227147 - ensuring that switchToShadowRoot does not crash when shadowRoot host element is dead.

---
 testing/marionette/listener.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Comment on attachment 8691532 [details]
MozReview Request: Bug 1227147 - ensuring that switchToShadowRoot does not crash when shadowRoot host element is dead.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/26131/diff/1-2/
Attachment #8691532 - Flags: review?(dburns)
Comment on attachment 8691532 [details]
MozReview Request: Bug 1227147 - ensuring that switchToShadowRoot does not crash when shadowRoot host element is dead.

https://reviewboard.mozilla.org/r/26131/#review23623
Attachment #8691532 - Flags: review?(dburns) → review+
https://hg.mozilla.org/mozilla-central/rev/8810318a745d
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Blocks: 1226555
---
 .../marionette/chrome/test_anonymous_content.xul   |  9 +++++++++
 .../tests/unit/test_anonymous_content.py           | 10 ++++++++++
 testing/marionette/driver.js                       | 23 ++++++++++++++++++++++
 3 files changed, 42 insertions(+)

Review commit: https://reviewboard.mozilla.org/r/30199/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30199/
Attachment #8705824 - Flags: review?(dburns)
Attachment #8705824 - Flags: review?(dburns)
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: