Commit Graph

41 Commits

Author SHA1 Message Date
denihs
482acb00f6 Merge branch 'release-3.0' into release-3.0-tools-and-mongo
# Conflicts:
#	packages/promise/promise-tests.js
2023-01-23 15:41:56 -04:00
denihs
212a668cb7 - These methods are now async:
- `WebAppInternals.reloadClientPrograms()`
    - `WebAppInternals.pauseClient()`
    - `WebAppInternals.generateClientProgram()`
    - `WebAppInternals.generateBoilerplate()`
    - `WebAppInternals.setInlineScriptsAllowed()`
    - `WebAppInternals.enableSubresourceIntegrity()`
    - `WebAppInternals.setBundledJsCssUrlRewriteHook()`
    - `WebAppInternals.setBundledJsCssPrefix()`
2023-01-18 14:52:34 -04:00
Gabriel Grubba
ae3e31f977 tests: adjusted test to match express npm modules 2023-01-13 16:34:03 -03:00
Gabriel Grubba
c9c48ccf37 tests: solved webapp tests 2023-01-11 18:19:22 -03:00
Dirk Stolle
57ee10322d fix typos in several files 2021-05-13 01:02:31 +02:00
Ben Newman
41e2615424 Fix tests by awaiting newly-async WebApp.staticFilesMiddleware. 2018-07-11 10:32:29 -04:00
Ben Newman
0a336175c4 Let any client request any static resource. (#9965)
Fixes #9953.
2018-06-07 16:20:38 -04:00
Ben Newman
223ec46525 Use isModern(request.browser) to determine architecture of static files.
Note that WebAppInternals.staticFiles has been replaced by
WebAppInternals.staticFilesByArch.
2018-04-29 09:58:08 -04:00
Ben Newman
991fb5ea86 Rename Boilerplate#toHTML to toHTMLStream and deprecate toHTML.
PR #9343 changed the return type of Boilerplate#toHTML from String to
Stream, which is likely to break existing code that expects a string.

In order to make the change in return type more obvious, I have renamed
the method to toHTMLStream, and I have attempted to update all call sites
appropriately. However, because this change comes in the release candidate
phase of Meteor 1.6.1 testing, it seemed important to preserve the
string-returning behavior of toHTML, with a deprecation notice.

Unless third-party code is using the Boilerplate class directly, I don't
think the toHTML method will ever be called, and we can remove it in
Meteor 1.6.2.

Thanks to @macrozone for tracking this problem down.

Fixes #9521.
2018-01-09 12:12:11 -05:00
Ben Newman
8009351653 Simplify/modernize webapp tests. 2017-11-22 20:09:18 -05:00
James Baxley
7ef237f99c refactored to a single stream api 2017-11-22 20:09:18 -05:00
James Baxley
fb4e2b6f73 fix tests 2017-11-22 20:09:18 -05:00
Ben Newman
d4f1ebf321 Fix tests and address review feedback from @stubailo. 2017-11-13 09:25:10 -05:00
James Baxley
70e815e7be Upgrade webapp package's Npm.depends dependencies. (#9315) 2017-11-09 10:52:25 -05:00
Hugh Willson
18dcb4d6d2 Handle overridden _.template settings in boilerplate-generator (#9250)
* Handle overridden _.template settings in boilerplate-generator

When `underscore`'s default `_.template` settings are overridden
using `_.templateSettings` in an application, this can adversely
affect the `_.template` calls used by the `boilerplate-generator`
to render an application's initial HTML template. These changes
make sure the `boilerplate-generator` is overridding any
defined `_.templateSettings` with its own verified to work
settings.

Fixes #9149.

* Add comment explaining additional _.template config override

* Handle overridden _.templateSettings with the cordova boilerplate

* Remove underscore use wherever possible

* Change incorrect implementation of an "empty" manifest.

This test was trying to imply an empty manifest by using an empty
associative array (hash), whereas a manifest is only ever an array
of hashes (as per the bundler code).  Therefore, an empty manifest
should be an array with no items.

This is to fix the failure seen in https://travis-ci.org/meteor/meteor/builds/291857783?utm_source=github_status&utm_medium=notification
because of @hwillson's changes in 9aee811a4b.

Refs: meteor/meteor#9250.

* Make underscore replacement code more defensive

`_.map` handles a falsy input value, whereas `Array.prototype.map`
(obivously) does not. While not likely common practice, it's
possible falsy values are being passed into the boilerplate
generator, for elements like `js`, `css`, etc. These changes
replicate `_.map`'s handling of incoming falsy values by
converting them to an empty array.
2017-11-08 18:43:14 +02:00
Hugh Willson
3dac748d69 Always remove the configured socket file at startup 2017-08-14 14:19:13 -04:00
Hugh Willson
bc467daf8a Merge remote-tracking branch 'upstream/devel' into devel 2017-08-10 07:25:31 -04:00
Ben Newman
fb73388ce3 Make server-render API more flexible and isomorph-ish.
Render callbacks can now inject HTML content into multiple different
elements, and may also append content to the <head> or <body> elements, on
both the client and the server.

This new API was inspired by trying to use the styled-components npm
package on the server, which involves not only rendering and injecting
static HTML somewhere in the <body>, but also appending the resulting
<style> tag(s) into the <head>:

  import { onPageLoad } from "meteor/server-render";
  import { renderToString } from "react-dom/server";
  import { ServerStyleSheet } from "styled-components";

  onPageLoad(sink => {
    const sheet = new ServerStyleSheet();
    const html = renderToString(sheet.collectStyles(
      <App location={sink.request.url} />
    ));

    sink.renderIntoElementById("app", html);
    sink.appendToHead(sheet.getStyleTags());
  });

Note that the server-render package now exports an onPageLoad function,
rather than the old renderIntoElementById function. The functionality of
renderIntoElementById is now exposed by the {Client,Server}Sink API.

I say the client-side version of this API is 'isomorphish' to the
server-side version, because ClientSink methods can accept DOM nodes in
addition to raw HTML strings, whereas DOM nodes don't really make sense on
the server.
2017-06-29 15:08:32 -04:00
Ben Newman
44fd232489 Allow boilerplate data callbacks to return promises.
https://github.com/meteor/meteor/pull/8841#issuecomment-310848373
2017-06-26 14:52:29 -04:00
Ben Newman
d8c38bfe4c Give boilerplate data callbacks access to dynamic{Head,Body}, too. 2017-06-26 14:52:29 -04:00
Ben Newman
7ac873d0e1 Implement WebAppInternals.registerBoilerplateDataCallback.
This API allows registering callbacks that have the opportunity to modify
boilerplate.baseData on each request, which will be useful for
implementing server-side rendering.

The code in question behaves the same as before if there are no callbacks
registered, so this change should be completely backwards compatible.
2017-06-26 14:52:29 -04:00
Vlad Lasky
d9e7f8672b Rewritten to address concerns raised in abernix's review 2017-05-20 01:28:00 +10:00
Vlad Lasky
693ac8ae72 In response to hwillson's feedback, added test to webapp_tests for socketPath and made cosmetic fixes to UNIX socket code to conform better with meteor's coding style. 2017-05-18 01:28:46 +10:00
Eric Terpstra
412e502fa9 Allow PORT as a string if it matches named pipe pattern. Fixes #4413 2015-10-12 21:49:13 -07:00
David Glasser
1002349edb Add direct access to connect module from webapp 2015-03-05 17:12:36 -08:00
David Glasser
d4d349ca96 Don't overly escape Meteor.settings.public
Fixes #3730.

Testing Done:
Manual testing based on the report in #3730. Also confirmed that `</script>` is not a problem.

I would have added a test-packages test but there's no easy way to override Meteor.settings in test-packages.

Bugs closed: 3730

Reviewed at https://rbcommons.com/s/meteor/r/1/
2015-02-17 18:01:01 -08:00
David Glasser
096df9d62d Refactor parent pid check; drop --keepalive
This commit moves parent pid process from the webapp package to the boot
script. This means that daemonized apps without webapp will also exit
when the runner exits, if run from the runner. (For example, several
self-tests such as 'autoupdate' no longer leak node processes.) This is
controlled via the $METEOR_PARENT_PID environment variable instead of
from command line arguments, in order to make fewer assumptions about
how Meteor apps process arguments.

This also drops the old --keepalive support (which already has stopped
being used by the dev mode runner or any MDG deployment platforms).
Neither --parent-pid nor --keepalive were documented beforehand, and
--keepalive was already deprecated before 1.0.

These flags used to also incidentally trigger printing the LISTENING
line; this is now controlled by $METEOR_PRINT_ON_LISTEN.

Fixes #3315.
2015-01-05 15:48:32 -08:00
Emily Stark
bb29469856 Replace runtime config regression selftest with simpler unit test 2014-10-08 14:28:24 -07:00
Emily Stark
f510cd0174 Simplify validPid, thanks Ben 2014-09-26 14:42:12 -07:00
Emily Stark
1797d28d0e Factor out check for valid --parent-pid and add tests. 2014-09-26 14:36:40 -07:00
Slava Kim
497e47ca5b Another fix for webapp test and behavior.
The previous commit didn't really fix the issue
2014-09-05 15:31:06 -07:00
Slava Kim
590a733cd8 Fix a broken webapp test
Invalidate teh boilerplate after flipping the inlineScriptsAllowed flag
2014-09-05 14:55:31 -07:00
Matthew Arbesfeld
0af50c04ef Change client.* to web.* and accept client and web 2014-08-28 13:35:26 -07:00
Slava Kim
2feef6ec9f fix tests for webapp after merge 2014-08-06 14:56:36 -07:00
Matthew Arbesfeld
ae8c412c38 Fixed webapp tests for additional static files and __meteor_runtime_config__ 2014-07-28 11:57:28 -07:00
Emily Stark
168f21654c Rename serveStaticFiles to staticFilesMiddleware 2014-06-26 15:15:24 -07:00
Emily Stark
53936d3062 Wrap webapp test code in _noYieldsAllowed. 2014-06-26 15:08:41 -07:00
Emily Stark
afff81ffc5 New approach for reload safety belt testing.
Mutating global state in tests is still not a good idea. (Specifically,
in the previous version of the test, changing the value of
`WebAppInternals.inlineScriptsAllowed()` could mess with other
client-side tests that depend on it being one way or another -- of which
there are currently probably none, but there could be in theory.)

Instead, export the exact things we want to test (boilerplate HTML
generation and the static file handler). Now we are still mutating the
global `inlineScriptsAllowed()` state, but we don't yield before setting
it back to what it was.

Also simplify the reload-safetybelt test: instead of sending an HTTP
request, just check that the script gets adding to
`WebAppInternals.additionalStaticJs`.
2014-06-26 15:08:41 -07:00
Emily Stark
68b4c18627 Make more generic additionalStaticJs interface in webapp.
Now webapp doesn't need to know anything about the reload safetybelt; it
just exposes a generic interface that any package can use to include
additional static JS (inlined when possible) in the boilerplate
HTML. reload-safetybelt uses this interface, instead of webapp
weak-depending on reload-safetybelt.
2014-06-26 15:08:41 -07:00
Emily Stark
c044786e2f nim, glasser comments 2014-05-08 12:12:45 -07:00
Emily Stark
4afa54ca5a Set Content-Type header on js and css resources. 2014-05-08 12:12:45 -07:00