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

Convert WebSocket tests to .any.js format #5148

Closed
wants to merge 1 commit into from

Conversation

annevk
Copy link
Member

@annevk annevk commented Mar 15, 2017

Fixes #2557.

@wpt-pr-bot
Copy link
Collaborator

@w3c-bots
Copy link

These tests are now available on w3c-test.org

@annevk
Copy link
Member Author

annevk commented Mar 15, 2017

This was done in an automated fashion using this Python script:

import os, html5lib

path = "./"
for filename in os.listdir(path):
    filename_tuple = os.path.splitext(filename)
    if filename_tuple[1] == ".htm" or filename_tuple[1] == ".html":
        output = u""
        with open(filename, "r") as f:
            root = html5lib.parse(f, "etree")
            for script in root.iter("{http://www.w3.org/1999/xhtml}script"):
                if u"src" in script.attrib:
                    if script.attrib[u"src"] in (u"/resources/testharness.js", u"/resources/testharnessreport.js"):
                        continue
                    else:
                        output += u"// META: script=" + script.attrib[u"src"] + u"\n"
                else:
                    output += u"\n" + script.text.strip("\n")

        new_file_name = filename_tuple[0] + ".any.js"
        os.rename(os.path.join(path,filename),os.path.join(path,new_file_name))
        with open(new_file_name, "w") as f:
            f.write(output.strip().encode("utf-8"))
            f.write(u"\n")

<script src=/resources/testharnessreport.js></script>
<script src=constants.js?pipe=sub></script>
<meta name="variant" content="">
<meta name="variant" content="?wss">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about these

Copy link
Member Author

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks okay, found a couple of minor potential issues, two of which need fixing before landing.


var testOpen = async_test("W3C WebSocket API - Send unicode data on a WebSocket - Connection should be opened");
var testMessage = async_test("W3C WebSocket API - Send unicode data on a WebSocket - Message should be received");
var testClose = async_test("W3C WebSocket API - Send unicode data on a WebSocket - Connection should be closed");

var data = "¥¥¥¥¥¥";
var data = "¥¥¥¥¥¥";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a fixup before landing.

<script src=/resources/testharnessreport.js></script>
<script src=constants.js?pipe=sub></script>
<meta name="variant" content="">
<meta name="variant" content="?wss">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear if these meta elements were important.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. They cause the runner to run the test once with nothing appended to the URL and once with ?wss appended (which tests wss: instead of ws:).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ms2ger I guess we need to introduce // META: variant= for these? Do you want to do that or provide me with a pointer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm what would you output though for the worker case? I'd know for https://github.com/w3c/wpt-tools/blob/6bc43a7c185137ccdfdfe114528e43784fc94c43/serve/serve.py#L115 which also needs changing. I filed w3c/wpt-tools#185 since @Ms2ger said he'd get to it.


var testOpen = async_test("W3C WebSocket API - Send unicode data on a Secure WebSocket - Connection should be opened");
var testMessage = async_test("W3C WebSocket API - Send unicode data on a Secure WebSocket - Message should be received");
var testClose = async_test("W3C WebSocket API - Send unicode data on a Secure WebSocket - Connection should be closed");

var data = "¥¥¥¥¥¥";
var data = "¥¥¥¥¥¥";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a fixup before landing.

@w3c-bots
Copy link

View the complete job log.

Firefox (nightly channel)

Testing web-platform-tests at revision 185b066
Using browser at version BuildID 20170314110401; SourceStamp 6d38ad302429c98115c354d643e81987ecec5d3c
Starting 10 test iterations
No tests run.

@w3c-bots
Copy link

View the complete job log.

Chrome (unstable channel)

Testing web-platform-tests at revision 185b066
Using browser at version 58.0.3029.19 dev
Starting 10 test iterations
No tests run.

@@ -0,0 +1,9 @@
// META: script=websocket.sub.js

if(window.WebSocket) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use self?

@unixbox08
Copy link

Reviewed 152 of 152 files at r1.
Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


Comments from Reviewable

annevk added a commit that referenced this pull request Apr 24, 2018
Take 2 (see #5148 for take 1), fixes #2557.
@annevk
Copy link
Member Author

annevk commented Apr 24, 2018

This is now #10598.

@annevk annevk closed this Apr 24, 2018
@annevk annevk deleted the annevk/websocket-anyjs branch April 24, 2018 13:13
jgraham pushed a commit that referenced this pull request Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants