Skip to content

Conversation

@cpcallen
Copy link
Collaborator

@cpcallen cpcallen commented Jul 9, 2021

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

The problem

Unlike goog.provide packages, goog.module modules are loaded using XMLHttpRequest when in uncompiled mode. Because browsers treat file: URLs as each being a separate, unique origin, CORS rules prevent browsers from loading goog.module modules from file: URLs.

Proposed Changes

Use the http-server npm to serve the repository root directory on localhost:8080.

Provide a script so that you can type npm start to start the local http server and automatically open a browser window pointing at tests/playground.html.

Modify the setBackgroundColour function in the playgrounds to provide the usual lilac background on locahost URLs and a sickly green one if using a file: URL (all of which will soon stop working).

(The background doesn't actually appear to be visible in the advanced playground.)

Developer Behaviour Before Change

We have opened file:///.../blockly/tests/playground.html to do local manual testing.

Developer Behaviour After Change

We will run npm start to do local manual testing. To access the advanced playground, we need only then navigate to http://localhost:8080/tests/playgrounds/advanced_playground.html.

Test Coverage

Tested manually locally on macOS.

Documentation

At minimum:

should be updated with instructions to run npm start (after npm install) to load up the playground.

(I don't believe I have the ability to modify either of these directly.)

Additional Information

Should this PR target the goog_module branch instead of develop? There's nothing goog.module specific about it (i.e., we wouldn't necessarily want to undo this even if the whole module migration is abandoned), but it is only necessary because of that migration.

(N.B.: I'm planning to fast-forward goog_module to the tip of develop once #4968 is merged, before it gets any PRs of its own.)

Unlike goog.provide packages, goog.module modules are loaded using
XMLHttpRequest in uncompiled mode.  Because browsers treat file: URLs
as each being a separate, unique origin, this means that CORS rules
prevent goog.module modules being loaded from a file URL.

To work around this, use the http-server npm to serve the repository
root directory on localhost:8080.

Provide a script so that you can type `npm start` to start the local
http server and automatically open a browser window pointing at
tests/playground.html.

Modify the setBackgroundColour function in the playgrounds to provide
the usual lilac background on locahost URLs and a sickly green one
if using a file: URL, all of which will soon stop working.

(The background doesn't actually appear to be visible in the advanced
playground.)
@cpcallen cpcallen added component: devtools internal External contributions not accepted labels Jul 9, 2021
@cpcallen cpcallen requested a review from a team as a code owner July 9, 2021 15:44
@cpcallen cpcallen requested a review from NeilFraser July 9, 2021 15:44
@cpcallen cpcallen merged commit 1306e41 into RaspberryPiFoundation:develop Jul 9, 2021
@cpcallen cpcallen deleted the http-server branch July 9, 2021 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: devtools internal External contributions not accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants