Skip to content

Commit 039a465

Browse files
committed
fix: failing markdown live preview focus integ tests
1 parent cb2e9ef commit 039a465

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/extensionsIntegrated/Phoenix-live-preview/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ define(function (require, exports, module) {
9595
if($iframe && $iframe[0]) {
9696
const iframeDom = $iframe[0];
9797
iframeDom.contentWindow.postMessage({
98+
type: "WHO_AM_I_RESPONSE",
9899
isTauri: Phoenix.browser.isTauri
99100
}, "*"); // this is not sensitive info, and is only dispatched if requested by the iframe
100101
}

src/extensionsIntegrated/Phoenix-live-preview/markdown.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525
return; // Ignore messages from unexpected origins
2626
}
2727

28-
window.__PHOENIX_EMBED_INFO = {
29-
isTauri: event.data.isTauri
30-
};
28+
if(event.data.type === "WHO_AM_I_RESPONSE") {
29+
window.__PHOENIX_EMBED_INFO = {
30+
isTauri: event.data.isTauri
31+
};
32+
} else if(event.data.type === "_TEST_FOCUS_CLICK") { // for integ tests
33+
document.body.click();
34+
}
3135
});
3236
if(window.self !== window.parent){
3337
// in an iframe

test/spec/LiveDevelopmentMultiBrowser-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,17 @@ define(function (require, exports, module) {
618618
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["readme.md"]),
619619
"readme.md");
620620

621+
// now make the active editor loose focus and click on the markdown md for it to
622+
// trigger focus.
621623
await awaits(300);
622624
let outerIFrame = testWindow.document.getElementById("panel-live-preview-frame");
623625
expect(outerIFrame.src.endsWith("readme.md")).toBeTrue();
624626
outerIFrame.focus();
625627
expect(testWindow.document.activeElement).toEqual(outerIFrame);
628+
outerIFrame.contentWindow.postMessage({
629+
type: "_TEST_FOCUS_CLICK",
630+
isTauri: Phoenix.browser.isTauri
631+
}, "*"); // this is not sensitive info, and is only dispatched if requested by the iframe
626632

627633
// Editor lost focus, it will gain back as the editor detects it lost focus to live preview pane in 100 ms
628634
await awaits(500);

0 commit comments

Comments
 (0)