Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/LiveDevelopment/Inspector/inspector.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
});
});
</script>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" rel="stylesheet">
Copy link
Member

Choose a reason for hiding this comment

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

There are two entries for rel="stylesheet"

<style>
body {padding: 70px 0 20px 0;}
h3, dl {font-family: Menlo, Monaco, "Courier New", monospace;}
Expand Down
57 changes: 32 additions & 25 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ define(function LiveDevelopment(require, exports, module) {
}

// Clear all documents from request filtering
_server.clear();
if (_server) {
_server.clear();
}
}

/**
Expand Down Expand Up @@ -533,8 +535,6 @@ define(function LiveDevelopment(require, exports, module) {
// No longer in site, so terminate live dev, but don't close browser window
Inspector.disconnect();
_closeReason = "navigated_away";
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 should have been handled in the _onDisconnect handler to begin with.

_setStatus(STATUS_INACTIVE);
_server = null;
}
}

Expand All @@ -545,12 +545,17 @@ define(function LiveDevelopment(require, exports, module) {

unloadAgents();

// Stop listening for requests when disconnected
_server.stop();

// Close live documents
_closeDocuments();

if (_server) {
// Stop listening for requests when disconnected
_server.stop();

// Dispose server
_server = null;
}

_setStatus(STATUS_INACTIVE);
}

Expand Down Expand Up @@ -593,11 +598,15 @@ define(function LiveDevelopment(require, exports, module) {
}

if (Inspector.connected()) {
var timer = window.setTimeout(cleanup, 5000); // 5 seconds
Inspector.Runtime.evaluate("window.open('', '_self').close();", function (response) {
Inspector.disconnect();
window.clearTimeout(timer);
cleanup();
// Close the browser tab/window
var closePromise = Inspector.Runtime.evaluate("window.open('', '_self').close();");

// Add a timeout to force cleanup if Inspector does not respond
closePromise = Async.withTimeout(closePromise, 5000);
Copy link
Member Author

Choose a reason for hiding this comment

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

Cleanup: Use withTimeout util instead of setTimeout


// Disconnect the Inspector after closing the tab/winow
closePromise.always(function () {
Inspector.disconnect().always(cleanup);
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix async bug where cleanup would update the status before a disconnect completed.

});
} else {
cleanup();
Expand Down Expand Up @@ -922,23 +931,21 @@ define(function LiveDevelopment(require, exports, module) {
function _onDocumentChange() {
var doc = _getCurrentDocument();

if (!doc) {
if (!doc || !Inspector.connected()) {
return;
}

if (Inspector.connected()) {
hideHighlight();

// close the current session and begin a new session if the current
// document changes to an HTML document that was not loaded yet
var wasRequested = agents.network && agents.network.wasURLRequested(doc.url),
isHTML = exports.config.experimental || _isHtmlFileExt(doc.extension);

if (!wasRequested && isHTML) {
// TODO (jasonsanjose): optimize this by reusing the same connection
// no need to fully teardown.
close().done(open);
}
hideHighlight();

// close the current session and begin a new session if the current
// document changes to an HTML document that was not loaded yet
var wasRequested = agents.network && agents.network.wasURLRequested(doc.url),
isViewable = exports.config.experimental || _server.canServe(doc.file.fullPath);
Copy link
Member Author

Choose a reason for hiding this comment

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

Move to canServe to match workflow in LiveDevServerManager.


if (!wasRequested && isViewable) {
// TODO (jasonsanjose): optimize this by reusing the same connection
// no need to fully teardown.
close().done(open);
}
}

Expand Down
7 changes: 2 additions & 5 deletions test/spec/LiveDevelopment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,7 @@ define(function (require, exports, module) {

afterEach(function () {
waitsForDone(LiveDevelopment.close(), "Waiting for browser to become inactive", 10000);

runs(function () {
testWindow.closeAllFiles();
});
testWindow.closeAllFiles();
});

it("should establish a browser connection for an opened html file", function () {
Expand Down Expand Up @@ -690,7 +687,7 @@ define(function (require, exports, module) {
// Verify that we still have modified text
expect(updatedNode.value).toBe("Live Preview in Brackets is awesome!");
});

// Save original content back to the file after this test passes/fails
runs(function () {
htmlDoc.setText(origHtmlText);
Expand Down