29 Commits

Author SHA1 Message Date
Kasper Nilsson
75f467566a Add manual_review section to diff prefs
Bug: Issue 4676
Change-Id: Iecef2b7bc1d506b960b32f92bb1b8870c5b96c65
2018-02-09 22:21:00 +00:00
Paladox none
313e605fc6 Fix html syntax in gr-diff-preferences
Change-Id: Iaa5da5607b9ec90e0d80a7c906e316b6ef1b9687
2018-01-11 23:21:18 +00:00
Kasper Nilsson
eae9f56034 Fix focus stops in diff prefs and reply dialogs
Recent changes aligned PolyGerrit closer with the Material spec, which
moved many dialog actions from being left-aligned to right-aligned, and
with 'reverse' order.

In two cases (gr-diff-preferences and gr-reply-dialog), the focusStops
for the dialog were hardcoded to the first and last focusable DOM
elements in the dialog. When the button order was reversed, these were
not updated.

Bug: Issue 7775
Change-Id: I7faa4e49e9610f0196314a103dd4f5d6b2c1a456
2017-11-20 14:01:39 -08:00
Becky Siegel
d1f95e97ae Update a few gr-button styles
- Diff preferences
  - Use link button, align right
- diff comment
  - use link button, modify colors

Change-Id: Ibdd232b1f30d2d0d3e36ce708afbd35470f6da44
2017-10-12 00:52:20 +00:00
Becky Siegel
1a09820022 Update bold fonts to Roboto Medium
Bold fonts were inconsistent across platforms and new design specs use
Roboto Medium instead, so switching all currently bold fonts to use
that.

Change-Id: Ibfc5ffc3fc33517acb85acc0194215b4d7864cae
2017-09-08 16:06:35 -07:00
Becky Siegel
8d92d53db5 Annotation updates
Change-Id: I146f76b9dcc1a92e18acec01481ad280fb431868
2017-08-12 11:49:52 -07:00
Becky Siegel
10de103815 Revert "Update iron-input to 2.0"
This reverts commit 37636a62564b09df8d8e4e48828b72afdf817bb0.

Reason for revert: The googlesource.com environment is not ready for
this yet.

I didn't realize that we couldn't yet use the hybrid version of the
elements in google3 yet. They exist in the polymer2 directory, but
apparently that depends on using polymer2. This change will need to be
reverted until iron-input v1 is updated to get the polymer2 "hybrid"
version.

Change-Id: Ibeeae2458337b0a225993e12b043b1e65c3c4c04
2017-07-18 14:32:41 -07:00
Becky Siegel
37636a6256 Update iron-input to 2.0
This version is compatible with Polymer 1 and Polymer 2, but required
for Polymer 2.

Elements that were formerly
<input is="iron-input>

are now
<iron-input>
  <input>
</iron-input>

There are a few scenarios in which inputs were not using two way data
binding, which is the reason for using iron-input, and those have been
modified back to a native input.

With the updated iron-input to access the native input, there is an
'inputElement' getter function, which is used heavily in this update.

Also of note, in many tests, it is required to wrap Polymer.Base.async,
which is necessary because the mutation observer is async:

https://github.com/PolymerElements/iron-input/blob/master/test/iron-input.html

Also modifies polylint_test to explicitly ignore bower_components.

Change-Id: I75f7fa1bb0c00837f631f6e1043e15a3270b9bce
2017-07-17 10:20:08 -07:00
Wyatt Allen
27a7a367b1 Merge "Add polygerrit-ui/app/test/common-test-setup.html" 2017-06-06 00:40:15 +00:00
Becky Siegel
a4fc6de235 Fix various selectors for shadow dom
https://www.polymer-project.org/2.0/docs/devguide/style-shadow-dom

Bug: Issue 6372
Change-Id: I1918e86b31d4fa02b67d1b0e5ef9ae8f48877257
2017-06-05 22:42:22 +00:00
Mike Samuel
e07c4b2ea1 Add polygerrit-ui/app/test/common-test-setup.html
This is a partial roll-forward of c/106190

This replaces all loads of iron-test-helpers with a load of a file
that wraps it, and adds that file to test files that do not currently
load iron-test-helpers.

A future CL will also install polymer-resin via common-test-helpers.html.

I tested by running

$ WCT_ARGS="-l chrome" ./polygerrit-ui/app/run_test.sh

Change-Id: Ifb3cd2c8db13d724f57e56e7e78045470d103a43
2017-06-05 22:10:12 +00:00
Becky Siegel
b159a7f5cc Update styles for shadow dom
- Create a shared style module that is included in every custom element
- Add the shared style module to each existing element

Change-Id: I1ee382955afe4ff630548a6640e7c4d03688849d
2017-06-02 14:54:03 -07:00
Wyatt Allen
c601abccc3 Revert "Polygerrit now loads polymer-resin"
This reverts commit 0895052c01ac5ac657a9763d2ad9967d9ae55c18.

Reason for revert: issue 6387

Change-Id: I14e00addeab53606952aa3ea2d45a74eac7a9d8a
2017-06-02 09:37:37 -07:00
Mike Samuel
0895052c01 Polygerrit now loads polymer-resin
polymer-resin intercepts polymer property assignments
before they reach XSS-vulnerable sinks like `href="..."`
and text nodes in `<script>` elements.

This follows the instructions in WORKSPACE for adding a new bower
dependency with kaspern's tweak to use the dependency in a rule so
that it's found.  //lib/js/bower_components.bzl has already been
rolled-back per those instructions.

The license is the polymer license as can be seen at
https://github.com/Polymer/polymer-resin/blob/master/LICENSE though
I'm not sure that //tools/js/bower2bazel.py recognizes it as such.

Docs for the added component are available at
https://github.com/Polymer/polymer-resin/blob/master/README.md
https://github.com/Polymer/polymer-resin/blob/master/getting-started.md

With this change, when I introduce an XSS vulnerability as below,
polymer-resin intercepts and stops it.

Patch that introduces a strawman vulnerability.

--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
@@ -55,6 +55,10 @@
         url: '/q/status:abandoned',
         name: 'Abandoned',
       },
+      {
+        url: location.hash.replace(/^#/, '') || 'http://example.com/#fragment_echoed_here',
+        name: 'XSS Me',
+      },
     ],
   }];

---

Address kaspern's and paladox's comments.

---

Undo version bumps for bower dependencies.

---

Change Soy index template to parallel app/index.html.

---

update polymer-resin to version 1.1.1-beta

----

Load polymer-resin into polygerrit-ui/**/*_test.html

After this, I ran the tests with
  -l chrome
  -l firefox

I ran a handful of tests with -p and observed that the
console shows "initResin" is called before test cases start
executing.

These changes were done programmaticly by running the script below
(approximately) thus:
```
gerrit/ $ cd polygerrit-ui/app
app/ $ find . -name \*test.html | xargs perl hack-tests.pl
```

```
use strict;

sub removeResin($) {
  my $s = $_[0];
  $s =~ s@<link rel="import" href="[^"]*/polymer-resin/[^"]*"[^>]*>\n?@@;
  $s =~ s@<script src="[^"]*/polymer-resin/[^"]*"></script>\n?@@;
  $s =~ s@<script>\s*security\.polymer_resin.*?</script>\n?@@s;
  return $s;
}

for my $f (@ARGV) {
  next if $f =~ m@/bower_components/|/node_modules/@;

  system('git', 'checkout', $f);
  print "$f\n";

  my @lines = ();
  open(IN, "<$f") or die "$f: $!";
  my $maxLineOfMatch = 0;
  while (<IN>) {
    push(@lines, $_);
    # Put a marker after core loading directives.
    $maxLineOfMatch = scalar(@lines)
      if m@/webcomponentsjs/|/polymer[.]html\b|/browser[.]js@;
  }
  close(IN) or die "$f: $!";

  die "$f missing loading directives" unless $maxLineOfMatch;

  # Given ./a/b/c/my_test.html, $pathToRoot is "../../.."
  # assuming no non-leading . or .. components in the path from find.
  my $pathToRoot = $f;
  $pathToRoot =~ s@^\.\/@@;
  $pathToRoot =~ s@^(.*?/)?app/@@;
  $pathToRoot =~ s@\/[^\/]*$@@;
  $pathToRoot =~ s@[^/]+@..@g;

  my $nLines = scalar(@lines);
  open(OUT, ">$f") or die "$f: $!";

  # Output the lines up to the last polymer-resin dependency
  # loaded explicitly by this test.
  my $before = join '', @lines[0..($maxLineOfMatch - 1)];
  $before = removeResin($before);
  print OUT "$before";

  # Dump out the lines that load polymer-resin and configure it for
  # polygerrit.
  if (1) {
      print OUT qq'<link rel="import" href="$pathToRoot/bower_components/polymer-resin/standalone/polymer-resin-debug.html"/>
<script>
security.polymer_resin.install({allowedIdentifierPrefixes: [\'\']});
</script>
    ';
  }

  # Emit any remaining lines.
  my $after = join '', @lines[$maxLineOfMatch..$#lines];
  $after = removeResin($after);
  $after =~ s/^\n*//;
  print OUT "$after";

  close(OUT) or die "$f: $!";
}
```

---

update polymer-resin to version 1.2.1-beta

---

update Soy index template to new style polymer-resin initialization

----

fix lint warnings

----

Load test/common-test-setup.html into *_test.html

Instead of inserting instructions to load and initialize polymer-resin into
every test file, add a common-test-setup.html that does that and also fold
iron-test-helpers loading into it.

----

imported files do not need to load webcomponentsjs

