From 7102e87bf47f7ebc77ee82c35490c1e0aaf0e1c7 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Wed, 14 May 2014 18:44:19 -0400 Subject: [PATCH] Eliminate console spam during normal test execution. Three tests were (potentially) dumping text to console.log during the run, which they should never do. Fixing that revealed that one of them, the test for interrupting a long-running JS script, was not actually testing what it was supposed to test. Fixing *that* revealed that the long-running-script hook is broken and does not actually interrupt JS infinite loops; that test has been temporarily disabled. #12230 (Test suite improvements). --- test/webpage-spec.js | 18 ++++++++++++++---- test/webserver-spec.js | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/test/webpage-spec.js b/test/webpage-spec.js index 1a1252d9..6a30e996 100644 --- a/test/webpage-spec.js +++ b/test/webpage-spec.js @@ -1395,15 +1395,25 @@ describe("WebPage object", function() { }); }); - it("should interrupt a long-running JavaScript code", function() { + xit("should interrupt a long-running JavaScript code", function() { var page = new WebPage(); + var longRunningScriptCalled = false; + var loadStatus; page.onLongRunningScript = function() { page.stopJavaScript(); + longRunningScriptCalled = true; }; + page.onError = function () {}; - page.open('../test/webpage-spec-frames/forever.html', function(status) { - expect(status).toEqual('success'); + runs(function() { + page.open('../test/webpage-spec-frames/forever.html', + function(status) { loadStatus = status; }); + }); + waits(5000); + runs(function() { + expect(loadStatus).toEqual('success'); + expect(longRunningScriptCalled).toBeTruthy(); }); }); }); @@ -2168,7 +2178,7 @@ xdescribe("WebPage render image", function(){ content = fs.read(TEST_FILE, "b"); fs.remove(TEST_FILE); - } catch (e) { console.log(e) } + } catch (e) { jasmine.fail(e) } // for PDF test if (format === "pdf") { diff --git a/test/webserver-spec.js b/test/webserver-spec.js index ea8ea60d..c7cf4aab 100644 --- a/test/webserver-spec.js +++ b/test/webserver-spec.js @@ -31,9 +31,9 @@ function checkRequest(request, response) { if (expectedPostData !== false) { expect(request.method).toEqual("POST"); expect(request.hasOwnProperty('post')).toBeTruthy(); - console.log("request.post => " + JSON.stringify(request.post, null, 4)); - console.log("expectedPostData => " + JSON.stringify(expectedPostData, null, 4)); - console.log("request.headers => " + JSON.stringify(request.headers, null, 4)); + jasmine.log("request.post => " + JSON.stringify(request.post, null, 4)); + jasmine.log("expectedPostData => " + JSON.stringify(expectedPostData, null, 4)); + jasmine.log("request.headers => " + JSON.stringify(request.headers, null, 4)); if (request.headers["Content-Type"] && request.headers["Content-Type"] === "application/x-www-form-urlencoded") { expect(typeof request.post).toEqual('object'); expect(request.post).toEqual(expectedPostData);