Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/extensionsIntegrated/Phoenix-live-preview/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ define(function (require, exports, module) {
let panel,
urlPinned,
currentLivePreviewURL = "",
currentPreviewFile = '';
currentPreviewFile = '',
_loadGeneration = 0;

function _blankIframe() {
// we have to remove the dom node altog as at time chrome fails to clear workers if we just change
Expand Down Expand Up @@ -795,8 +796,12 @@ define(function (require, exports, module) {
if(!isPreviewLoadable){
return;
}
const thisGeneration = ++_loadGeneration;
// panel-live-preview-title
let previewDetails = await StaticServer.getPreviewDetails();
if(thisGeneration !== _loadGeneration) {
return; // A newer _loadPreview call has been made; this one is stale
}
if(urlPinned && !force) {
return;
}
Expand Down
50 changes: 38 additions & 12 deletions test/spec/KeybindingManager-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ define(function (require, exports, module) {
await _writeKeyboardJson(KeyBindingManager._getUserKeyMapFilePath());
await KeyBindingManager._loadUserKeyMapImmediate();
await awaitsFor(async ()=>{
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return Object.keys(textJson.overrides).length === 0;
try {
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return Object.keys(textJson.overrides).length === 0;
} catch (e) {
return false; // file may be mid-write; retry on next poll
}
}, "reset user shortcuts");
await awaitsFor(()=>{
const binding = KeyBindingManager.getKeyBindings(Commands.EDIT_BEAUTIFY_CODE);
Expand Down Expand Up @@ -203,26 +207,38 @@ define(function (require, exports, module) {
testWindow.$(".change-shortcut-dialog .Remove").click();
let existingBinding = KeyBindingManager.getKeyBindings(Commands.EDIT_BEAUTIFY_CODE);
await awaitsFor(async ()=>{
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides[existingBinding[0].key] === null;
try {
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides[existingBinding[0].key] === null;
} catch (e) {
return false; // file may be mid-write; retry on next poll
}
}, "command to be removed");
});

it("Should be able to assign Function key shortcut association", async function () {
await editShortcut(Commands.EDIT_BEAUTIFY_CODE);
keyboardType('F6');
await awaitsFor(async ()=>{
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides['F6'] === Commands.EDIT_BEAUTIFY_CODE;
try {
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides['F6'] === Commands.EDIT_BEAUTIFY_CODE;
} catch (e) {
return false; // file may be mid-write; retry on next poll
}
}, "F6 to be assigned");
});

it("Should be able to assign Shift-Function key shortcut association", async function () {
await editShortcut(Commands.EDIT_BEAUTIFY_CODE);
keyboardType('Shift-F6');
await awaitsFor(async ()=>{
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides['Shift-F6'] === Commands.EDIT_BEAUTIFY_CODE;
try {
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides['Shift-F6'] === Commands.EDIT_BEAUTIFY_CODE;
} catch (e) {
return false; // file may be mid-write; retry on next poll
}
}, "Shift-F6 to be assigned");
});

Expand All @@ -246,8 +262,12 @@ define(function (require, exports, module) {
expect(testWindow.$(".change-shortcut-dialog .Assign").is(":visible")).toBeTrue();
testWindow.$(".change-shortcut-dialog .Assign").click();
await awaitsFor(async ()=>{
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides['F1'] === Commands.EDIT_BEAUTIFY_CODE;
try {
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return textJson.overrides['F1'] === Commands.EDIT_BEAUTIFY_CODE;
} catch (e) {
return false; // file may be mid-write; retry on next poll
}
}, "F1 to be assigned");
});

Expand All @@ -262,8 +282,14 @@ define(function (require, exports, module) {
expect(testWindow.$(".change-shortcut-dialog .Assign").is(":visible")).toBeTrue();
testWindow.$(".change-shortcut-dialog .Cancel").click();
await awaits(200);
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
expect(textJson.overrides).toEql({});
await awaitsFor(async ()=>{
try {
const textJson = JSON.parse(await _readKeyboardJson(KeyBindingManager._getUserKeyMapFilePath()));
return Object.keys(textJson.overrides).length === 0;
} catch (e) {
return false; // file may be mid-write; retry on next poll
}
}, "overrides to be empty");
expect(testWindow.$(".change-shortcut-dialog").is(":visible")).toBeFalse();
});

Expand Down
Loading