| OLD | NEW |
| 1 // Some of the js-test.js boilerplate will add stuff to the top of the document
early | 1 // Some of the js-test.js boilerplate will add stuff to the top of the document
early |
| 2 // enough to screw with frame offsets that are measured by the test. Delay all
that | 2 // enough to screw with frame offsets that are measured by the test. Delay all
that |
| 3 // jazz until the actual test code is finished. | 3 // jazz until the actual test code is finished. |
| 4 if (self.isJsTest) { | 4 if (self.isJsTest) { |
| 5 setPrintTestResultsLazily(); | 5 setPrintTestResultsLazily(); |
| 6 self.jsTestIsAsync = true; | 6 self.jsTestIsAsync = true; |
| 7 } | 7 } |
| 8 | 8 |
| 9 // waitForNotification is a requestIdleCallback wrapped in a setTimeout wrapped
in a | 9 // waitForNotification is a setTimeout wrapped in a setTimeout wrapped in a |
| 10 // requestAnimationFrame. What in the wide, wide world of sports is going on he
re? | 10 // requestAnimationFrame. What in the wide, wide world of sports is going on he
re? |
| 11 // | 11 // |
| 12 // Here's the order of events: | 12 // Here's the order of events: |
| 13 // | 13 // |
| 14 // - firstTestFunction | 14 // - firstTestFunction |
| 15 // - Change layout to generate new IntersectionObserver notifications. | 15 // - Change layout to generate new IntersectionObserver notifications. |
| 16 // - waitForNotification(secondTestFunction) | 16 // - waitForNotification(secondTestFunction) |
| 17 // - requestAnimationFrame | 17 // - requestAnimationFrame |
| 18 // - BeginFrame | 18 // - BeginFrame |
| 19 // - requestAnimationFrame handler runs. | 19 // - requestAnimationFrame handler runs. |
| 20 // - setTimeout | 20 // - queue first setTimeout |
| 21 // - FrameView::updateAllLifecyclePhases | 21 // - FrameView::updateAllLifecyclePhases |
| 22 // - IntersectionObserver generates notification based on the new layout. | 22 // - IntersectionObserver generates notification based on the new layout. |
| 23 // - Post idle task to deliver notification. | 23 // - Post task to deliver notification. |
| 24 // - setTimeout handler runs. | 24 // - first setTimeout runs. |
| 25 // - testRunner.runIdleTasks or requestIdleCallback. | 25 // - queue second setTimeout |
| 26 // - Idle tasks run -- more or less immediately if (self.testRunner), | 26 // - Posted task runs. |
| 27 // possibly delayed if (!self.testRunner). | |
| 28 // - IntersectionObserver notifications are delivered. | 27 // - IntersectionObserver notifications are delivered. |
| 29 // - secondTestFunction | 28 // - second setTimeout runs secondTestFunction |
| 30 // - Verify notifications generated by firstTestFunction. | 29 // - Verify notifications generated by firstTestFunction. |
| 31 // - Change layout to generate new IntersectionObserver notifications. | 30 // - Change layout to generate new IntersectionObserver notifications. |
| 32 // - waitForNotification(thirdTestFunction) | 31 // - waitForNotification(thirdTestFunction) |
| 33 // | |
| 34 // Note that this should work equally well in these operation conditions: | |
| 35 // | |
| 36 // - layout test using single-threaded compositing (the default) | |
| 37 // - layout test using multi-threaded compositing (virtual/threaded/) | |
| 38 // - Not in a layout test and using multi-threaded compositing (the only confi
guration we ship) | |
| 39 function waitForNotification(f) { | 32 function waitForNotification(f) { |
| 40 requestAnimationFrame(() => { | 33 requestAnimationFrame(() => { |
| 41 setTimeout(() => { | 34 setTimeout(() => { |
| 42 if (self.testRunner) | 35 setTimeout(f); |
| 43 testRunner.runIdleTasks(f); | |
| 44 else | |
| 45 requestIdleCallback(f); | |
| 46 }); | 36 }); |
| 47 }); | 37 }); |
| 48 } | 38 } |
| 49 | 39 |
| 50 function rectToString(rect) { | 40 function rectToString(rect) { |
| 51 return "[" + rect.left + ", " + rect.right + ", " + rect.top + ", " + rect.bot
tom + "]"; | 41 return "[" + rect.left + ", " + rect.right + ", " + rect.top + ", " + rect.bot
tom + "]"; |
| 52 } | 42 } |
| 53 | 43 |
| 54 function entryToString(entry) { | 44 function entryToString(entry) { |
| 55 var ratio = ((entry.intersectionRect.width * entry.intersectionRect.height) / | 45 var ratio = ((entry.intersectionRect.width * entry.intersectionRect.height) / |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 90 |
| 101 function entryToJson(entry) { | 91 function entryToJson(entry) { |
| 102 return { | 92 return { |
| 103 boundingClientRect: clientRectToJson(entry.boundingClientRect), | 93 boundingClientRect: clientRectToJson(entry.boundingClientRect), |
| 104 intersectionRect: clientRectToJson(entry.intersectionRect), | 94 intersectionRect: clientRectToJson(entry.intersectionRect), |
| 105 rootBounds: clientRectToJson(entry.rootBounds), | 95 rootBounds: clientRectToJson(entry.rootBounds), |
| 106 time: entry.time, | 96 time: entry.time, |
| 107 target: entry.target.id | 97 target: entry.target.id |
| 108 }; | 98 }; |
| 109 } | 99 } |
| OLD | NEW |