Modified: trunk/LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html (206129 => 206130)
--- trunk/LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html 2016-09-19 23:30:53 UTC (rev 206129)
+++ trunk/LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html 2016-09-19 23:36:26 UTC (rev 206130)
@@ -10,7 +10,7 @@
suite.addTestCase({
name: "CheckLazyInitializationOfDOMTree",
description: "Check that DOMTree instances are created lazily.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
let instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree);
InspectorTest.expectThat(instances.size === 0, "There should not be a DOMTree listening to DOMTreeManager events initially.");
InspectorTest.log("DOMTree instance count: " + instances.size);
@@ -21,7 +21,7 @@
suite.addTestCase({
name: "CheckDOMTreeCountAfterUsingGetter",
description: "Check that the count of connected DOMTrees is correct after initializing them.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
let mainFrame = WebInspector.frameResourceManager.mainFrame;
mainFrame.domTree; // Force creation of the root DOM tree.
@@ -45,13 +45,14 @@
suite.addTestCase({
name: "CheckDOMTreeCountAfterReloading",
description: "Check that the count of connected DOMTrees is correct after a reload.",
- test: (resolve, reject) => {
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.MainResourceDidChange, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.MainResourceDidChange)
+ .then((event) => {
let instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree);
InspectorTest.expectThat(instances.size === 0, "There should not be any DOMTrees listening to DOMTreeManager events after a main frame navigation.");
InspectorTest.log("DOMTree instance count: " + instances.size);
- resolve();
- });
+ })
+ .then(resolve, reject);
InspectorTest.reloadPage();
}
Modified: trunk/LayoutTests/http/tests/inspector/network/copy-as-curl.html (206129 => 206130)
--- trunk/LayoutTests/http/tests/inspector/network/copy-as-curl.html 2016-09-19 23:30:53 UTC (rev 206129)
+++ trunk/LayoutTests/http/tests/inspector/network/copy-as-curl.html 2016-09-19 23:36:26 UTC (rev 206130)
@@ -6,7 +6,7 @@
<script>
function createSimpleGETRequest()
{
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("GET", "resources/url?query=true", true);
request.send();
}
@@ -13,7 +13,7 @@
function createGETRequestWithSpecialURL()
{
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("GET", "resources/url'with$special{1..20}chars[] .html", true);
request.send();
}
@@ -20,7 +20,7 @@
function createGETRequestWithSpecialCharsInHeaders()
{
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("GET", "resources/url", true);
request.setRequestHeader("X-Custom1", "test1");
request.setRequestHeader("X-Custom2'%", "\'Test'\'1\\'2");
@@ -30,7 +30,7 @@
function createGETRequestWithUTF8()
{
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("GET", "resources/url?utf8=👍", true);
request.send();
}
@@ -37,7 +37,7 @@
function createPOSTRequestWithURLEncodedData()
{
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("POST", "resources/url", true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("lorem=ipsum&$dolor='sit'&amet={1..20}");
@@ -45,7 +45,7 @@
function createPOSTRequestWithUTF8()
{
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("POST", "resources/url?utf8=👍", true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("🌨=⛄️");
@@ -53,7 +53,7 @@
function createPUTRequestWithJSON()
{
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("PUT", "resources/url", true);
request.setRequestHeader("Content-Type", "application/json");
request.send("{\"update\":\"now\"}");
@@ -66,9 +66,9 @@
suite.addTestCase({
name: "SimpleURLGenerateCURL",
description: "Generate cURL command from a simple URL.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createSimpleGETRequest()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
let curl = resource.generateCURLCommand().split(" \\\n");
@@ -76,8 +76,10 @@
InspectorTest.expectThat(curl[1] === "-XGET", "Command should be a GET request.");
InspectorTest.expectThat(curl.find((cmd) => cmd.includes('User-Agent')) !== undefined, "Command should contain User-Agent header.");
InspectorTest.expectThat(curl.find((cmd) => cmd.includes('X-Custom')) === undefined, "Command should not contain a custom header.");
- resolve();
- });
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createSimpleGETRequest()");
}
});
@@ -84,15 +86,17 @@
suite.addTestCase({
name: "SpecialURLGenerateCURL",
description: "Generate cURL command from a URL containing special characters.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createGETRequestWithSpecialURL()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
let curl = resource.generateCURLCommand().split(" \\\n");
InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\\\'with\\$special\\\\{1\.\.20\\\\}chars\\\\\\[\\\\\\]%20.html") !== null, "Command should contain valid POSIX escaped URL.");
- resolve();
- });
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createGETRequestWithSpecialURL()");
}
});
@@ -99,9 +103,9 @@
suite.addTestCase({
name: "SpecialHeadersGenerateCURLValidPOSIXOutput",
description: "Generate cURL command from a request containing special characters in the headers and verify valid POSIX output.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createGETRequestWithSpecialCharsInHeaders()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
let curl = resource.generateCURLCommand().split(" \\\n");
@@ -108,8 +112,10 @@
InspectorTest.expectThat(curl.find((cmd) => cmd.includes('X-Custom1')) === "-H 'X-Custom1: test1'", "Command should have correct custom header 1.");
InspectorTest.expectThat(curl.find((cmd) => cmd.includes('X-Custom2')) === "-H $'X-Custom2\\'%: \\'Test\\'\\'1\\\\\\'2'", "Command should have correct custom header 2.");
InspectorTest.expectThat(curl.find((cmd) => cmd.includes('X-Custom3')) === "-H $'X-Custom3: \\'${PWD}'", "Command should have correct custom header 3.");
- resolve();
- });
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createGETRequestWithSpecialCharsInHeaders()");
}
});
@@ -116,15 +122,17 @@
suite.addTestCase({
name: "URLWithUTF8GenerateCURL",
description: "Generate cURL command from a URL containing UTF8 characters.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createGETRequestWithUTF8()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
let curl = resource.generateCURLCommand().split(" \\\n");
InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\?utf8=%F0%9F%91%8D") !== null, "Command should contain URL with UTF8 characters.");
- resolve();
- });
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createGETRequestWithUTF8()");
}
});
@@ -131,9 +139,9 @@
suite.addTestCase({
name: "POSTRequestURLEncodedDataGenerateCURL",
description: "Generate cURL command from a POST request with URL encoded data.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createPOSTRequestWithURLEncodedData()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
let curl = resource.generateCURLCommand().split(" \\\n");
@@ -140,8 +148,10 @@
InspectorTest.expectThat(curl[1] === "-XPOST", "Command should be a POST request.");
InspectorTest.expectThat(curl.find((cmd) => cmd.includes('Content-Type')) === "-H 'Content-Type: application/x-www-form-urlencoded'", "Command should have correct Content-Type.");
InspectorTest.expectThat(curl.find((cmd) => cmd === "--data $'lorem=ipsum&$dolor=\\'sit\\'&amet={1..20}'") !== undefined, "Command should contain correct data.");
- resolve();
- });
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createPOSTRequestWithURLEncodedData()");
}
});
@@ -148,16 +158,18 @@
suite.addTestCase({
name: "POSTRequestURLEncodedDataUTF8GenerateCURL",
description: "Generate cURL command from a POST request with URL encoded UTF8 data.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createPOSTRequestWithUTF8()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
let curl = resource.generateCURLCommand().split(" \\\n");
InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\?utf8=%F0%9F%91%8D") !== null, "Command should contain URL with UTF8 characters.");
InspectorTest.expectThat(curl.find((cmd) => cmd === "--data $'\\ud83c\\udf28=\\u26c4\\ufe0f'") !== undefined, "Command should contain correct UTF8 data.");
- resolve();
- });
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createPOSTRequestWithUTF8()");
}
});
@@ -164,9 +176,9 @@
suite.addTestCase({
name: "PUTRequestWithJSONGenerateCURL",
description: "Generate cURL command from a PUT request with JSON data.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createPUTRequestWithJSON()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
let curl = resource.generateCURLCommand().split(" \\\n");
@@ -173,8 +185,10 @@
InspectorTest.expectThat(curl[1] === "-XPUT", "Command should be a PUT request.");
InspectorTest.expectThat(curl.find((cmd) => cmd.includes('Content-Type')) === "-H 'Content-Type: application/json'", "Command should have JSON Content-Type.");
InspectorTest.expectThat(curl.find((cmd) => cmd === "--data-binary '{\"update\":\"now\"}'") !== undefined, "Command should contain correct JSON data.");
- resolve();
- });
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createPUTRequestWithJSON()");
}
});
Modified: trunk/LayoutTests/http/tests/inspector/network/resource-timing.html (206129 => 206130)
--- trunk/LayoutTests/http/tests/inspector/network/resource-timing.html 2016-09-19 23:30:53 UTC (rev 206129)
+++ trunk/LayoutTests/http/tests/inspector/network/resource-timing.html 2016-09-19 23:36:26 UTC (rev 206130)
@@ -16,37 +16,36 @@
suite.addTestCase({
name: "CheckResourceTimingInformationForResource",
description: "Check if a resource has timing information.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createRequest()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
- let resource = event.data.resource;
+ test(resolve, reject) {
+ Promise.all([
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded),
+ WebInspector.Resource.awaitEvent(WebInspector.Resource.Event.ResponseReceived),
+ WebInspector.Resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish)
+ ])
+ .then(([resourceWasAddedEvent, responseReceivedEvent, loadingDidFinishEvent]) => {
+ let resource = resourceWasAddedEvent.data.resource;
- InspectorTest.expectThat(resource.timingData instanceof WebInspector.ResourceTimingData, "Newly added resource should have a resource timing model.");
- InspectorTest.expectThat(resource.timingData.startTime, "Newly added resource should have a start time.");
+ InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be createad.");
+ InspectorTest.expectThat(resource === responseReceivedEvent.target, "Added Resource received a response.");
+ InspectorTest.expectThat(resource === loadingDidFinishEvent.target, "Added Resource did finish loading.");
- resource.singleFireEventListener(WebInspector.Resource.Event.ResponseReceived, (event) => {
- let timingData = resource.timingData;
+ let timingData = resource.timingData;
+ InspectorTest.expectThat(timingData instanceof WebInspector.ResourceTimingData, "Newly added resource should have a resource timing model.");
+ InspectorTest.expectThat(timingData.startTime > 0, "Resource should have a start time.");
+ InspectorTest.expectThat(timingData.requestStart > 0, "Resource should have a request start time.");
+ InspectorTest.expectThat(timingData.responseStart > 0, "Resource should have a response start time.");
- InspectorTest.expectThat(timingData, "Resource should now contain timing information.");
- InspectorTest.expectThat(timingData.startTime > 0, "Resource should have a start time.");
- InspectorTest.expectThat(timingData.requestStart > 0, "Resource should have a request start time.");
- InspectorTest.expectThat(timingData.responseStart > 0, "Resource should have a response start time.");
+ InspectorTest.expectThat(typeof timingData.domainLookupStart === "number" && typeof timingData.domainLookupEnd === "number", "domainLookupStart and domainLookupEnd should both be NaN or a number.");
+ InspectorTest.expectThat(typeof timingData.connectStart === "number" && typeof timingData.connectStart === "number", "connectStart and connectEnd should both be NaN or a number.");
- InspectorTest.expectThat(typeof timingData.domainLookupStart === "number" && typeof timingData.domainLookupEnd === "number", "domainLookupStart and domainLookupEnd should both be NaN or a number.");
- InspectorTest.expectThat(typeof timingData.connectStart === "number" && typeof timingData.connectStart === "number", "connectStart and connectEnd should both be NaN or a number.");
+ InspectorTest.expectThat(timingData.startTime <= timingData.requestStart, "requestStart should come after startTime.");
+ InspectorTest.expectThat(isNaN(timingData.secureConnectionStart) || timingData.connectStart <= timingData.secureConnectionStart, "A secure connection should be reused or secureConnectionStart should come after connectStart.");
+ InspectorTest.expectThat(timingData.requestStart <= timingData.responseStart, "responseStart should come after requestStart.");
+ InspectorTest.expectThat(timingData.responseStart <= timingData.responseEnd, "responseEnd should come after responseStart.");
+ })
+ .then(resolve, reject);
- InspectorTest.expectThat(timingData.startTime <= timingData.requestStart, "requestStart should come after startTime.");
- InspectorTest.expectThat(isNaN(timingData.secureConnectionStart) || timingData.connectStart <= timingData.secureConnectionStart, "A secure connection should be reused or secureConnectionStart should come after connectStart.");
- InspectorTest.expectThat(timingData.requestStart <= timingData.responseStart, "responseStart should come after requestStart.");
- InspectorTest.expectThat(isNaN(timingData.responseEnd), "responseEnd should not be available yet.");
- });
-
- resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFinish, (event) => {
- let timingData = resource.timingData;
- InspectorTest.expectThat(timingData.responseStart <= timingData.responseEnd, "responseEnd should come after responseStart.");
- resolve();
- });
- });
+ InspectorTest.evaluateInPage("createRequest()");
}
});
Modified: trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly.html (206129 => 206130)
--- trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly.html 2016-09-19 23:30:53 UTC (rev 206129)
+++ trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly.html 2016-09-19 23:36:26 UTC (rev 206130)
@@ -5,7 +5,7 @@
<script src=""
<script>
function createXHRResource() {
- var request = new XMLHttpRequest();
+ let request = new XMLHttpRequest();
request.open("POST", "resources/", true);
request.send("utf8=👍");
}
@@ -17,20 +17,23 @@
suite.addTestCase({
name: "XHRWithRequestDataIsEncodedCorrectly",
description: "XHR with request data is encoded correctly.",
- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createXHRResource()");
- WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ test(resolve, reject) {
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
let resource = event.data.resource;
InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
InspectorTest.expectThat(resource.requestData === "utf8=👍", "Request data should have expected content.");
- resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFinish, (event) => {
- InspectorTest.pass("Resource load should finish.");
- resolve();
- });
- });
+ return resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish);
+ })
+ .then((event) => {
+ InspectorTest.pass("Resource load should finish.");
+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("createXHRResource()");
}
});
-
+
suite.runTestCasesAndFinish();
}
</script>