Closed Bug 1318351 Opened 8 years ago Closed 7 years ago

Remove B2g code from Marionette server

Categories

(Remote Protocol :: Marionette, defect)

Version 3
defect
Not set
normal

Tracking

(firefox55 fixed)

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: whimboo, Assigned: whimboo)

References

Details

Attachments

(5 files)

The b2g code for the client and harness already got removed. What we should do is the same for the server component.
Blocks: 937659
No longer blocks: 937659
Attachment #8864491 - Flags: review?(ato)
Attachment #8864492 - Flags: review?(ato)
Attachment #8864493 - Flags: review?(ato)
Attachment #8864494 - Flags: review?(ato)
Attachment #8864495 - Flags: review?(ato)
Comment on attachment 8864491 [details]
Bug 1318351 - Remove readyStateTimer which was only used for B2G.

https://reviewboard.mozilla.org/r/136160/#review140514
Attachment #8864491 - Flags: review?(ato) → review+
Comment on attachment 8864492 [details]
Bug 1318351 - Remove B2G related assertions.

https://reviewboard.mozilla.org/r/136162/#review140516
Attachment #8864492 - Flags: review?(ato) → review+
Comment on attachment 8864493 [details]
Bug 1318351 - Remove obsolete B2G code from listener frame script.

https://reviewboard.mozilla.org/r/136164/#review140520
Attachment #8864493 - Flags: review?(ato) → review+
Comment on attachment 8864494 [details]
Bug 1318351 - Ensure that window ids are internally handled as numbers.

https://reviewboard.mozilla.org/r/136166/#review140522

::: testing/marionette/driver.js:1441
(Diff revision 2)
> +  // Window IDs are internally handled as numbers
> +  let switchTo = cmd.parameters.name * 1;
> +  if (isNaN(switchTo)) {
> +    switchTo = cmd.parameters.name;
> +  }

I wonder if we could not use strings internally?  Ideally we want to change the window IDs to be UUIDs in the future.

::: testing/marionette/driver.js:2613
(Diff revision 2)
>  
>    if (this.mm != globalMessageManager) {
>      this.mm.removeDelayedFrameScript(FRAME_SCRIPT);
>    }
>  
> -  return this.curBrowser.closeTab().then(() => this.windowHandles);
> +  return this.curBrowser.closeTab().then(() => this.windowHandles.map(String));

It would be great if we had a test for this.

::: testing/marionette/driver.js:2652
(Diff revision 2)
>  
>    if (this.mm != globalMessageManager) {
>      this.mm.removeDelayedFrameScript(FRAME_SCRIPT);
>    }
>  
> -  return this.curBrowser.closeWindow().then(() => this.chromeWindowHandles);
> +  return this.curBrowser.closeWindow().then(() => this.chromeWindowHandles.map(String));

It would be great if you could also add a test for this.

::: testing/marionette/driver.js:3429
(Diff revision 2)
>    let id = win.QueryInterface(Ci.nsIInterfaceRequestor)
>        .getInterface(Ci.nsIDOMWindowUtils)
>        .outerWindowID;
>  
> -  return id.toString();
> +  return id;

Just return directly.
Attachment #8864494 - Flags: review?(ato) → review-
Comment on attachment 8864495 [details]
Bug 1318351 - Remove mainContent and related code used by B2G.

https://reviewboard.mozilla.org/r/136168/#review140528

This is a great improvement to testing/marionette/browser.js.  Thanks for doing this!

::: testing/marionette/listener.js
(Diff revision 2)
> -function emitTouchEventForIFrame(message) {
> -  message = message.json;
> -  let identifier = legacyactions.nextTouchId;
> -
> -  let domWindowUtils = curContainer.frame.
> -    QueryInterface(Components.interfaces.nsIInterfaceRequestor).
> -    getInterface(Components.interfaces.nsIDOMWindowUtils);
> -  var ratio = domWindowUtils.screenPixelsPerCSSPixel;
> -
> -  var typeForUtils;
> -  switch (message.type) {
> -    case 'touchstart':
> -      typeForUtils = domWindowUtils.TOUCH_CONTACT;
> -      break;
> -    case 'touchend':
> -      typeForUtils = domWindowUtils.TOUCH_REMOVE;
> -      break;
> -    case 'touchcancel':
> -      typeForUtils = domWindowUtils.TOUCH_CANCEL;
> -      break;
> -    case 'touchmove':
> -      typeForUtils = domWindowUtils.TOUCH_CONTACT;
> -      break;
> -  }
> -  domWindowUtils.sendNativeTouchPoint(identifier, typeForUtils,
> -    Math.round(message.screenX * ratio), Math.round(message.screenY * ratio),
> -    message.force, 90);
> -}

