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

Write a test for #11223 #11566

Open
jdm opened this issue Jun 2, 2016 · 4 comments
Open

Write a test for #11223 #11566

jdm opened this issue Jun 2, 2016 · 4 comments
Assignees
Labels

Comments

@jdm
Copy link
Member

@jdm jdm commented Jun 2, 2016

We should be able to write a test based on #11223 (comment), since WPT supports delaying and chunking responses in well-defined ways: http://wptserve.readthedocs.io/en/latest/pipes.html#trickle

cc @emilio

@jdm jdm added the A-testing label Jun 2, 2016
@emilio
Copy link
Member

@emilio emilio commented Jun 2, 2016

I might get to do it this weekend, but if someone steps in I'd be glad to help him.

Thanks for writing this, didn't know wpt allowed that kind of things.

@emilio emilio mentioned this issue Jun 3, 2016
4 of 4 tasks complete
@emilio emilio self-assigned this Jun 4, 2016
@emilio
Copy link
Member

@emilio emilio commented Jun 4, 2016

I'm doing it right now, and the presence of some flags we use for testing, like --user-agent-stylesheet, seem to inhibit the deadlock.

Also, in the following wpt-test (being localhost:5000 the node server in #11223 (comment)), and running an affected servo build directly against http://web-platform.test:8000/_mozilla/mozilla/iframe/iframe_query.html, the first iframe does not deadlock, while the second does:

<!doctype html>
<meta charset="utf-8">
<title>Early script query in an iframe does not deadlock</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- This is a test for servo/servo#11223. Note that 82 is the number of bytes until the end of the <script> tag -->
<iframe id="frame" src="resources/iframe_query_inner.html?pipe=trickle(82:d2)"></iframe>
<iframe id="frame2" src="http://localhost:5000"></iframe>                                                                                                                                     
<div>test</div>
<script>
async_test(function(t) {
  document.getElementById("frame").onload = function() {
    t.done();
  }
}, "Iframe that does an early query when te viewport is not yet present should not deadlock");
</script>

resources/iframe_query_inner.html:

<!doctype html><script>console.log(document.documentElement.offsetHeight)</script><div>test</div>

Changing the event listener target, or the order of the iframes don't seem to make an effect, but they should be strictly equivalent otherwise.

So... I'll try to check if any headers wpt could be sending would make a difference, but otherwise I'm running out of ideas (modulo reverse-engineering wptrunner and see what happens).

Also, I'm not sure if we can not-specify the --user-agent-stylesheets flag for a test... Any idea?

@jdm
Copy link
Member Author

@jdm jdm commented Jun 4, 2016

I do not believe there is a way to inhibit the stylesheet flag. I wonder if we should restrict it to only be added for reference tests? We could at least the theory by removing http://mxr.mozilla.org/servo/source/tests/wpt/harness/wptrunner/executors/executorservo.py#75 .

@emilio
Copy link
Member

@emilio emilio commented Jun 9, 2016

I ran out of ideas on how to reproduce it... Below are the http headers for the three attempts.

The trickle one really differs, and the chunked_layout_query.py is done with the following python snippet:

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from time import sleep

def write_chunk(response, chunk):
    line = [
      "%x\r\n" % len(chunk),
      chunk,
      "\r\n"]
    response.writer.write("".join(line))


def main(request, response):
    chunks = [
        "<!doctype html><script>console.log(document.documentElement.offsetHeight)</script>",
        "<div>Test</div>"
    ];
    response.headers.set("Content-Type", "text/html");
    response.headers.set("Transfer-Encoding", "chunked");
    response.headers.set("Connection", "keep-alive");
    response.write_status_headers()

    write_chunk(response, chunks[0]);
    sleep(2);
    write_chunk(response, chunks[1]);

    response.writer.write("0\r\n\r\n")
$ curl -vvvvv http://127.0.0.1:5000/                                                                                                                  
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/7.48.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html
< Date: Thu, 09 Jun 2016 12:49:57 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
< 
* Connection #0 to host 127.0.0.1 left intact
<!doctype html><script>console.log(document.documentElement.offsetHeight)</script><div>Test</div>
$ curl -vvvvv http://web-platform.test:8000/_mozilla/mozilla/iframe/resources/chunked_layout_query.py                                               
*   Trying 127.0.0.1...
* Connected to web-platform.test (127.0.0.1) port 8000 (#0)
> GET /_mozilla/mozilla/iframe/resources/chunked_layout_query.py HTTP/1.1
> Host: web-platform.test:8000
> User-Agent: curl/7.48.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< Server: BaseHTTP/0.3 Python/2.7.11
< Date: Thu, 09 Jun 2016 12:50:55 GMT
< 
* Connection #0 to host web-platform.test left intact
<!doctype html><script>console.log(document.documentElement.offsetHeight)</script><div>test</div>
➜  servo git:(regression-test-for-11223) ✗ curl -vvvvv "http://web-platform.test:8000/_mozilla/mozilla/iframe/resources/iframe_query_inner.html?pipe=trickle(82:d2)"                         
*   Trying 127.0.0.1...
* Connected to web-platform.test (127.0.0.1) port 8000 (#0)
> GET /_mozilla/mozilla/iframe/resources/iframe_query_inner.html?pipe=trickle(82:d2) HTTP/1.1
> Host: web-platform.test:8000
> User-Agent: curl/7.48.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html
< Server: BaseHTTP/0.3 Python/2.7.11
< Date: Thu, 09 Jun 2016 12:51:56 GMT
* no chunk, no close, no size. Assume close to signal end
< 
<!doctype html><script>console.log(document.documentElement.offsetHeight)</script><div>test</div>
* Closing connection 0

When creating different iframes for each, only the node server deadlocks, and the others run fine...

My guess is there are some internal differences between how wpt python handlers and node works, but I haven't investigated further...

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
2 participants
You can’t perform that action at this time.