winjs / winjs

A UI toolkit for modern browsers
http://try.buildwinjs.com/
Other
4.14k stars 472 forks source link

Protractor: Regression in WinJS - test case "WinJSTests.FlipperInstantiationTests: NoNavigationOnResize " in "winjs/bin/tests/FlipView/test.html" #1310

Closed mikewjackson closed 9 years ago

mikewjackson commented 9 years ago

Test case "WinJSTests.FlipperInstantiationTests: NoNavigationOnResize " in "winjs/bin/tests/FlipView/test.html" failed in the latest Protractor run. Protractor determined that this failure is a regression from mshtml or a previous build of edgehtml (based on historical data). Please investigate why this test has begun failing.

mikewjackson commented 9 years ago

This is a result of a resize and scroll event occurring in close proximity. However, we believe this issue will be addressed by removing the mselementresize event handler as tracked by #1308

rigdern commented 9 years ago

Repro Steps

The test failure is due to a race condition which triggers intermittently. It requires Edge to repro the bug. The test only fails sometimes so I did some work to make it easier to repro. I uploaded a subset of the FlipView tests from the WinJS repository to OneDrive (link in the repro steps). Having a subset of the tests makes it easier to repro because the tests are run thru several iterations before the bug triggers. Repeating the 1 failing test alone doesn't trigger the bug.

  1. Download and unzip repro.zip from http://1drv.ms/1DwCmSO
  2. Open a Windows command prompt in the repro directory
  3. Run npm install
  4. Run grunt connect:localhost
  5. In Edge, open http://localhost:9666/bin/tests/FlipView/test.html?fastanimations=true&loop=true
  6. Click the "Start" button

After several iterations, WinJSTests.FlipperInstantiationTests: NoNavigationOnResize will fail with an exception:

image

Cause

When the bug does not repro, the following happens:

  1. FlipView scrolls itself
  2. FlipView's scroll handler runs
  3. Test resizes FlipView
  4. FlipView's resize handler runs

When the bug repros, the following happens:

  1. FlipView scrolls itself
  2. Test resizes FlipView
  3. FlipView's scroll handler runs. Inside the scroll handler:
    • FlipView queries the DOM which causes the browser to do a layout
    • FlipView's resize handler runs. Inside the resize handler:
      • FlipView sets _lastScrollPos and its scroll position to a new value
    • FlipView reads its scroll position which doesn't match _lastScrollPos and this causes the FlipView to scroll to the wrong page