Change-Id: I71221c36ed8a0fe7f8720c1064a2fcc9555bb8df
2017-05-30 23:16:09 -04:00
Kasper Nilsson
90111b882a ES6ify /gr-diff-preferences/*
Bug: Issue 6179
Change-Id: I5a68c4db6d196f5724a5702f7433c41c3cf7b7fd
2017-05-16 14:21:31 -07:00
Becky Siegel
7a45400e24 Move diff overlay to gr-diff-preferences
Previously, gr-diff-preferences was the contents that was displayed in
an overlay contained in the gr-diff-view.  There were a handful of
functions that crossed between the two-- the diff preferences element
would fire events that needed to be handled by the diff view.

Because the gr-diff-preferences element will be added to the change
view as well, the overlay has been moved to be part of the diff
preferences element. This way, the element can handle all of the actions
taken by the panel, and all the parent element needs to do is call
the open function.

A separate change will come with the addition of diff preferences in the
change view.

Bug: Issue 5426
Change-Id: Id7396147e73354122ea3825bde2c324b5daa1d26
2017-04-19 13:25:25 -07:00
Viktar Donich
29e1ce5e84 Collection of prospective test flake fixes
Potentially related:
https://github.com/Polymer/web-component-tester/issues/505

Bug: Issue 5792
Change-Id: I9ab6e8e40d9811dd52906335426764c052907609
2017-03-30 13:46:58 -07:00
Becky Siegel
07c8a169d6 Use sentence case for names of options
Continue to use title case for titles/section titles.

Bug: Issue 5685
Change-Id: I848a3277f80d9959ff1cbbe78b2368d1e3c87e0f
2017-03-15 14:21:33 -07:00
Wyatt Allen
d970500d62 Annotate trailing whitespace per user preference
Add a simple annotation layer that marks trailing whitespace in diffs
(guarded by the `show_whitespace_errors` diff preference). The newly
supported diff preference is added to both diff preference controls. The
requirement that all annotation layers must implement `addListener` is
relaxed as the trailing whitespace layer is the third layer that doesn't
use it.

Adds tests for the layer and the diff preference.

Feature: Issue 4836
Change-Id: Ifba05216bf0bc3c0a8a094f5ef392b983091d59f
2016-11-20 13:31:30 -08:00
Becky Siegel
e7d19a9976 Add preference for line wrapping in diff preferences
Previously in Polygerrit, diff views were always displayed in the width
specified in diff preferences. This change gives the option to wrap
lines instead, which takes precedence over column width (the column
width option is hidden when line wrapping is selected), and fits the
diff view to screen.

The gerrit API already supports the 'lineWrapping' preference so this
change uses that already existing option.

Feature: Issue 4809
Change-Id: I0d9e292739b5910abfd04af63ec4c745bf06e446
2016-10-31 17:35:21 -07:00
Becky Siegel
1f5a8510b7 Safeguard for font preferences if server has skew
Added temporary safeguard for the font preferences change so that inputs
are hidden and custom styles are not set if font-size was not part of
the preferneces response.

Change-Id: I5b34b317bf953591889fa25e1c351d4f490d989e
2016-10-14 14:13:36 -07:00
Becky Siegel
d7dbed640c Add a diff preference for font size
This change adds a font size field in diff preferences in both the
generic preferences page and also the preferences modal from the diff
view. The new field allows users to update their preferred font size
for the diff view to be displayed. This updates both the line number
font size as well as the diff font size.

Feature: Issue 4417
Change-Id: I0fb75fd2186d2ff63b3627e8b0f15f2b3cddbfa3
2016-10-12 16:31:24 -07:00
beckysiegel
c47410c816 Focus and tab between diff preferences inputs
Previously, the diff preferences form did not automatically focus to the
first textfield and did not allow tabbing between input fields. This
change adds autofocus when the overlay is opened and allows for tabbing
between the other input fields in the modal.

Bug: Issue 4140
Change-Id: If15812bb4404ca4061597755eeaf68d4cae23b3f
2016-09-20 18:30:29 -07:00
Wyatt Allen
7c66d99a1c Respect the diff preference for syntax highlighting
Adds checkboxes to both diff preferences controls, adds an `enabled`
boolean property to the `gr-syntax-layer` element, and updates all
relevant tests.

Bug: Issue 4297
Change-Id: I10cef760c354c53e03acfb3c84379e82859ef25f
2016-07-27 11:14:54 -07:00
Viktar Donich
60d8bce771 Release range comments
Remove beta diff setting and enable range comments for all.

Change-Id: I0cee7e1717574ab54317cdce9e2332c8cda7a0cb
2016-07-14 14:45:15 -07:00
Viktar Donich
5008b4491f Add a checkbox to hide ranged comments behind
Also adds concept of locally stored preferences.

Change-Id: Ib074a682228d5360a932af696e18967e8e3473be
2016-06-08 15:29:11 -07:00
Andrew Bonventre
1c4369b518 Add diff preferences dialog to gr-new-diff
Change-Id: I3024f46fff0a47e7a4e7a8f5beff9929d8ccb50b
2016-03-24 16:35:07 -04:00
Andrew Bonventre
02f71327cf Add comments/drafts to gr-new-diff
Change-Id: I8110b521ab83a31be5db7e3d65268186485db04d
2016-03-22 11:55:03 -04:00
Andrew Bonventre
78792e8e98 Refactor directory structure of components
There is no change in functionality. Only moving things around.

+ Separate html from the js.
+ Place the unit test for a component within the same folder.
+ Organize the components in subfolders.

Change-Id: I51fdc510db75fc1b33f040ca63decbbdfd4d5513
2016-03-04 18:02:24 -05:00