Skip to content

Commit

Permalink
fix: spec runner runs from tauri:// urls
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Oct 5, 2023
1 parent 4116f00 commit 2df41e9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ exports.buildDebug = series(copyThirdPartyLibs.copyAllDebug, makeLoggerConfig, z
exports.clean = series(cleanDist);
exports.reset = series(cleanAll);

exports.releaseDev = series(cleanDist, exports.build, makeDistAll, releaseDev,
exports.releaseDev = series(cleanDist, exports.buildDebug, makeDistAll, releaseDev,
createDistCacheManifest, createDistTest);
exports.releaseStaging = series(cleanDist, exports.build, makeDistNonJS, makeJSDist, releaseStaging,
createDistCacheManifest, createDistTest);
Expand Down
2 changes: 1 addition & 1 deletion src/extensibility/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ define(function (require, exports, module) {
d.reject(Errors.MALFORMED_URL);
return d.promise();
}
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
if (!(parsed.protocol === "http:" || parsed.protocol === "https:" || parsed.protocol === "tauri:")) {
d.reject(Errors.UNSUPPORTED_PROTOCOL);
return d.promise();
}
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/QuickView/ImagePreviewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define(function (require, exports, module) {
extensionlessImagePreview; // Whether to try and preview extensionless URLs

// List of protocols which we will support for image preview urls
let validProtocols = ["data:", "http:", "https:", "ftp:", "file:"];
let validProtocols = ["data:", "http:", "https:", "tauri:", "ftp:", "file:"];

prefs = PreferencesManager.getExtensionPrefs("quickview");

Expand Down
4 changes: 3 additions & 1 deletion src/filesystem/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,8 @@ define(function (require, exports, module) {

// attach remote file handlers
var HTTP_PROTOCOL = "http:",
HTTPS_PROTOCOL = "https:";
HTTPS_PROTOCOL = "https:",
TAURI_PROTOCOL = "tauri:";

var protocolAdapter = {
priority: 0, // Default priority
Expand All @@ -1241,4 +1242,5 @@ define(function (require, exports, module) {
// Register the custom object as HTTP and HTTPS protocol adapter
registerProtocolAdapter(HTTP_PROTOCOL, protocolAdapter);
registerProtocolAdapter(HTTPS_PROTOCOL, protocolAdapter);
registerProtocolAdapter(TAURI_PROTOCOL, protocolAdapter);
});
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@
'http://127.0.0.1:8000': true, // phcode dev server
'http://127.0.0.1:8001': true, // phcode dev live preview server
'http://127.0.0.1:5000': true, // playwright tests
'tauri://localhost': true, // tauri prod app
'https://phcode.live': true, // phcode prod live preview server
'https://phcode.dev': true,
'https://dev.phcode.dev': true,
'https://staging.phcode.dev': true,
'https://create.phcode.dev': true
}
};
window.Phoenix.TRUSTED_ORIGINS[location.origin] = true;
Phoenix.isSupportedBrowser = Phoenix.browser.isTauri ||
(Phoenix.browser.isDeskTop && ("serviceWorker" in navigator));
window.testEnvironment = window.Phoenix.isTestWindow;
Expand Down
10 changes: 7 additions & 3 deletions test/SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
}
</script>

<!-- Import the phoenix browser virtual file system -->
<script src="../src/phoenix/virtualfs.js"></script>

<script>
// environment setup for boot. do not move out of index html!!
(function(){
Expand Down Expand Up @@ -135,14 +138,17 @@
'http://127.0.0.1:8000': true, // phcode dev server
'http://127.0.0.1:8001': true, // phcode dev live preview server
'http://127.0.0.1:5000': true, // playwright tests
'tauri://localhost': true, // tauri prod app
'https://phcode.live': true, // phcode prod live preview server
'https://phcode.dev': true,
'https://dev.phcode.dev': true,
'https://staging.phcode.dev': true,
'https://create.phcode.dev': true
}
};
Phoenix.isSupportedBrowser = Phoenix.browser.isDeskTop && ("serviceWorker" in navigator);
window.Phoenix.TRUSTED_ORIGINS[location.origin] = true;
Phoenix.isSupportedBrowser = Phoenix.browser.isTauri ||
(Phoenix.browser.isDeskTop && ("serviceWorker" in navigator));
window.testEnvironment = window.Phoenix.isTestWindow;

// now setup PhoenixBaseURL, which if of the form https://phcode.dev/ or tauri://localhost/
Expand All @@ -160,8 +166,6 @@
}());
</script>

<!-- Import the phoenix browser virtual file system -->
<script src="../src/phoenix/virtualfs.js"></script>
<script src="../src/phoenix/shell.js" type="module"></script>
<script src="virtual-server-loader.js" type="module"></script>

Expand Down
6 changes: 5 additions & 1 deletion test/spec/SpecRunnerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ define(function (require, exports, module) {
path = path.split("/");
path = path.slice(0, path.length - 2);
path.push("src");
return window.location.origin + path.join("/");
let url = window.location.origin + path.join("/");
if (!url.endsWith("/")){
url = url + "/";
}
return url;
}

/**
Expand Down

0 comments on commit 2df41e9

Please sign in to comment.