Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract reftests #5260

Open
kmcallister opened this issue Mar 18, 2015 · 7 comments
Open

Abstract reftests #5260

kmcallister opened this issue Mar 18, 2015 · 7 comments

Comments

@kmcallister
Copy link
Contributor

@kmcallister kmcallister commented Mar 18, 2015

Instead of dumping an image, write out every DOM node's client rects. We can also implement this as a Firefox extension; then we can test Gecko vs. Servo layout without some of the pitfalls mentioned in #1768. Applications:

  • Automatically reduce a page's HTML / CSS (see servo/html5ever#5) to determine why the layout is wrong in Servo.
  • Track metrics on layout correctness for the top N websites (live or cached).
@kmcallister
Copy link
Contributor Author

@kmcallister kmcallister commented Mar 20, 2015

We can do this inside any engine by injecting some JavaScript:

window.addEventListener('load', function () {
    var elements = [].map.call(document.getElementsByTagName("*"), function (elem) {
        var rects = [].map.call(elem.getClientRects(), function (r) {
            return {
                bottom: r.bottom,
                top: r.top,
                left: r.left,
                right: r.right,
            };
        });
        return {
            name: elem.tagName,
            id: elem.id,
            classes: elem.className,
            rects: rects,
        };
    });

    console.log(JSON.stringify({
        viewport: {
            width: window.innerWidth,
            height: window.innerHeight,
        },
        elements: elements,
    }));
});
@kmcallister
Copy link
Contributor Author

@kmcallister kmcallister commented Mar 20, 2015

This approach also supports fuzzy matching and intelligent test case reduction.

@kmcallister
Copy link
Contributor Author

@kmcallister kmcallister commented Mar 24, 2015

I have a demo of the above in PhantomJS and I'm working with @Manishearth to implement the Servo side with the new "user scripts" option. Then we should be set for automated, headless testing \o/

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Apr 2, 2015

Would the test’s rectangles be compared to raw rectangles (maybe stored in JSON or something), or to the rectangles of another (reference) HTML document? If the former, these aren’t reftests and shoul probably be called something else. Layout tests maybe?

@kmcallister
Copy link
Contributor Author

@kmcallister kmcallister commented Apr 2, 2015

I called them "abstract reftests" because I imagine comparing to a reference document or to the same document in another engine. But we could use the same script for other kinds of testing, as well.

@kmcallister
Copy link
Contributor Author

@kmcallister kmcallister commented Apr 2, 2015

I just got this working in Servo. Here's the diff for Acid1.

@nox
Copy link
Member

@nox nox commented Sep 30, 2017

Is this still something we want to do? Couldn't we reuse webrender's own stuff to specify display lists in written form?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.