Changeset 206130 in webkit
- Timestamp:
- Sep 19, 2016 4:36:26 PM (8 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206127 r206130 1 2016-09-19 Devin Rousso <dcrousso+webkit@gmail.com> 2 3 Web Inspector: adopt Object.awaitEvent in LayoutTests/http/tests/inspector 4 https://bugs.webkit.org/show_bug.cgi?id=162069 5 6 Reviewed by Brian Burg. 7 8 Replace instances of singleFireEventListener with awaitEvent and use promise logic to make 9 tests more readable. 10 11 * http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html: 12 * http/tests/inspector/network/copy-as-curl.html: 13 * http/tests/inspector/network/resource-timing-expected.txt: 14 * http/tests/inspector/network/resource-timing.html: 15 * http/tests/inspector/network/xhr-request-data-encoded-correctly.html: 16 1 17 2016-09-16 Jer Noble <jer.noble@apple.com> 2 18 -
trunk/LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html
r188756 r206130 11 11 name: "CheckLazyInitializationOfDOMTree", 12 12 description: "Check that DOMTree instances are created lazily.", 13 test : (resolve, reject) =>{13 test(resolve, reject) { 14 14 let instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree); 15 15 InspectorTest.expectThat(instances.size === 0, "There should not be a DOMTree listening to DOMTreeManager events initially."); … … 22 22 name: "CheckDOMTreeCountAfterUsingGetter", 23 23 description: "Check that the count of connected DOMTrees is correct after initializing them.", 24 test : (resolve, reject) =>{24 test(resolve, reject) { 25 25 let mainFrame = WebInspector.frameResourceManager.mainFrame; 26 26 mainFrame.domTree; // Force creation of the root DOM tree. … … 46 46 name: "CheckDOMTreeCountAfterReloading", 47 47 description: "Check that the count of connected DOMTrees is correct after a reload.", 48 test: (resolve, reject) => { 49 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.MainResourceDidChange, (event) => { 48 test(resolve, reject) { 49 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.MainResourceDidChange) 50 .then((event) => { 50 51 let instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree); 51 52 InspectorTest.expectThat(instances.size === 0, "There should not be any DOMTrees listening to DOMTreeManager events after a main frame navigation."); 52 53 InspectorTest.log("DOMTree instance count: " + instances.size); 53 resolve();54 });54 }) 55 .then(resolve, reject); 55 56 56 57 InspectorTest.reloadPage(); -
trunk/LayoutTests/http/tests/inspector/network/copy-as-curl.html
r203132 r206130 7 7 function createSimpleGETRequest() 8 8 { 9 varrequest = new XMLHttpRequest();9 let request = new XMLHttpRequest(); 10 10 request.open("GET", "resources/url?query=true", true); 11 11 request.send(); … … 14 14 function createGETRequestWithSpecialURL() 15 15 { 16 varrequest = new XMLHttpRequest();16 let request = new XMLHttpRequest(); 17 17 request.open("GET", "resources/url'with$special{1..20}chars[] .html", true); 18 18 request.send(); … … 21 21 function createGETRequestWithSpecialCharsInHeaders() 22 22 { 23 varrequest = new XMLHttpRequest();23 let request = new XMLHttpRequest(); 24 24 request.open("GET", "resources/url", true); 25 25 request.setRequestHeader("X-Custom1", "test1"); … … 31 31 function createGETRequestWithUTF8() 32 32 { 33 varrequest = new XMLHttpRequest();33 let request = new XMLHttpRequest(); 34 34 request.open("GET", "resources/url?utf8=👍", true); 35 35 request.send(); … … 38 38 function createPOSTRequestWithURLEncodedData() 39 39 { 40 varrequest = new XMLHttpRequest();40 let request = new XMLHttpRequest(); 41 41 request.open("POST", "resources/url", true); 42 42 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); … … 46 46 function createPOSTRequestWithUTF8() 47 47 { 48 varrequest = new XMLHttpRequest();48 let request = new XMLHttpRequest(); 49 49 request.open("POST", "resources/url?utf8=👍", true); 50 50 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); … … 54 54 function createPUTRequestWithJSON() 55 55 { 56 varrequest = new XMLHttpRequest();56 let request = new XMLHttpRequest(); 57 57 request.open("PUT", "resources/url", true); 58 58 request.setRequestHeader("Content-Type", "application/json"); … … 67 67 name: "SimpleURLGenerateCURL", 68 68 description: "Generate cURL command from a simple URL.", 69 test : (resolve, reject) =>{70 InspectorTest.evaluateInPage("createSimpleGETRequest()");71 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded,(event) => {69 test(resolve, reject) { 70 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 71 .then((event) => { 72 72 let resource = event.data.resource; 73 73 let curl = resource.generateCURLCommand().split(" \\\n"); … … 77 77 InspectorTest.expectThat(curl.find((cmd) => cmd.includes('User-Agent')) !== undefined, "Command should contain User-Agent header."); 78 78 InspectorTest.expectThat(curl.find((cmd) => cmd.includes('X-Custom')) === undefined, "Command should not contain a custom header."); 79 resolve(); 80 }); 79 }) 80 .then(resolve, reject); 81 82 InspectorTest.evaluateInPage("createSimpleGETRequest()"); 81 83 } 82 84 }); … … 85 87 name: "SpecialURLGenerateCURL", 86 88 description: "Generate cURL command from a URL containing special characters.", 87 test: (resolve, reject) => { 89 test(resolve, reject) { 90 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 91 .then((event) => { 92 let resource = event.data.resource; 93 let curl = resource.generateCURLCommand().split(" \\\n"); 94 95 InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\\\'with\\$special\\\\{1\.\.20\\\\}chars\\\\\\[\\\\\\]%20.html") !== null, "Command should contain valid POSIX escaped URL."); 96 }) 97 .then(resolve, reject); 98 88 99 InspectorTest.evaluateInPage("createGETRequestWithSpecialURL()"); 89 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {90 let resource = event.data.resource;91 let curl = resource.generateCURLCommand().split(" \\\n");92 93 InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\\\'with\\$special\\\\{1\.\.20\\\\}chars\\\\\\[\\\\\\]%20.html") !== null, "Command should contain valid POSIX escaped URL.");94 resolve();95 });96 100 } 97 101 }); … … 100 104 name: "SpecialHeadersGenerateCURLValidPOSIXOutput", 101 105 description: "Generate cURL command from a request containing special characters in the headers and verify valid POSIX output.", 102 test : (resolve, reject) =>{103 InspectorTest.evaluateInPage("createGETRequestWithSpecialCharsInHeaders()");104 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded,(event) => {106 test(resolve, reject) { 107 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 108 .then((event) => { 105 109 let resource = event.data.resource; 106 110 let curl = resource.generateCURLCommand().split(" \\\n"); … … 109 113 InspectorTest.expectThat(curl.find((cmd) => cmd.includes('X-Custom2')) === "-H $'X-Custom2\\'%: \\'Test\\'\\'1\\\\\\'2'", "Command should have correct custom header 2."); 110 114 InspectorTest.expectThat(curl.find((cmd) => cmd.includes('X-Custom3')) === "-H $'X-Custom3: \\'${PWD}'", "Command should have correct custom header 3."); 111 resolve(); 112 }); 115 }) 116 .then(resolve, reject); 117 118 InspectorTest.evaluateInPage("createGETRequestWithSpecialCharsInHeaders()"); 113 119 } 114 120 }); … … 117 123 name: "URLWithUTF8GenerateCURL", 118 124 description: "Generate cURL command from a URL containing UTF8 characters.", 119 test: (resolve, reject) => { 125 test(resolve, reject) { 126 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 127 .then((event) => { 128 let resource = event.data.resource; 129 let curl = resource.generateCURLCommand().split(" \\\n"); 130 131 InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\?utf8=%F0%9F%91%8D") !== null, "Command should contain URL with UTF8 characters."); 132 }) 133 .then(resolve, reject); 134 120 135 InspectorTest.evaluateInPage("createGETRequestWithUTF8()"); 121 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {122 let resource = event.data.resource;123 let curl = resource.generateCURLCommand().split(" \\\n");124 125 InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\?utf8=%F0%9F%91%8D") !== null, "Command should contain URL with UTF8 characters.");126 resolve();127 });128 136 } 129 137 }); … … 132 140 name: "POSTRequestURLEncodedDataGenerateCURL", 133 141 description: "Generate cURL command from a POST request with URL encoded data.", 134 test : (resolve, reject) =>{135 InspectorTest.evaluateInPage("createPOSTRequestWithURLEncodedData()");136 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded,(event) => {142 test(resolve, reject) { 143 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 144 .then((event) => { 137 145 let resource = event.data.resource; 138 146 let curl = resource.generateCURLCommand().split(" \\\n"); … … 141 149 InspectorTest.expectThat(curl.find((cmd) => cmd.includes('Content-Type')) === "-H 'Content-Type: application/x-www-form-urlencoded'", "Command should have correct Content-Type."); 142 150 InspectorTest.expectThat(curl.find((cmd) => cmd === "--data $'lorem=ipsum&$dolor=\\'sit\\'&amet={1..20}'") !== undefined, "Command should contain correct data."); 143 resolve(); 144 }); 151 }) 152 .then(resolve, reject); 153 154 InspectorTest.evaluateInPage("createPOSTRequestWithURLEncodedData()"); 145 155 } 146 156 }); … … 149 159 name: "POSTRequestURLEncodedDataUTF8GenerateCURL", 150 160 description: "Generate cURL command from a POST request with URL encoded UTF8 data.", 151 test : (resolve, reject) =>{152 InspectorTest.evaluateInPage("createPOSTRequestWithUTF8()");153 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded,(event) => {161 test(resolve, reject) { 162 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 163 .then((event) => { 154 164 let resource = event.data.resource; 155 165 let curl = resource.generateCURLCommand().split(" \\\n"); … … 157 167 InspectorTest.expectThat(curl[0].match("https?://.*?/resources/url\\?utf8=%F0%9F%91%8D") !== null, "Command should contain URL with UTF8 characters."); 158 168 InspectorTest.expectThat(curl.find((cmd) => cmd === "--data $'\\ud83c\\udf28=\\u26c4\\ufe0f'") !== undefined, "Command should contain correct UTF8 data."); 159 resolve(); 160 }); 169 }) 170 .then(resolve, reject); 171 172 InspectorTest.evaluateInPage("createPOSTRequestWithUTF8()"); 161 173 } 162 174 }); … … 165 177 name: "PUTRequestWithJSONGenerateCURL", 166 178 description: "Generate cURL command from a PUT request with JSON data.", 167 test : (resolve, reject) =>{168 InspectorTest.evaluateInPage("createPUTRequestWithJSON()");169 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded,(event) => {179 test(resolve, reject) { 180 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 181 .then((event) => { 170 182 let resource = event.data.resource; 171 183 let curl = resource.generateCURLCommand().split(" \\\n"); … … 174 186 InspectorTest.expectThat(curl.find((cmd) => cmd.includes('Content-Type')) === "-H 'Content-Type: application/json'", "Command should have JSON Content-Type."); 175 187 InspectorTest.expectThat(curl.find((cmd) => cmd === "--data-binary '{\"update\":\"now\"}'") !== undefined, "Command should contain correct JSON data."); 176 resolve(); 177 }); 188 }) 189 .then(resolve, reject); 190 191 InspectorTest.evaluateInPage("createPUTRequestWithJSON()"); 178 192 } 179 193 }); -
trunk/LayoutTests/http/tests/inspector/network/resource-timing-expected.txt
r205211 r206130 4 4 == Running test suite: ResourceTimingData 5 5 -- Running test case: CheckResourceTimingInformationForResource 6 PASS: Resource should be createad. 7 PASS: Added Resource received a response. 8 PASS: Added Resource did finish loading. 6 9 PASS: Newly added resource should have a resource timing model. 7 PASS: Newly added resource should have a start time.8 PASS: Resource should now contain timing information.9 10 PASS: Resource should have a start time. 10 11 PASS: Resource should have a request start time. … … 15 16 PASS: A secure connection should be reused or secureConnectionStart should come after connectStart. 16 17 PASS: responseStart should come after requestStart. 17 PASS: responseEnd should not be available yet.18 18 PASS: responseEnd should come after responseStart. 19 19 -
trunk/LayoutTests/http/tests/inspector/network/resource-timing.html
r205211 r206130 17 17 name: "CheckResourceTimingInformationForResource", 18 18 description: "Check if a resource has timing information.", 19 test: (resolve, reject) => { 19 test(resolve, reject) { 20 Promise.all([ 21 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded), 22 WebInspector.Resource.awaitEvent(WebInspector.Resource.Event.ResponseReceived), 23 WebInspector.Resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish) 24 ]) 25 .then(([resourceWasAddedEvent, responseReceivedEvent, loadingDidFinishEvent]) => { 26 let resource = resourceWasAddedEvent.data.resource; 27 28 InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be createad."); 29 InspectorTest.expectThat(resource === responseReceivedEvent.target, "Added Resource received a response."); 30 InspectorTest.expectThat(resource === loadingDidFinishEvent.target, "Added Resource did finish loading."); 31 32 let timingData = resource.timingData; 33 InspectorTest.expectThat(timingData instanceof WebInspector.ResourceTimingData, "Newly added resource should have a resource timing model."); 34 InspectorTest.expectThat(timingData.startTime > 0, "Resource should have a start time."); 35 InspectorTest.expectThat(timingData.requestStart > 0, "Resource should have a request start time."); 36 InspectorTest.expectThat(timingData.responseStart > 0, "Resource should have a response start time."); 37 38 InspectorTest.expectThat(typeof timingData.domainLookupStart === "number" && typeof timingData.domainLookupEnd === "number", "domainLookupStart and domainLookupEnd should both be NaN or a number."); 39 InspectorTest.expectThat(typeof timingData.connectStart === "number" && typeof timingData.connectStart === "number", "connectStart and connectEnd should both be NaN or a number."); 40 41 InspectorTest.expectThat(timingData.startTime <= timingData.requestStart, "requestStart should come after startTime."); 42 InspectorTest.expectThat(isNaN(timingData.secureConnectionStart) || timingData.connectStart <= timingData.secureConnectionStart, "A secure connection should be reused or secureConnectionStart should come after connectStart."); 43 InspectorTest.expectThat(timingData.requestStart <= timingData.responseStart, "responseStart should come after requestStart."); 44 InspectorTest.expectThat(timingData.responseStart <= timingData.responseEnd, "responseEnd should come after responseStart."); 45 }) 46 .then(resolve, reject); 47 20 48 InspectorTest.evaluateInPage("createRequest()"); 21 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {22 let resource = event.data.resource;23 24 InspectorTest.expectThat(resource.timingData instanceof WebInspector.ResourceTimingData, "Newly added resource should have a resource timing model.");25 InspectorTest.expectThat(resource.timingData.startTime, "Newly added resource should have a start time.");26 27 resource.singleFireEventListener(WebInspector.Resource.Event.ResponseReceived, (event) => {28 let timingData = resource.timingData;29 30 InspectorTest.expectThat(timingData, "Resource should now contain timing information.");31 InspectorTest.expectThat(timingData.startTime > 0, "Resource should have a start time.");32 InspectorTest.expectThat(timingData.requestStart > 0, "Resource should have a request start time.");33 InspectorTest.expectThat(timingData.responseStart > 0, "Resource should have a response start time.");34 35 InspectorTest.expectThat(typeof timingData.domainLookupStart === "number" && typeof timingData.domainLookupEnd === "number", "domainLookupStart and domainLookupEnd should both be NaN or a number.");36 InspectorTest.expectThat(typeof timingData.connectStart === "number" && typeof timingData.connectStart === "number", "connectStart and connectEnd should both be NaN or a number.");37 38 InspectorTest.expectThat(timingData.startTime <= timingData.requestStart, "requestStart should come after startTime.");39 InspectorTest.expectThat(isNaN(timingData.secureConnectionStart) || timingData.connectStart <= timingData.secureConnectionStart, "A secure connection should be reused or secureConnectionStart should come after connectStart.");40 InspectorTest.expectThat(timingData.requestStart <= timingData.responseStart, "responseStart should come after requestStart.");41 InspectorTest.expectThat(isNaN(timingData.responseEnd), "responseEnd should not be available yet.");42 });43 44 resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFinish, (event) => {45 let timingData = resource.timingData;46 InspectorTest.expectThat(timingData.responseStart <= timingData.responseEnd, "responseEnd should come after responseStart.");47 resolve();48 });49 });50 49 } 51 50 }); -
trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly.html
r202843 r206130 6 6 <script> 7 7 function createXHRResource() { 8 varrequest = new XMLHttpRequest();8 let request = new XMLHttpRequest(); 9 9 request.open("POST", "resources/", true); 10 10 request.send("utf8=👍"); … … 18 18 name: "XHRWithRequestDataIsEncodedCorrectly", 19 19 description: "XHR with request data is encoded correctly.", 20 test : (resolve, reject) =>{21 InspectorTest.evaluateInPage("createXHRResource()");22 WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded,(event) => {20 test(resolve, reject) { 21 WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded) 22 .then((event) => { 23 23 let resource = event.data.resource; 24 24 InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created."); 25 25 InspectorTest.expectThat(resource.requestData === "utf8=👍", "Request data should have expected content."); 26 resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFinish, (event) => { 27 InspectorTest.pass("Resource load should finish."); 28 resolve(); 29 }); 30 }); 26 return resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish); 27 }) 28 .then((event) => { 29 InspectorTest.pass("Resource load should finish."); 30 }) 31 .then(resolve, reject); 32 33 InspectorTest.evaluateInPage("createXHRResource()"); 31 34 } 32 35 }); 33 36 34 37 suite.runTestCasesAndFinish(); 35 38 }
Note: See TracChangeset
for help on using the changeset viewer.