Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js b/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..36c18f14bc3ec359b8a9b2932030b6ff0a2a4716 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js |
| @@ -0,0 +1,56 @@ |
| +// Some of the js-test.js boilerplate will add stuff to the top of the document early |
| +// enough to screw with frame offsets that are measured by the test. Delay all that |
| +// jazz until the actual test code is finished. |
| +if (window.setPrintTestResultsLazily) |
| + setPrintTestResultsLazily(); |
| +var delayDescription = description || null; |
| +var descriptionString = ""; |
| +var delayIsSuccessfullyParsed = isSuccessfullyParsed || null; |
| +var isSuccessfullyParsed = function() {} |
| +var description = function(msg) { descriptionString = msg } |
|
ojan
2016/01/21 23:56:43
I don't think you need to do all this monkey patch
szager1
2016/01/22 00:23:39
I tried that; didn't work :)
|
| + |
| +if (window.testRunner) |
| + testRunner.waitUntilDone(); |
| + |
| +function clientRectToJson(rect) { |
| + if (!rect) |
| + return null; |
| + return { |
| + top: rect.top, |
| + right: rect.right, |
| + bottom: rect.bottom, |
| + left: rect.left, |
| + width: rect.width, |
| + height: rect.height |
| + }; |
| +} |
| + |
| +function coordinatesToClientRectJson(top, right, bottom, left) { |
| + return { |
| + top: top, |
| + right: right, |
| + bottom: bottom, |
| + left: left, |
| + width: right - left, |
| + height: bottom - top |
| + }; |
| +} |
| + |
| +function entryToJson(entry) { |
| + return { |
| + boundingClientRect: clientRectToJson(entry.boundingClientRect), |
| + intersectionRect: clientRectToJson(entry.intersectionRect), |
| + rootBounds: clientRectToJson(entry.rootBounds), |
| + time: entry.time, |
| + target: entry.target.id |
| + }; |
| +} |
| + |
| +function finishTest() { |
| + if (descriptionString) |
| + delayDescription(descriptionString); |
| + delayIsSuccessfullyParsed(); |
| + finishJSTest(); |
| + if (window.testRunner) |
| + testRunner.notifyDone(); |
| +} |