I guess removing this does not cause any tests to fail?
Attachment #8864495 - Flags: review?(ato) → review+
Talked to whimboo on IRC, and we agreed to store window handles as integers internally still, add type tests for the commands that now return strings, and move to use strings as part of https://bugzilla.mozilla.org/show_bug.cgi?id=1311041.
Comment on attachment 8864495 [details]
Bug 1318351 - Remove mainContent and related code used by B2G.

https://reviewboard.mozilla.org/r/136168/#review140528

> I guess removing this does not cause any tests to fail?

No. There is only one caller of this method which was behind an if condition for b2g. So nothing else uses it at the moment, and as such should be save to remove.
Andreas, please have a look at the latest changes again.
Flags: needinfo?(ato)
Comment on attachment 8864494 [details]
Bug 1318351 - Ensure that window ids are internally handled as numbers.

https://reviewboard.mozilla.org/r/136166/#review141040

::: testing/marionette/driver.js:1442
(Diff revision 2)
> +  let switchTo = cmd.parameters.name * 1;
> +  if (isNaN(switchTo)) {
> +    switchTo = cmd.parameters.name;
> +  }

Since there is not atoi function in JS, you should probably use parseInt(cmd.parameters.name).  This returns NaN if the input cannot be parsed, so the isNaN(switchTo) test can be kept.
Attachment #8864494 - Flags: review- → review+
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Comment on attachment 8864494 [details]
Bug 1318351 - Ensure that window ids are internally handled as numbers.

https://reviewboard.mozilla.org/r/136166/#review141040

> Since there is not atoi function in JS, you should probably use parseInt(cmd.parameters.name).  This returns NaN if the input cannot be parsed, so the isNaN(switchTo) test can be kept.

parseInt() is 99% slower then just a "*1" as seen when run the tests via jsperf.org.
Comment on attachment 8864494 [details]
Bug 1318351 - Ensure that window ids are internally handled as numbers.

https://reviewboard.mozilla.org/r/136166/#review141046

Tests look good.

::: testing/marionette/harness/marionette_harness/tests/unit/test_window_handles_chrome.py:30
(Diff revision 3)
> +        try:
> +            self.assertIsInstance(self.marionette.current_chrome_window_handle, types.StringTypes)
> +            self.assertIsInstance(self.marionette.current_window_handle, types.StringTypes)
> +        except errors.NoSuchWindowException:
> +            pass

So the idea here is that one of them will fail?  You’re aware that if :31 throws, :32 will not be run?  I’m guessing this is fine?
Comment on attachment 8864494 [details]
Bug 1318351 - Ensure that window ids are internally handled as numbers.

https://reviewboard.mozilla.org/r/136166/#review141040

> parseInt() is 99% slower then just a "*1" as seen when run the tests via jsperf.org.

parseInt handles a few corner cases that right-hand-side type coercion does not.  Vitally null * 1 produces 0, whereas parseInt(null) returns NaN.  This is problematic since the input to this function may be null due to a client programming error.

It’s unfortunate that parseInt has performance penalties, but this will go away once I get time to work on the remoteness bug in Marionette.  With that we will switch to use string UUIDs for window IDs, and no type coercion will be necessary.
Flags: needinfo?(ato)
Comment on attachment 8864494 [details]
Bug 1318351 - Ensure that window ids are internally handled as numbers.

https://reviewboard.mozilla.org/r/136166/#review141040

> parseInt handles a few corner cases that right-hand-side type coercion does not.  Vitally null * 1 produces 0, whereas parseInt(null) returns NaN.  This is problematic since the input to this function may be null due to a client programming error.
> 
> It’s unfortunate that parseInt has performance penalties, but this will go away once I get time to work on the remoteness bug in Marionette.  With that we will switch to use string UUIDs for window IDs, and no type coercion will be necessary.

Makes sense. Thank you for info. It will be fixed in my next update.
Pushed by hskupin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4aa517cee854
Remove readyStateTimer which was only used for B2G. r=ato
https://hg.mozilla.org/integration/autoland/rev/31fdc1fc528e
Remove B2G related assertions. r=ato
https://hg.mozilla.org/integration/autoland/rev/281fa6a43aef
Remove obsolete B2G code from listener frame script. r=ato
https://hg.mozilla.org/integration/autoland/rev/cfa7a86e0b8d
Ensure that window ids are internally handled as numbers. r=ato
https://hg.mozilla.org/integration/autoland/rev/f2e0943a6762
Remove mainContent and related code used by B2G. r=ato
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: