Closed Bug 1227147 Opened 6 years ago Closed 6 years ago

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


(Testing Graveyard :: JSMarionette, defect)

Not set


(firefox45 fixed)

Tracking Status
firefox45 --- fixed


(Reporter: azasypkin, Assigned: yzen)




(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.
// Tap on back button, that triggers window.history.back().
// Switch back to window context.

This code throws:
{ [GenericError: GenericError: can't access dead object
Remote Stack:
   { 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: [] },
      { context: 'content',
        scriptTimeout: 20000,
        searchTimeout: 20000 },
      { context: 'content',
        scriptTimeout: 20000,
        searchTimeout: 20000 },
     protocol: 2,
      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] },
      { 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',
      { 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.

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.

Flags: needinfo?(azasypkin) → needinfo?(yzenevich)
Thanks this helps a lot!
Assignee: nobody → yzenevich
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:
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.
Attachment #8691532 - Flags: review?(dburns) → review+
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Blocks: 1226555
 .../marionette/chrome/test_anonymous_content.xul   |  9 +++++++++
 .../tests/unit/           | 10 ++++++++++
 testing/marionette/driver.js                       | 23 ++++++++++++++++++++++
 3 files changed, 42 insertions(+)

Review commit:
See other reviews:
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.