Revision 273bb41376c98c36e743186b63ec3cffa58a5339 authored by Ovidio Henriquez on 23 March 2018, 15:12:10 UTC, committed by Blink WPT Bot on 23 March 2018, 15:30:21 UTC
This change allows the removal of a descriptor to be simulated by the
Bluetooth test interface. A generated test script was also converted to test the
new interface.

BUG=569709

Change-Id: Id4286a3e44cd04ee1b371938f1ef89f33458269c
Reviewed-on: https://chromium-review.googlesource.com/972334
Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Conley Owens <cco3@chromium.org>
Commit-Queue: Ovidio Henriquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545448}
1 parent 2d1fd9e
Raw File
navigate.iFrame.sub.html
<!DOCTYPE html>
<html>
<head>
    <title>W3C Beacon As Fetch (Fetch KeepAlive) Navigate Test</title>
</head>
<body>
    <script src="beacon-common.sub.js"></script>
    <script>
        "use strict";

        // An array should be passed through postMessage to this iFrame, where
        //     [0] contains a test case id as defined in beacon-common.js.
        //     [1] is the URL for the keep alive fetch() or sendBeacon().
        //     [2] string indicating the function to call - "fetch" to call fetch() or "beacon" to call sendBeacon().
        // The testcase id is returned back to the window through postMesage.
        var tests = 0;
        window.onmessage = function(e) {
            var testCaseId = e.data[0];
            var url = e.data[1];
            var func = e.data[2];
            tests++;

            // Reconstruct enough of the test case to send the keep alive fetch (data and url).
            var testCase = testLookup[testCaseId];
            testCase.url = url;

            if (func === "beacon") {
                // sendData calls sendBeacon
                sendData(testCase);
            }
            else {
                throw new Error(func + " is an invalid function");
            }

            // Let the main page continue the test if we don't immediately throw an exception.
            parent.postMessage(testCaseId, "*");

            // Now navigate ourselves.
            if (tests == sampleTests.length) {
                window.location = "http://{{host}}:{{ports[http][0]}}/";
            }
        }
    </script>
</body>
</html>
back to top