Problem/Motivation
The Manual Crop module uses inline Javascript. Any site using a strong Content Security Policy will want to exclude inline Javascript, and the Manual Crop button will break. Existing Panopoly Behat tests only check for the presence of the Crop button, not whether it works.
Steps to reproduce
- Install the latest dev version of Panopoly 7.x with starter content
- Set a Content Security Policy header that disallows inline JS (do not output the 'unsafe-inline' keyword).
- Customize a page and create an Image widget. Note that the Crop button appears.
- Click the Crop button.
- Note that nothing happens.
Proposed resolution
Patch Manual Crop (see #3177209: Remove inline Javascript so that CSP doesn't require 'unsafe-inline') and add a Behat test that verifies what we can verify - probably we can test that the button opens the Crop dialog, the expected Crop buttons are present, and saving the crop returns us to the host page.
Remaining tasks
Write a Behat test that demonstrates the issue - DONE.
Update the Panopoly Images makefile to apply Manual Crop patch - DONE.
Run Behat tests to verify the fix - DONE.
Manual testing to verify that Crop works as expected - DONE.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | panopoly_images-manualcrop-csp-3177807-5.patch | 468 bytes | cboyden |
| #3 | panopoly_test-manualcrop-csp-3177807-3.patch | 3.02 KB | cboyden |
Comments
Comment #2
cboyden commentedHere's a patch that adds a Behat test to verify the basic functions of Manual Crop: Activate the crop button; make a selection (using Maximize selection); save the crop; reopen and undo the crop (using Remove selection). MC does something to duplicate and then hide its buttons, so the patch required adding a new Behat region to find the active links.
The patch in the linked issue #3177209: Remove inline Javascript so that CSP doesn't require 'unsafe-inline' needs to be updated to do some button text switching; until that's done, this test will not pass with the patch in that issue.
Comment #3
cboyden commentedUpdated patch to reflect that Remove selection is available from the start on a new, uncropped upload.
Comment #4
cboyden commentedThe new Manual Crop test is passing, see https://travis-ci.org/github/cboyden/panopoly/builds/737480633 for results. Failures on some of the update jobs seem to be unrelated to the new test. This is without a strict CSP; it just verifies that manual crop works without the new patch and without CSP.
I've tested locally with a strict CSP and the test fails, so this verifies that the test detects what it's supposed to detect. Once the patch in #3177209: Remove inline Javascript so that CSP doesn't require 'unsafe-inline' is updated, if this test passes, we're good.
Comment #5
cboyden commentedThe manualcrop patch has been updated and passes in my local testing with strict CSP. Here's a patch to add that to the panopoly_images makefile.
Edit: Tests are generally passing: https://travis-ci.org/github/cboyden/panopoly/builds/738447028
Comment #6
cboyden commentedComment #7
cboyden commentedComment #9
dsnopekThanks! Committed :-)