Merge "Convert gr-kyeboard-shortcuts-dialog_test to typescript"
diff --git a/Documentation/cmd-create-project.txt b/Documentation/cmd-create-project.txt
index 9e3d70b..0575eb9 100644
--- a/Documentation/cmd-create-project.txt
+++ b/Documentation/cmd-create-project.txt
@@ -53,9 +53,10 @@
 -b::
 	Name of the initial branch(es) in the newly created project.
 	Several branches can be specified on the command line.
-	If several branches are specified then the first one becomes HEAD
-	of the project. If none branches are specified then default value
-	('master') is used.
+	If several branches are specified then the first one becomes
+	link:project-configuration.html#default-branch[HEAD] of the project.
+	If none branches are specified then link:config-gerrit.html#gerrit.defaultBranch[host-level default]
+	is used.
 
 --owner::
 -o::
diff --git a/Documentation/concept-changes.txt b/Documentation/concept-changes.txt
index 6de787c..0444fab 100644
--- a/Documentation/concept-changes.txt
+++ b/Documentation/concept-changes.txt
@@ -104,6 +104,9 @@
 Assigning a topic to a change can be done in the change screen or through a `git
 push` command.
 
+For more information about using topics, see the user guide:
+link:cross-repository-changes.html[Submitting Changes Across Repositories by using Topics].
+
 [[submit-strategies]]
 == Submit strategies
 
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 23720460..4ce5360 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -2122,6 +2122,13 @@
 +
 Defaults to `All-Projects` if not set.
 
+[[gerrit.defaultBranch]]gerrit.defaultBranch::
++
+Name of the link:project-configuration.html#default-branch[default branch]
+to use on the project creation, if no other branches were specified in the input.
++
+Defaults to `refs/heads/master` if not set.
+
 [[gerrit.allUsers]]gerrit.allUsers::
 +
 Name of the project in which meta data of all users is stored.
@@ -2197,11 +2204,21 @@
 By default unset, as the HTTP daemon must be configured externally
 by the system administrator, and might not even be running on the
 same host as Gerrit.
-
++
+[[gerrit.installBatchModule]]gerrit.installBatchModule::
++
+Repeatable list of class name of additional Guice modules to load as
+override to the batchInjector's modules during the init phases.
+Classes are resolved using the primary Gerrit class loader, hence the
+class needs to be either declared in Gerrit or an additional JAR
+located under the `/lib` directory.
++
+By default unset.
++
 [[gerrit.installDbModule]]gerrit.installDbModule::
 +
 Repeatable list of class name of additional Guice modules to load at
-Gerrit startup as part of the dbInjector and during the init phases.
+Gerrit startup as part of the dbInjector.
 Classes are resolved using the primary Gerrit class loader, hence the
 class needs to be either declared in Gerrit or an additional JAR
 located under the `/lib` directory.
@@ -2211,7 +2228,7 @@
 [[gerrit.installModule]]gerrit.installModule::
 +
 Repeatable list of class name of additional Guice modules to load at
-Gerrit startup as part of the sysInjector and during the init phases.
+Gerrit startup as part of the sysInjector.
 Classes are resolved using the primary Gerrit class loader, hence the
 class needs to be either declared in Gerrit or an additional JAR
 located under the `/lib` directory.
@@ -2224,6 +2241,7 @@
   installModule = com.googlesource.gerrit.libmodule.MyModule
   installModule = com.example.abc.OurSpecialSauceModule
   installDbModule = com.example.def.OurCustomProvider
+  installBatchModule = com.example.ghi.CustomBatchInitModule
 ----
 
 [[gerrit.listProjectsFromIndex]]gerrit.listProjectsFromIndex::
diff --git a/Documentation/config-validation.txt b/Documentation/config-validation.txt
index cb953c1..56c9ecd 100644
--- a/Documentation/config-validation.txt
+++ b/Documentation/config-validation.txt
@@ -21,6 +21,14 @@
 Out of the box, Gerrit includes a plugin that checks the length of the
 subject and body lines of commit messages on uploaded commits.
 
+[plugin-push-options]]
+=== Plugin push options
+
+Plugins can register push options by implementing the `PluginPushOption`
+interface. If a plugin push option was specified it is available from
+the `CommitReceivedEvent` that is passed into `CommitValidationListener`.
+This way the plugin commit validation can be controlled by push options.
+
 [[user-ref-operations-validation]]
 == User ref operations validation
 
diff --git a/Documentation/cross-repository-changes.txt b/Documentation/cross-repository-changes.txt
new file mode 100644
index 0000000..136219c
--- /dev/null
+++ b/Documentation/cross-repository-changes.txt
@@ -0,0 +1,252 @@
+:linkattrs:
+= Gerrit Code Review - Submitting Changes Across Repositories by using Topics
+
+== Goal
+
+This document describes how to propose and submit code changes across multiple
+Git repositories together in Gerrit.
+
+== When to Use
+
+Oftentimes, especially for larger code bases, code is split across multiple
+repositories. The Android operating system’s code base, for example, consists of
+https://android.googlesource.com/[hundreds] of separate repositories. When
+making a change, you might make code changes that span multiple repositories.
+For example, one repository could define an API which is used in another
+repository. Submitting these changes across these repositories separately could
+cause the build to break for other developers.
+
+Gerrit provides a mechanism called link:intro-user.html#topics[Topics] to submit
+changes together to prevent this problem.
+
+|===
+|NOTE: Usage of topics to submit multiple changes together requires your
+Gerrit host having
+link:config-gerrit.html#change.submitWholeTopic[config.submitWholeTopic] set to
+true. Ask your Gerrit administrator if you're not sure if this is enabled for
+your Gerrit instance.
+|===
+
+== What is a Topic?
+
+* A topic is a string that can be associated with a change.
+* Multiple changes can use that topic to be submitted at the same time (assuming
+  approvals, etc.).
+* Submitting a change with a topic causes all of the changes in the topic *to be
+  submitted together*
+  ** Topics that span only a single repository are guaranteed to be submitted
+  together
+  ** Topics that span multiple repositories simply triggers submission of all
+  changes. No other guarantees are given. Submission of all changes could
+  fail, so you could get a partial topic submission. This is very rare but
+  can happen in some of the following situations:
+  *** Storage layer failures. This is unlikely in single-master installation and
+  more likely with multi-master setups.
+  *** Race conditions. Concurrent submits to the same repository or concurrent
+  updates of the pending changes.
+
+Here are a few intricacies you should be aware of:
+
+1. Topics can only be used for changes within a single Gerrit instance. There is
+no builtin support for synchronizing with other Gerrit or Git hosting sites.
+
+2. A topic can be any string, and they are not namespaced in a Gerrit instance;
+there is a chance for collisions and inadvertently grouping changes together
+that weren’t meant to be grouped. This could even happen with changes you can’t
+see, leading to more confusion e.g. (change not submittable, but you can't see
+why it's not submittable.). We suggest prefixing topic strings with the author’s
+username e.g. “username-” to help avoid this.
+
+You can view the assigned topic from the change screen in Gerrit:
+
+image::images/cross-repository-changes-topic.png[width=600]
+
+=== Topic submission behavior
+* Submitting a topic will submit any dependent changes as well. For example,
+  an unsubmitted parent change will also be submitted, even if it isn’t in the
+  original topic.
+* A change with a topic is submittable when *all changes* in the topic are
+  submittable and *all of the changes’ dependent changes* (and their topics!)
+  are also submittable.
+* Gerrit calls the totality of these changes "Submitted Together", and they can
+be found with the
+  link:rest-api-changes.html#submitted-together[Submitted Together endpoint] or
+  on the change screen.
+
+image::images/cross-repository-changes-submitted-together.png[width=600]
+
+* A submission creates a unique submission ID
+    (link:rest-api-changes.html#change-info[`submission_id`]), which can be
+    used in Gerrit's search bar to find all the submitted changes for the
+    submission. This ID is relevant when <<reverting,reverting a submission>>.
+
+To better underestand this behavior, consider this following example.
+
+==== Example Submission[[example_submission]]
+
+image::images/cross-repository-changes-example.png[width=600]
+
+* Two repositories: A and B
+* Two changes in A: A1 and A2, where A2 is the child change.
+* Two changes in B: B1 and B2, where B2 is the child change.
+* Topic X contains change A1 and B1
+* Topic Y contains change A2 and B2
+
+Submission of A2 will submit all four of these changes because submission of A2
+submits all of topic Y as well as all dependent changes and their topics i.e. A1
+and topic X.
+
+Because of this, any submission is blocked until all four of these changes are
+submittable.
+
+|===
+| Important point: B1 can unexpectedly block the submission of A2!
+This kind of situation is hard to immediately grok: B1 isn't in the topic you're
+trying to submit, and it isn't a depnedent change of A2. If your topic isn’t
+submittable and you can’t figure out why, this might be a reason.
+|===
+
+== Submitting Changes Using Topics
+
+=== 1. *Associate the changes to a topic*
+
+The first step is to associate all the changes you want to be submitted together
+with the same topic. There are multiple ways to associate changes with a topic.
+
+==== From the command line
+You can set the topic name when uploading to Gerrit
+
+----
+$ git push origin HEAD:refs/heads/master -o topic=[YOUR_TOPIC_NAME]
+----
+
+*OR*
+
+----
+$ git push origin HEAD:refs/for/master%topic=[YOUR_TOPIC_NAME]
+----
+
+If you’re using https://source.android.com/setup/develop[repo] to upload a
+change to Android Gerrit, you can associate a topic via:
+
+----
+$ repo upload -o topic=[YOUR_TOPIC_NAME]
+----
+
+If you’re using
+https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools.html[depot_tools]
+to upload a change to Chromium Gerrit, you can associate a topic via:
+
+----
+$ git cl upload --topic=[YOUR_TOPIC_NAME]
+----
+
+==== From the UI
+
+If the change has already been created, you can add a topic from the change page
+by clicking ADD TOPIC, found on the left side of the top of the Change screen.
+
+image::images/cross-repository-changes-add-topic.png[width=600]
+
+=== 2. *Go through the normal code review process*
+
+Each change still goes through the normal code review process where reviewers
+vote on each change individually. The changes won’t be able to be submitted
+until *all* changes in the topic are submittable.
+
+The requirements for submittability vary based on rules set by your repository
+administrators; often this includes being approved by all requisite parties,
+passing presubmit testing, and being able to merge cleanly (without conflicts)
+into the target branch.
+
+=== 3. *Submit the change*
+
+When all changes in the topic are submittable, you’ll see *SUBMIT WHOLE TOPIC*
+at the top of the _Change screen_. Clicking it will submit all the changes in
+"Submitted Together."
+
+image::images/cross-repository-changes-submit-topic.png[width=600]
+
+== Reverting a Submission[[reverting]]
+
+After a topic is submitted, you can revert all or one of the changes by clicking
+the *REVERT* button on any change.
+
+image::images/cross-repository-changes-revert-topic.png[width=600]
+
+This will give you the option to either revert just the change in question or
+the entire topic:
+
+image::images/cross-repository-changes-revert-topic-options.png[width=600]
+
+Reverting the entire submission creates revert commits for each change and
+automatically associates them together under the same topic. To submit
+these changes, go through the normal review process.
+
+When submitting a topic, dependent changes and their topics are submitted as
+well. The RevertSubmission creates reverts for all the changes that were
+submitted at that time. When reverting the submission described in
+<<example_submission,Example Submission>>, all 4 of those changes will get
+reverted.
+
+|===
+| NOTE: We say “reverting a submission” instead of “reverting a submitted
+  topic” because submissions are defined by submission id, not by the topic
+  string. So even though topics names could be reused, this doesn't effect
+  reverting. For example:
+
+  1. Submission #1 uses topic A
+
+  2. Later, Submission #2 uses topic A again
+
+  Reverting submission #2 only reverts the changes in that submission, not all
+  changes included in topic A.
+|===
+
+== Cherry-Picking a Topic
+
+You may want to cherry-pick the changes (i.e. copy the changes) of a topic to
+another branch, perhaps because you have multiple branches that all need to be
+updated with the same change (e.g. you're porting a security fix across
+branches). Gerrit provides a mechanism to create these changes.
+
+From the overflow menu (3 dot icon) in the top right of the Change Screen,
+select “Cherry pick.” In the screenshot below, we’re showing this on a
+submitted change, but this option is available if the change is pending as
+well.
+
+image::images/cross-repository-changes-cp-menu.png[width=600]
+
+Afterwards, you’ll be presented with a modal where you can “Cherry Pick entire
+topic.”
+
+image::images/cross-repository-changes-cp-modal.png[width=600]
+
+Enter the branch name that you want to target for these repositories. The
+branch must already exist on all of the repositories. After clicking
+“CHERRY PICK,” Gerrit will create new changes all targeting the entered
+branch in their respective repositories, and these new changes will all be
+associated with a new, uniquely-generated topic name.
+
+To submit the cherry-picked changes, go through the normal submission
+process.
+
+|===
+| NOTE: You cannot cherry pick two or more changes that all target the same
+ repository from the Gerrit UI at this time; you’ll get an error message saying
+ “changes cannot be of the same repository.” To accomplish this, you’d
+ need to do the cherry-pick locally.
+|===
+
+== Searching for Topics
+
+In the Gerrit search bar, you can search for changes attached to a specific
+topic using the `topic` operator e.g. `topic:MY_TOPIC_NAME`. The `intopic`
+operator works similary but supports free-text and regular expression search.
+
+You can also search for a submission using the `submissionid` operator. Topic
+submission IDs are "<id>-<topic>" where id is the change number of the change
+that triggered the submission (though this could change in the future). As a
+full example, if the topic name is my-topic and change 12345 was the one that
+triggered submission, you could find it with `submissionid:12345-my-topic`.
+
diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt
index 8197550..adc9be5 100644
--- a/Documentation/dev-bazel.txt
+++ b/Documentation/dev-bazel.txt
@@ -255,7 +255,7 @@
 with BUILD Files` button of link:https://ij.bazel.build[Bazel plugin,role=external,window=_blank].
 
 [[documentation]]
-=== Documentation
+== Documentation
 
 To build only the documentation for testing or static hosting:
 
@@ -375,6 +375,24 @@
 for fine-grained test selection that can be combined with many of the examples
 above.
 
+[[debugging-tests]]
+== Debugging Unit Tests
+In some cases it may be necessary to debug a test while running it in bazel. For example, when we
+observe a different test result in Eclipse and bazel. Using the `--java_debug` option will start the
+JVM in debug mode and await for a remote debugger to attach.
+
+Example:
+[source,bash]
+----
+  bazel test --java_debug --test_tag_filters=delete-project //...
+  ...
+  Listening for transport dt_socket at address: 5005
+  ...
+----
+
+Now attach with a debugger to the port `5005`. For example use "Remote Java Application" launch
+configuration in Eclipe and specify the port `5005`.
+
 [[elasticsearch]]
 === Elasticsearch
 
diff --git a/Documentation/dev-design.txt b/Documentation/dev-design.txt
index c94862e..203b368 100644
--- a/Documentation/dev-design.txt
+++ b/Documentation/dev-design.txt
@@ -18,83 +18,45 @@
 
 == Background
 
-Google developed Mondrian, a Perforce based code review tool to
-facilitate peer-review of changes prior to submission to the central
-code repository.  Mondrian is not open source, as it is tied to the
-use of Perforce and to many Google-only services, such as Bigtable.
-Google employees have often described how useful Mondrian and its
-peer-review process is to their day-to-day work.
-
-Guido van Rossum open sourced portions of Mondrian within Rietveld,
-a similar code review tool running on Google App Engine, but for
-use with Subversion rather than Perforce.  Rietveld is in common
-use by many open source projects, facilitating their peer reviews
-much as Mondrian does for Google employees.  Unlike Mondrian and
-the Google Perforce triggers, Rietveld is strictly advisory and
-does not enforce peer-review prior to submission.
-
 Git is a distributed version control system, wherein each repository
 is assumed to be owned/maintained by a single user.  There are no
 inherent security controls built into Git, so the ability to read
 from or write to a repository is controlled entirely by the host's
-filesystem access controls.  When multiple maintainers collaborate
-on a single shared repository a high degree of trust is required,
-as any collaborator with write access can alter the repository.
+filesystem or network access controls.
 
-Gitosis provides tools to secure centralized Git repositories,
-permitting multiple maintainers to manage the same project at once,
-by restricting the access to only over a secure network protocol,
-much like Perforce secures a repository by only permitting access
-over its network port.
+The objective of Gerrit is to facilitate Git development by larger
+teams: it provides a means to enforce organizational policies around
+code submissions, eg. "all code must be reviewed by another
+developer", "all code shall pass tests". It achieves this by
 
-The Android Open Source Project (AOSP) was founded by Google by the
-open source releasing of the Android operating system.  AOSP has
-selected Git as its primary version control tool.  As many of the
-engineers have a background of working with Mondrian at Google,
-there is a strong desire to have the same (or better) feature set
-available for Git and AOSP.
+* providing fine-grained (per-branch, per-repository, inheriting)
+  access controls, which allow a Gerrit admin to delegate permissions
+  to different team(-lead)s.
 
-Gerrit Code Review started as a simple set of patches to Rietveld,
-and was originally built to service AOSP. This quickly turned
-into a fork as we added access control features that Guido van
-Rossum did not want to see complicating the Rietveld code base. As
-the functionality and code were starting to become drastically
-different, a different name was needed. Gerrit calls back to the
-original namesake of Rietveld, Gerrit Rietveld, a Dutch architect.
-
-Gerrit 2.x is a complete rewrite of the Gerrit fork, completely
-changing the implementation from Python on Google App Engine, to Java
-on a J2EE servlet container and an SQL database.
-
-Since Gerrit 3.x link:note-db.html[NoteDb] replaced the SQL database
-and all metadata is now stored in Git.
-
-* link:http://video.google.com/videoplay?docid=-8502904076440714866[Mondrian Code Review On The Web,role=external,window=_blank]
-* link:https://github.com/rietveld-codereview/rietveld[Rietveld - Code Review for Subversion,role=external,window=_blank]
-* link:http://eagain.net/gitweb/?p=gitosis.git;a=blob;f=README.rst;hb=HEAD[Gitosis README,role=external,window=_blank]
-* link:http://source.android.com/[Android Open Source Project,role=external,window=_blank]
-
+* facilitate code review: Gerrit offers a web view of pending code
+  changes, that allows for easy reading and commenting by humans. The
+  web view can offer data coming out of automated QA processes (eg.
+  CI). The permission system also includes fine grained control of who
+  can approve pending changes for submission to further facilitate
+  delegation of code ownership.
 
 == Overview
 
 Developers create one or more changes on their local desktop system,
 then upload them for review to Gerrit using the standard `git push`
-command line program, or any GUI which can invoke `git push` on
-behalf of the user.  Authentication and data transfer are handled
-through SSH.  Users are authenticated by username and public/private
-key pair, and all data transfer is protected by the SSH connection
-and Git's own data integrity checks.
+command line program, or any GUI which can invoke `git push` on behalf
+of the user. Authentication and data transfer are handled through SSH
+and HTTPS. Uploads are protected by the authentication,
+confidentiality and integrity offered by the transport (SSH, HTTPS).
 
-Each Git commit created on the client desktop system is converted
-into a unique change record which can be reviewed independently.
-Change records are stored in NoteDb.
+Each Git commit created on the client desktop system is converted into
+a unique change record which can be reviewed independently.
 
 A summary of each newly uploaded change is automatically emailed
 to reviewers, so they receive a direct hyperlink to review the
 change on the web.  Reviewer email addresses can be specified on the
-`git push` command line, but typically reviewers are automatically
-selected by Gerrit by identifying users who have change approval
-permissions in the project.
+`git push` command line, but typically reviewers are added in the web
+interface.
 
 Reviewers use the web interface to read the side-by-side or unified
 diff of a change, and insert draft inline/file comments where
@@ -103,20 +65,16 @@
 emailed to the change author by Gerrit, and are CC'd to all other
 reviewers who have already commented on the change.
 
-When publishing comments reviewers are also given the opportunity
-to score the change, indicating whether they feel the change is
-ready for inclusion in the project, needs more work, or should be
-rejected outright.  These scores provide direct feedback to Gerrit's
-change submit function.
+Reviewers can score the change ("vote"), indicating whether they feel the
+change is ready for inclusion in the project, needs more work, or
+should be rejected outright. These scores provide direct feedback to
+Gerrit's change submit function.
 
-After a change has been scored positively by reviewers, Gerrit
-enables a submit button on the web interface.  Authorized users
-can push the submit button to have the change enter the project
-repository.  The equivalent in Subversion or Perforce would be
-that Gerrit is invoking `svn commit` or `p4 submit` on behalf of
-the web user pressing the button.  Due to the way Git audit trails
-are maintained, the user pressing the submit button does not need
-to be the author of the change.
+After a change has been scored positively by reviewers, Gerrit enables
+a submit button on the web interface. Authorized users can push the
+submit button to have the change enter the project repository. The
+user pressing the submit button does not need to be the author of the
+change.
 
 
 == Infrastructure
@@ -125,18 +83,30 @@
 HTTP server.  As nearly all of the user interface is implemented
 through PolyGerrit, the majority of these requests are transmitting
 compressed JSON payloads, with all HTML being generated within the
-browser.  Most responses are under 1 KB.
+browser.
 
-Gerrit's HTTP server side component is implemented as a standard
-Java servlet, and thus runs within any J2EE servlet container.
-Popular choices for deployments would be Tomcat or Jetty, as these
-are high-quality open-source servlet containers that are readily
-available for download.
+Gerrit's HTTP server side component is implemented as a standard Java
+servlet, and thus runs within any link:install-j2ee.html[J2EE servlet
+container]. The standard install will run inside Jetty, which is
+included in the binary.
 
-End-user uploads are performed over SSH, so Gerrit's servlets also
-start up a background thread to receive SSH connections through
-an independent SSH port.  SSH clients communicate directly with
-this port, bypassing the HTTP server used by browsers.
+End-user uploads are performed over SSH or HTTP, so Gerrit's servlets
+also start up a background thread to receive SSH connections through
+an independent SSH port. SSH clients communicate directly with this
+port, bypassing the HTTP server used by browsers.
+
+User authentication is handled by identity realms. Gerrit supports the
+following types of authentication:
+
+* OpenId (see link:http://openid.net/developers/specs/[OpenID Specifications,role=external,window=_blank])
+* OAuth2
+* LDAP
+* Google accounts (on googlesource.com)
+* SAML
+* Kerberos
+* 3rd party SSO
+
+=== NoteDb
 
 Server side data storage for Gerrit is broken down into two different
 categories:
@@ -156,28 +126,119 @@
 local ones, due to Git disk IO behavior not being optimized for
 remote access.
 
-The Gerrit metadata contains a summary of the available changes,
-all comments (published and drafts), and individual user account
-information.  The metadata is mostly housed in the database (*1),
-which can be located either on the same server as Gerrit, or on
-a different (but nearby) server.  Most installations would opt to
-install both Gerrit and the metadata database on the same server,
-to reduce administration overheads.
+The Gerrit metadata contains a summary of the available changes, all
+comments (published and drafts), and individual user account
+information.
 
-User authentication is handled by OpenID, and therefore Gerrit
-requires that the OpenID provider selected by a user must be
-online and operating in order to authenticate that user.
+Gerrit metadata is also stored in Git, with the commits marking the
+historical state of metadata. Data is stored in the trees associated
+with the commits, typically using Git config file or JSON as the base
+format. For metadata, there are 3 types of data: changes, accounts and
+groups.
 
-* link:http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html[Git Repository Format,role=external,window=_blank]
-* link:http://openid.net/developers/specs/[OpenID Specifications,role=external,window=_blank]
+Accounts are stored in a special Git repository `All-Users`.
 
-*1  Although an effort is underway to eliminate the use of the
-database altogether, and to store all the metadata directly in
-the git repositories themselves.  So far, as of Gerrit 2.2.1, of
-all Gerrit's metadata, only the project configuration metadata
-has been migrated out of the database and into the git
-repositories for each project.
+Accounts can be grouped in groups. Gerrit has a built-in group system,
+but can also interface to external group system (eg. Google groups,
+LDAP). The built-in groups are stored in `All-Users`.
 
+Draft comments are stored in `All-Users` too.
+
+Permissions are stored in Git, in a branch `refs/meta/config` for the
+repository. Repository configuration (including permissions) supports
+single inheritance, with the `All-Projects` repository containing
+site-wide defaults.
+
+Code review metadata is stored in Git, alongside the code under
+review. Metadata includes change status, votes, comments. This review
+metadata is stored in NoteDb along with the submitted code and code
+under review. Hence, the review history can be exported with `git
+clone --mirror` by anyone with sufficient permissions.
+
+== Permissions
+
+Permissions are specified on branch names, and given to groups. For
+example,
+
+```
+[access "refs/heads/stable/*"]
+        push = group Release-Engineers
+```
+
+this provides a rule, granting Release-Engineers push permission for
+stable branches.
+
+There are fundamentally two types of permissions:
+
+* Write permissions (who can vote, push, submit etc.)
+
+* Read permissions (who can see data)
+
+Read permissions need special treatment across Gerrit, because Gerrit
+should only surface data (including repository existence) if a user
+has read permission. This means that
+
+* The git wire protocol support must omit references from
+  advertisement if the user lacks read permissions
+
+* Uploads through the git wire protocol must refuse commits that are
+  based on SHA1s for data that the user can't see.
+
+* Tags are only visible if their commits are visible to user through a
+  non-tag reference.
+
+Metadata (eg. OAuth credentials) is also stored in Git. Existing
+endpoints must refuse creating branches or changes that expose these
+metadata or allow changes to them.
+
+
+=== Indexing
+
+Almost all data is stored as Git, but Git only supports fast lookup by
+SHA1 or by ref (branch) name. Therefore Gerrit also has an indexing
+system (powered by Lucene by default) for other types of queries.
+There are 4 indices:
+
+* Project index - find repositories by name, parent project, etc.
+* Account index - find accounts by name, email, etc.
+* Group index - find groups by name, owner, description etc.
+* Change index - find changes by file, status, modification date etc.
+
+The base entities are characterized by SHA1s. Storing the
+characterizing SHA1s allows detection of stale index entries.
+
+== Plug-in architecture
+
+Gerrit has a plug-in architecture. Plugins can be installed by
+dropping them into $site_directory/plugins, or at runtime through
+plugin SSH commands, or the plugin REST API.
+
+=== Backend plugins
+
+At runtime, code can be loaded from a `.jar` file. This code can hook
+into predefined extension points. A common use of plugins is to have
+Gerrit interoperate with site-specific tools, such as CI-systems or
+issue trackers.
+
+// list some notable extension points, and notable plugins
+// link to plugin development
+
+Some backend plugins expose the JVM for scripting use (eg. Groovy,
+Scala), so plugins can be written without having to setup a Java
+development environment.
+
+// Luca to expand: how do script plugins load their scripts?
+
+=== Frontend plugins
+
+The UI can be extended using Frontend plugins. This is useful for
+changing the look & feel of Gerrit, but it can also be used to surface
+data from systems that aren't integrated with the Gerrit backend, eg.
+CI systems or code coverage providers.
+
+// FE team to write a bit more:
+// * how to load ?
+// * XSRF, CORS ?
 
 == Internationalization and Localization
 
@@ -189,14 +250,11 @@
 and comments in English, and therefore an English user interface
 is usable by the target user base.
 
-Right-to-left (RTL) support is only barely considered within the
-Gerrit code base.  Some portions of the code have tried to take
-RTL into consideration, while others probably need to be modified
-before translating the UI to an RTL language.
-
 
 == Accessibility Considerations
 
+// UI team to rewrite this.
+
 Whenever possible Gerrit displays raw text rather than image icons,
 so screen readers should still be able to provide useful information
 to blind persons accessing Gerrit sites.
@@ -215,7 +273,9 @@
 
 == Browser Compatibility
 
-Supporting non-JavaScript enabled browsers is a non-goal for Gerrit.
+Gerrit requires a JavaScript enabled browser.
+
+// UI team to add section on minimum browser requirements.
 
 As Gerrit is a pure JavaScript application on the client side, with
 no server side rendering fallbacks, the browser must support modern
@@ -223,54 +283,19 @@
 Dumb clients such as `lynx`, `wget`, `curl`, or even many search engine
 spiders are not able to access Gerrit content.
 
-There are number of web browsers available with full JavaScript
-support, and nearly every operating system (including any PDA-like
-mobile phone) comes with one standard.  Users who are committed
-to developing changes for a Gerrit managed project can be expected
-to be able to run a JavaScript enabled browser, as they also would
-need to be running Git in order to contribute.
-
-There are a number of open source browsers available, including
-Firefox and Chromium.  Users have some degree of choice in their
-browser selection, including being able to build and audit their
-browser from source.
-
-The majority of the content stored within Gerrit is also available
-through other means, such as gitweb or the `git://` protocol.
-Any existing search engine spider can crawl the server-side HTML
-produced by gitweb, and thus can index the majority of the changes
-which might appear in Gerrit.  Some engines may even choose to
-crawl the native version control database, such as ohloh.net does.
-Therefore the lack of support for most search engine spiders is a
-non-issue for most Gerrit deployments.
+All of the content stored within Gerrit is also available through
+other means, such as gitweb or the `git://` protocol. Any existing
+search engine crawlers can index the server-side HTML served by a code
+browser, and thus can index the majority of the changes which might
+appear in Gerrit. Therefore the lack of support for most search engine
+crawlers is a non-issue for most Gerrit deployments.
 
 
 == Product Integration
 
-Gerrit integrates with an existing gitweb installation by optionally
-creating hyperlinks to reference changes on the gitweb server.
-
-Gerrit integrates with an existing git-daemon installation by
-optionally displaying `git://` URLs for users to download a
-change through the native Git protocol.
-
-Gerrit integrates with any OpenID provider for user authentication,
-making it easier for users to join a Gerrit site and manage their
-authentication credentials to it.  To make use of Google Accounts
-as an OpenID provider easier, Gerrit has a shorthand "Sign in with
-a Google Account" link on its sign-in screen.  Gerrit also supports
-a shorthand sign in link for Yahoo!.  Other providers may also be
-supported more directly in the future.
-
-Site administrators may limit the range of OpenID providers to
-a subset of "reliable providers".  Users may continue to use
-any OpenID provider to publish comments, but granted privileges
-are only available to a user if the only entry point to their
-account is through the defined set of "reliable OpenID providers".
-This permits site administrators to require HTTPS for OpenID,
-and to use only large main-stream providers that are trustworthy,
-or to require users to only use a custom OpenID provider installed
-alongside Gerrit Code Review.
+Gerrit optionally surfaces links to HTML pages in a code browser. The
+links are configurable, and Gerrit comes with a built-in code browser,
+called Gitiles.
 
 Gerrit integrates with some types of corporate single-sign-on (SSO)
 solutions, typically by having the SSO authentication be performed
@@ -290,16 +315,17 @@
 Gerrit does not integrate with any Google service, or any other
 services other than those listed above.
 
+Plugins (see above) can be used to drive product integrations from the
+Gerrit side. Products that support Gerrit explicitly can use the REST
+API or the SSH API to contact Gerrit.
+
+
 == Privacy Considerations
 
 Gerrit stores the following information per user account:
 
 * Full Name
 * Preferred Email Address
-* Mailing Address '(Optional, Encrypted)'
-* Country '(Optional, Encrypted)'
-* Phone Number '(Optional, Encrypted)'
-* Fax Number '(Optional, Encrypted)'
 
 The full name and preferred email address fields are shown to any
 site visitor viewing a page containing a change uploaded by the
@@ -325,271 +351,145 @@
 The user's name and email address is stored unencrypted in the
 link:config-accounts.html#all-users[All-Users] repository.
 
-The snail-mail mailing address, country, and phone and fax numbers
-are gathered to help project leads contact the user should there
-be a legal question regarding any change they have uploaded.
-
-These sensitive fields are immediately encrypted upon receipt with
-a GnuPG public key, and stored "off site" in another data store,
-isolated from the main Gerrit change data.  Gerrit does not have
-access to the matching private key, and as such cannot decrypt the
-information.  Therefore these fields are write-once in Gerrit, as not
-even the account owner can recover the values they previously stored.
-
-It is expected that the address information would only need to be
-decrypted and revealed with a valid court subpoena, but this is
-really left to the discretion of the Gerrit site administrator as
-to when it is reasonable to reveal this information to a 3rd party.
-
-
 == Spam and Abuse Considerations
 
-Gerrit makes no attempt to detect spam changes or comments.  The
-somewhat high barrier to entry makes it unlikely that a spammer
-will target Gerrit.
+There is no spam protection for the Git protocol upload path.
+Uploading a change successfully requires a pre-existing account, and a
+lot of up-front effort.
 
-To upload a change, the client must speak the native Git protocol
-embedded in SSH, with some custom Gerrit semantics added on top.
-The client must have their public key already stored in the Gerrit
-database, which can only be done through the XSRF protected
-JSON-RPC interface.  The level of effort required to construct
-the necessary tools to upload a well-formatted change that isn't
-rejected outright by the Git and Gerrit checksum validations is
-too high to for a spammer to get any meaningful return.
+Gerrit makes no attempt to detect spam changes or comments in the web
+UI. To post and publish a comment a client must sign in and then use
+the XSRF protected JSON-RPC interface to publish the draft on an
+existing change record.
 
-To post and publish a comment a client must sign in with an OpenID
-provider and then use the XSRF protected JSON-RPC interface to
-publish the draft on an existing change record.  Again, the level of
-effort required to implement the Gerrit specific XSRF protections
-and the JSON-RPC payload format necessary to post a draft and then
-publish that draft is simply too high for a spammer to bother with.
-
-Both of these assumptions are also based upon the idea that Gerrit
-will be a lot less popular than blog software, and thus will be
-running on a lot fewer websites.  Spammers therefore have very little
-returned benefit for getting over the protocol hurdles.
-
-These assumptions may need to be revisited in the future if any
-public Gerrit site actually notices spam.
-
-
-== Latency
-
-Gerrit targets for sub-250 ms per page request, mostly by using
-very compact JSON payloads between client and server.  However, as
-most of the serving stack (network, hardware, metadata
-database) is out of control of the Gerrit developers, no real
-guarantees can be made about latency.
+Absence of SPAM handling is based upon the idea that Gerrit caters to
+a niche audience, and will therefore be unattractive to spammers. In
+addition, it is not a factor for corporate, on-premise deployments.
 
 
 == Scalability
 
-Gerrit is designed for a very large scale open source project, or
-large commercial development project.  Roughly this amounts to
-parameters such as the following:
+Gerrit supports the Git wire protocol, and an API (one API for HTTP,
+and one for SSH).
 
-.Design Parameters
-[options="header"]
-|======================================================
-|Parameter        | Default Maximum | Estimated Maximum
-|Projects         |         1,000   | 10,000
-|Contributors     |         1,000   | 50,000
-|Changes/Day      |           100   |  2,000
-|Revisions/Change |            20   |     20
-|Files/Change     |            50   | 16,000
-|Comments/File    |           100   |    100
-|Reviewers/Change |             8   |      8
-|======================================================
+The git wire protocol does a client/server negotiation to avoid
+sending too much data. This negotation occupies a CPU, so the number
+of concurrent push/fetch operations should be capped by the number of
+CPUs.
 
-Out of the box, Gerrit will handle the "Default Maximum". Site
-administrators may reconfigure their servers by editing gerrit.config
-to run closer to the estimated maximum if sufficient memory is made
-available to the JVM and the relevant cache.*.memoryLimit variables
-are increased from their defaults.
-
-=== Discussion
-
-Very few, if any open source projects have more than a handful of
-Git repositories associated with them.  Since Gerrit treats each
-Git repository as a project, an upper limit of 10,000 projects
-is reasonable.  If a site has more than 1,000 projects, administrators
-should increase
-link:config-gerrit.html#cache.name.memoryLimit[`cache.projects.memoryLimit`]
-to match.
-
-Almost no open source project has 1,000 contributors over all time,
-let alone on a daily basis.  This default figure of 1,000 was WAG'd by
-looking at PR statements published by cell phone companies picking
-up the Android operating system.  If all of the stated employees in
-those PR statements were working on *only* the open source Android
-repositories, we might reach the 1,000 estimate listed here.  Knowing
-these companies as being very closed-source minded in the past, it
-is very unlikely all of their Android engineers will be working on
-the open source repository, and thus 1,000 is a very high estimate.
-
-The upper maximum of 50,000 contributors is based on existing
-installations that are already handling quite a bit more than the
-default maximum of 1,000 contributors. Given how the user data is
-stored and indexed, supporting 50,000 contributor accounts (or more)
-is easily possible for a server. If a server has more than 1,000
-*active* contributors,
-link:config-gerrit.html#cache.name.memoryLimit[`cache.accounts.memoryLimit`]
-should be increased by the site administrator, if sufficient RAM
-is available to the host JVM.
-
-The estimate of 100 changes per day was WAG'd off some estimates
-originally obtained from Android's development history.  Writing a
-good change that will be accepted through a peer-review process
-takes time.  The average engineer may need 4-6 hours per change just
-to write the code and unit tests.  Proper design consideration and
-additional but equally important tasks such as meetings, interviews,
-training, and eating lunch will often pad the engineer's day out
-such that suitable changes are only posted once a day, or once
-every other day.  For reference, the entire Linux kernel has an
-average of only 79 changes/day. If more than 100 changes are active
-per day, site administrators should consider increasing the
-link:config-gerrit.html#cache.name.memoryLimit[`cache.diff.memoryLimit`]
-and `cache.diff_intraline.memoryLimit`.
-
-On average any given change will need to be modified once to address
-peer review comments before the final revision can be accepted by the
-project.  Executing these revisions also eats into the contributor's
-time, and is another factor limiting the number of changes/day
-accepted by the Gerrit instance.  However, even though this implies
-only 2 revisions/change, many existing Gerrit installations have seen
-20 or more revisions/change, when new contributors are learning the
-project's style and conventions.
-
-On average, each change will have 2 reviewers, a human and an
-automated test bed system.  Usually this would be the project lead, or
-someone who is familiar with the code being modified.  The time
-required to comment further reduces the time available for writing
-one's own changes.  However, existing Gerrit installations have seen 8
-or more reviewers frequently show up on changes that impact many
-functional areas, and therefore it is reasonable to expect 8 or more
-reviewers to be able to work together on a single change.
-
-Existing installations have successfully processed change reviews with
-more than 16,000 files per change. However, since 16,000 modified/new
-files is a massive amount of code to review, it is more typical to see
-less than 10 files modified in any single change. Changes larger than
-10 files are typically merges, for example integrating the latest
-version of an upstream library, where the reviewer has little to do
-beyond verifying the project compiles and passes a test suite.
-
-=== CPU Usage - Web UI
-
-Gerrit's web UI would require on average `4+F+F*C` HTTP requests to
-review a change and post comments.  Here `F` is the number of files
-modified by the change, and `C` is the number of inline/file comments
-left by the reviewer per file.  The constant 4 accounts for the request
-to load the reviewer's dashboard, to load the change detail page,
-to publish the review comments, and to reload the change detail
-page after comments are published.
-
-This WAG'd estimate boils down to 216,000 HTTP requests per day
-(QPD). Assuming these are evenly distributed over an 8 hour work day
-in a single time zone, we are looking at approximately 7.5 queries
-per second (QPS).
-
-----
-  QPD = Changes_Day * Revisions_Change * Reviewers_Change * (4 +  F +  F * C)
-      = 2,000       * 2                * 1                * (4 + 10 + 10 * 4)
-      = 216,000
-  QPS = QPD / 8_Hours / 60_Minutes / 60_Seconds
-      = 7.5
-----
-
-Gerrit serves most requests in under 60 ms when using the loopback
-interface and a single processor.  On a single CPU system there is
-sufficient capacity for 16 QPS.  A dual processor system should be
-more than sufficient for a site with the estimated load described above.
-
-Given a more realistic estimate of 79 changes per day (from the
-Linux kernel) suggests only 8,532 queries per day, and a much lower
-0.29 QPS when spread out over an 8 hour work day.
-
-=== CPU Usage - Git over SSH/HTTP
-
-A 24 core server is able to handle ~25 concurrent `git fetch`
-operations per second. The issue here is each concurrent operation
-demands one full core, as the computation is almost entirely server
-side CPU bound. 25 concurrent operations is known to be sufficient to
-support hundreds of active developers and 50 automated build servers
-polling for updates and building every change.  (This data was derived
-from an actual installation's performance.)
-
-Because of the distributed nature of Git, end-users don't need to
-contact the central Gerrit Code Review server very often. For `git
-fetch` traffic, link:pgm-daemon.html[replica mode] is known to be an
-effective way to offload traffic from the main server, permitting it
-to scale to a large user base without needing an excessive number of
-cores in a single system.
-
-Clients on very slow network connections (for example home office
-users on VPN over home DSL) may be network bound rather than server
-side CPU bound, in which case a core may be effectively shared with
-another user. Possible core sharing due to network bottlenecks
+Clients on slow network connections may be network bound rather than
+server side CPU bound, in which case a core may be effectively shared
+with another user. Possible core sharing due to network bottlenecks
 generally holds true for network connections running below 10 MiB/sec.
 
-If the server's own network interface is 1 Gib/sec (Gigabit Ethernet),
-the system can really only serve about 10 concurrent clients at the
-10 MiB/sec speed, no matter how many cores it has.
+Deployments for large, distributed companies can replicate Git data to
+read-only replicas to offload fetch traffic. The read-only replicas
+should also serve this data using Gerrit to ensure that permissions
+are obeyed.
 
-=== Disk Usage
+The API serves requests of varying costs. Requests that originate in
+the UI can block productivity, so care has been taken to optimize
+these for latency, using the following techniques:
 
-The average size of a revision in the Linux kernel once compressed by
-Git is 2,327 bytes, or roughly 2 KiB.  Over the course of a year a
-Gerrit server running with the estimated maximum parameters above might
-see an introduction of 1.4 GiB over the total set of 10,000 projects
-hosted in that server.  This figure assumes the majority of the content
-is human written source code, and not large binary blobs such as disk
-images or media files.
+* Async calls: the UI becomes responsive before some UI elements
+  finished loading
 
-Production Gerrit installations have been tested, and are known to
-handle Git repositories in the multigigabyte range, storing binary
-files, ranging in size from a few kilobytes (for example compressed
-icons) to 800+ megabytes (firmware images, large uncompressed original
-artwork files).  Best practices encourage breaking very large binary
-files into their Git repositories based on access, to prevent desktop
-clients from needing to clone unnecessary materials (for example a C
-developer does not need every 800+ megabyte firmware image created by
-the product's quality assurance team).
+* Caching: metadata is stored in Git, which is relatively expensive to
+  access. This is sped up by multiple caches. Metadata entities are
+  stored in Git, and can therefore be seen as immutable values keyed
+  by SHA1, which is very amenable to caching. All SHA1 keyed caches
+  can be persisted on local disk.
+
+  The size (memory, disk) of these caches should be adapted to the
+  instance size (number of users, size and quantity of repositories)
+  for optimal performance.
+
+Git does not impose fundamental limits (eg. number of files per
+change) on data. To ensure stability, Gerrit configures a number of
+default limits for these.
+
+// add a link to the default settings.
+
+=== Scaling team size
+
+A team of size N has N^2 possible interactions. As a result, features
+that expose interactions with activities of other team members has a
+quadratic cost in aggregate. The following features scale poorly with
+large team sizes:
+
+* the change screen shows conflicting changes by default. This data is
+  cached, but updates to pending changes cause cache misses. For a
+  single change, the amount of work is proportional to the number of
+  pending changes, so in aggregate, the cost of this feature is
+  quadratic in the team size.
+
+* the change screen shows if a change is mergeable to the target
+  branch. If the target branch moves quickly (large developer team),
+  this causes cache misses. In aggregate, the cost of this feature is
+  also quadratic.
+
+Both features should be turned off for repositories that involve 1000s
+of developers.
+
+=== Browser performance
+
+// say something about browser performance tuning.
+
+=== Real life numbers
+
+
+Gerrit is designed for very large projects, both open source and
+proprietary commercial projects. For a single Gerrit process, the
+following limits are known to work:
+
+.Observed maximums
+[options="header"]
+|======================================================
+|Parameter        |         Maximum | Deployment
+|Projects         |         50,000  | gerrithub.io
+|Contributors     |        150,000  | eclipse.org
+|Bytes/repo       |        100G     | Qualcomm internal
+|Changes/repo     |        300k     | Qualcomm internal
+|Revisions/Change |        300      | Qualcomm internal
+|Reviewers/Change |        87       | Qualcomm internal
+|======================================================
+
+
+// find some numbers for these stats:
+// |Files/repo       |        ? |
+// |Files/Change     |        ? |
+// |Comments/Change  |        ? |
+// |max QPS/CPU      |        ? |
+
+
+Google runs a horizontally scaled deployment. We have seen the
+following per-JVM maximums:
+
+.Observed maximums (googlesource.com)
+[options="header"]
+|======================================================
+|Parameter        |         Maximum | Deployment
+|Files/repo       |        500,000  | chromium-review
+|Bytes/repo       |         12G     | chromium-review
+|Changes/repo     |          500k   | chromium-review
+|Revisions/Change |          1900   | chromium-review
+|Files/Change     |           10,000| android-review
+|Comments/Change  |           1,200 | chromium-review
+|======================================================
+
 
 == Redundancy & Reliability
 
-Gerrit largely assumes that the local filesystem where Git repository
-data is stored is always available.  Important data written to disk
-is also forced to the platter with an `fsync()` once it has been
-fully written.  If the local filesystem fails to respond to reads
-or becomes corrupt, Gerrit has no provisions to fallback or retry
-and errors will be returned to clients.
+Gerrit is structured as a single JVM process, reading and writing to a
+single file system. If there are hardware failures in the machine
+running the JVM, or the storage holding the repositories, there is no
+recourse; on failure, errors will be returned to the client.
 
-Gerrit largely assumes that the metadata database is online and
-answering both read and write queries.  Query failures immediately
-result in the operation aborting and errors being returned to the
-client, with no retry or fallback provisions.
+Deployments needing more stringent uptime guarantees can use
+replication/multi-master setup, which ensures availability and
+geographical distribution, at the cost of slower write actions.
 
-Due to the relatively small scale described above, it is very likely
-that the Git filesystem and metadata database are all housed on the
-same server that is running Gerrit.  If any failure arises in one of
-these components, it is likely to manifest in the others too.  It is
-also likely that the administrator cannot be bothered to deploy a
-cluster of load-balanced server hardware, as the scale and expected
-load does not justify the hardware or management costs.
-
-Most deployments caring about reliability will setup a warm-spare
-standby system and use a manual fail-over process to switch from the
-failed system to the warm-spare.
-
-As Git is a distributed version control system, and open source
-projects tend to have contributors from all over the world, most
-contributors will be able to tolerate a Gerrit down time of several
-hours while the administrator is notified, signs on, and brings the
-warm-spare up.  Pending changes are likely to need at least 24 hours
-of time on the Gerrit site anyway in order to ensure any interested
-parties around the world have had a chance to comment.  This expected
-lag largely allows for some downtime in a disaster scenario.
+// TODO: link.
 
 === Backups
 
@@ -603,7 +503,8 @@
 
 == Logging Plan
 
-Gerrit does not maintain logs on its own.
+Gerrit stores Apache style HTTPD logs, as well as ERROR/INFO messages
+from the Java logger, under `$site_dir/logs/`.
 
 Published comments contain a publication date, so users can judge
 when the comment was posted and decide if it was "recent" or not.
diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt
index 159e2fc..0db6026 100644
--- a/Documentation/dev-plugins.txt
+++ b/Documentation/dev-plugins.txt
@@ -2546,14 +2546,13 @@
 Compiled plugins and extensions can be deployed to a running Gerrit
 server using the link:cmd-plugin-install.html[plugin install] command.
 
-Web UI plugins distributed as a single `.js` file (or `.html` file for
-Polygerrit) can be deployed without the overhead of JAR packaging. For
-more information refer to link:cmd-plugin-install.html[plugin install]
-command.
+Web UI plugins distributed as a single `.js` file can be deployed without the
+overhead of JAR packaging. For more information refer to
+link:cmd-plugin-install.html[plugin install] command.
 
 Plugins can also be copied directly into the server's directory at
-`$site_path/plugins/$name.(jar|js|html)`. For Web UI plugins, the name
-of the file, minus the `.js` or `.html` extension, will be used as the
+`$site_path/plugins/$name.(jar|js)`. For Web UI plugins, the name
+of the file, minus the `.js` extension, will be used as the
 plugin name. For JAR plugins, the value of the `Gerrit-PluginName`
 manifest attribute will be used, if provided, otherwise the name of
 the file, minus the `.jar` extension, will be used.
diff --git a/Documentation/error-commit-already-exists.txt b/Documentation/error-commit-already-exists.txt
index d2b7c9d..2832c78 100644
--- a/Documentation/error-commit-already-exists.txt
+++ b/Documentation/error-commit-already-exists.txt
@@ -1,6 +1,6 @@
 = commit already exists
 
-With "commit already exists (as current patchset)" or
+With "commit(s) already exists (as current patchset)" or
 "commit already exists (in the change)" error message
 Gerrit rejects to push a commit to an existing change via
 `refs/changes/n` if the commit was already successfully
diff --git a/Documentation/images/cross-repository-changes-add-topic.png b/Documentation/images/cross-repository-changes-add-topic.png
new file mode 100644
index 0000000..fc85b8f
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-add-topic.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-cp-menu.png b/Documentation/images/cross-repository-changes-cp-menu.png
new file mode 100644
index 0000000..e9004f8
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-cp-menu.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-cp-modal.png b/Documentation/images/cross-repository-changes-cp-modal.png
new file mode 100644
index 0000000..a4790fb
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-cp-modal.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-example.png b/Documentation/images/cross-repository-changes-example.png
new file mode 100644
index 0000000..e790f71
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-example.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-revert-topic-options.png b/Documentation/images/cross-repository-changes-revert-topic-options.png
new file mode 100644
index 0000000..f2e9f1a
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-revert-topic-options.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-revert-topic.png b/Documentation/images/cross-repository-changes-revert-topic.png
new file mode 100644
index 0000000..8d87191
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-revert-topic.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-submit-topic.png b/Documentation/images/cross-repository-changes-submit-topic.png
new file mode 100644
index 0000000..7e96743
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-submit-topic.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-submitted-together.png b/Documentation/images/cross-repository-changes-submitted-together.png
new file mode 100644
index 0000000..e7ea334
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-submitted-together.png
Binary files differ
diff --git a/Documentation/images/cross-repository-changes-topic.png b/Documentation/images/cross-repository-changes-topic.png
new file mode 100644
index 0000000..12d0e38
--- /dev/null
+++ b/Documentation/images/cross-repository-changes-topic.png
Binary files differ
diff --git a/Documentation/index.txt b/Documentation/index.txt
index 8f36ecc..164039b 100644
--- a/Documentation/index.txt
+++ b/Documentation/index.txt
@@ -38,6 +38,7 @@
 ... link:user-changeid.html[Change-Id Lines]
 ... link:user-signedoffby.html[Signed-off-by Lines]
 ... link:user-change-cleanup.html[Change Cleanup]
+... link:cross-repository-changes.html[Cross Repository Changes using Topics]
 
 == Project Management
 . link:project-configuration.html[Project Configuration]
@@ -78,6 +79,7 @@
 . link:note-db.html[NoteDb]
 . link:config-accounts.html[Accounts on NoteDb]
 . link:config-groups.html[Groups on NoteDb]
+. link:user-privacy.html[User data and privacy]
 
 == Concepts
 . link:config-labels.html[Review Labels]
diff --git a/Documentation/intro-user.txt b/Documentation/intro-user.txt
index eb2025c..0408d5d 100644
--- a/Documentation/intro-user.txt
+++ b/Documentation/intro-user.txt
@@ -514,6 +514,9 @@
   $ git push origin HEAD:refs/heads/master -o topic=multi-master
 ----
 
+For more information about using topics, see the user guide:
+link:cross-repository-changes.html[Submitting Changes Across Repositories by using Topics].
+
 [[hashtags]]
 == Using Hashtags
 
diff --git a/Documentation/project-configuration.txt b/Documentation/project-configuration.txt
index 23030a4..e583f45 100644
--- a/Documentation/project-configuration.txt
+++ b/Documentation/project-configuration.txt
@@ -108,6 +108,9 @@
 === Default Branch
 
 The default branch of a remote repository is defined by its `HEAD`.
+The default branch is selected from the initial branches of the newly created project,
+or set to link:config-gerrit.html#gerrit.defaultBranch[host-level default],
+if the project was created with empty branches.
 For convenience reasons, when the repository is cloned Git creates a
 local branch for this default branch and checks it out.
 
diff --git a/Documentation/rest-api-projects.txt b/Documentation/rest-api-projects.txt
index 49bc7e5..e30ce3a 100644
--- a/Documentation/rest-api-projects.txt
+++ b/Documentation/rest-api-projects.txt
@@ -4211,8 +4211,10 @@
 |`branches`                  |optional|
 A list of branches that should be initially created. +
 For the branch names the `refs/heads/` prefix can be omitted. +
-The first entry of the list will be the default branch (ie. the target
-of the `HEAD` symbolic ref). +
+The first entry of the list will be the
+link:project-configuration.html#default-branch[default branch]. +
+If the list is empty, link:config-gerrit.html#gerrit.defaultBranch[host-level default]
+is used. +
 Branches in the Gerrit internal ref space are not allowed, such as
 refs/groups/, refs/changes/, etc...
 |`owners`                    |optional|
diff --git a/Documentation/user-attention-set.txt b/Documentation/user-attention-set.txt
index 5e2906f..4697afc 100644
--- a/Documentation/user-attention-set.txt
+++ b/Documentation/user-attention-set.txt
@@ -48,6 +48,7 @@
 * For merged and abandoned changes the owner is added only when a human creates
   an unresolved comment.
 * Only owner, uploader, reviewers and ccs can be in the attention set.
+* The rules for service accounts are different, see link:#bots[Bots].
 
 *!IMPORTANT!* These rules are not meant to be super smart and to always do the
 right thing, e.g. if the change owner sends a reply, then they are often
@@ -85,7 +86,7 @@
 
 image::images/user-attention-set-reply-select.png["reply dialog section for selecting users", align="center"]
 
-=== Bots
+=== Bots [[bots]]
 
 The attention set is meant for human reviews only. Triggering bots and reacting
 to their results is a different workflow and not in scope of the attenion set.
diff --git a/Documentation/user-privacy.txt b/Documentation/user-privacy.txt
new file mode 100644
index 0000000..d61ee76
--- /dev/null
+++ b/Documentation/user-privacy.txt
@@ -0,0 +1,113 @@
+:linkattrs:
+= Gerrit Code Review - User Privacy
+
+== Purpose
+
+This page documents how Gerrit handles user data.
+
+|===
+| Note: Gerrit has extensive support for link:config-plugins.html[plugins]
+  which extend Gerrits functionality, and these plugins could access, export, or
+  maniuplate user data. This document only focuses on the behavior of Gerrit
+  core and its link:dev-core-plugins.html[core plugins].
+|===
+
+== Types of User Data
+
+Gerrit stores account data required for collaborating on source code changes.
+This data is described by
+link:config-accounts.html#account-data-in-user-branch[Account Data in User
+Branch] and includes link:config-accounts.html#external-ids[External IDs],
+link:config-accounts.html#preferences[User Preferences],
+link:config-accounts.html#project-watches[Project Watches] and personally
+identifiable information, including  name and email address. The email
+address is required to associate Git commits with a Gerrit user account. All
+data except passwords is made accessible to other users who you are visible to,
+as detailed below.
+
+== User Visibility
+
+Gerrit has a concept of link:config-gerrit.html#accounts[account visibility]
+which determines what users a given user can see. This visibility configuration
+applies in account search, reviewer suggestion, and when accessing data through
+the link:rest-api-accounts.html#account-endpoints[Account REST endpoints]. If
+you can see a user, you have read access to most of the
+link:rest-api-accounts.html#account-info[AccountInfo] for that user, including
+name and email address. Additional information, including secondary emails, is
+included in AccountInfo if the caller has “Modify Account” permissions.
+
+Additionally, all users on a change (author, cc’d, reviewer) can see each other,
+irrespective of the  account visibility settings. For example: Say you are a
+reviewer on a change where user Foo is also a reviewer. Even if by account
+visibility you could not search for Foo, you'd still see their avatar, name,
+and email now because you can see the change; this information is required to
+collaborate on a code review. If Foo wasn't on that change, you could not add
+them because reviewer suggestions would not find them due to the account
+visibility settings.
+
+By default, account visibility on a Gerrit instance is set to `ALL` which allows
+all users to be visible to other users, even anonymous (i.e. unauthenticated)
+users. Depending on your installation type, you may want to change this:
+
+* For completely company-internal Gerrit installations (no external users), the
+`ALL` default may make sense.
+
+* If you work with multiple vendors who have
+access to their own independent sets of repos, `VISIBLE_GROUP` may be more
+appropriate as you wouldn’t want vendor A to see accounts from vendor B.
+
+* For public installations, e.g. for open source projects, you may want to
+change this setting or add a notice for users when they create an account e.g.
+“Most of what you submit on this site, including your email address and name,
+will be visible to others who use this service. You may prefer to use an email
+account specifically for this purpose.” One way to do this is using
+link:config-gerrit.html[`auth.registerPageUrl`] in `gerrit.config`.
+
+== ACLs and User Visibility
+
+User suggestions for changes, when adding a reviewer or cc-ing someone, always
+respect ACLs for that change: only users who can see the change are suggested.
+The suggested users are an intersection of who you can see and who can see the
+change.
+
+Consider the following situation:
+
+* `READ` permission for Registered Users on the host
+* User visibility is set to `VISIBILE_GROUP`, so only users of the same domain can
+  see each other
+* a@foo.com creates change 123
+
+This would mean:
+
+* a@foo.com cannot add b@bar.com to the change because these users cannot see
+  each other due to the user visibility setting.
+* b@bar.com can find change 123
+  because they have READ permission and could add themselves to the change.
+* a@foo.com would then be able to see b@bar.com’s name, avatar, and email on
+  change 123
+
+The only caveat to the above are Private Changes, which are only visible to the
+owner and reviewers; reviewers can only see the change once they are added to
+the change (if ACLs allow them to be added in the first place), not before.
+
+## Right to be Forgotten Limitations
+
+As a source control system, Gerrit has limited abilities to remove personally
+identifiable information. Notably, Gerrit cannot:
+
+* Remove a user's e-mail from all existing commits
+* Remove a user's username
+
+There is also a known
+link:https://bugs.chromium.org/p/gerrit/issues/detail?id=14185[bug] where a
+user's username is stored in metadata for link:user-attention-set.html[Attention
+Set].
+
+
+## Open Source Software Limitations
+
+Gerrit is open-source software licensed under the Apache 2.0 license.  Unless
+required by applicable law or agreed to in writing, software distributed under
+the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, either express or implied. See the License for the specific
+language governing permissions and limitations under the License.
\ No newline at end of file
diff --git a/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/AbandonChange.json b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/AbandonChange.json
new file mode 100644
index 0000000..665cc4d
--- /dev/null
+++ b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/AbandonChange.json
@@ -0,0 +1,6 @@
+[
+  {
+    "url": "HTTP_SCHEME://HOSTNAME:HTTP_PORT/a/changes/",
+    "number": "NUMBER"
+  }
+]
diff --git a/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/RestoreChange.json b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/RestoreChange.json
new file mode 100644
index 0000000..665cc4d
--- /dev/null
+++ b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/RestoreChange.json
@@ -0,0 +1,6 @@
+[
+  {
+    "url": "HTTP_SCHEME://HOSTNAME:HTTP_PORT/a/changes/",
+    "number": "NUMBER"
+  }
+]
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/AbandonChange.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/AbandonChange.scala
new file mode 100644
index 0000000..d387a3e
--- /dev/null
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/AbandonChange.scala
@@ -0,0 +1,71 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.scenarios
+
+import io.gatling.core.Predef.{atOnceUsers, _}
+import io.gatling.core.feeder.FeederBuilder
+import io.gatling.core.structure.ScenarioBuilder
+import io.gatling.http.Predef.http
+
+import scala.collection.mutable
+import scala.concurrent.duration.DurationInt
+
+class AbandonChange extends GerritSimulation {
+  private val data: FeederBuilder = jsonFile(resource).convert(keys).circular
+  private val projectName = className
+  private var numbersCopy: mutable.Queue[Int] = mutable.Queue[Int]()
+  private var createChange: Option[CreateChange] = Some(new CreateChange(projectName))
+
+  override def relativeRuntimeWeight = 10
+
+  def this(createChange: CreateChange) {
+    this()
+    this.createChange = Some(createChange)
+  }
+
+  val test: ScenarioBuilder = scenario(uniqueName)
+      .feed(data)
+      .exec(session => {
+        if (createChange.nonEmpty) {
+          if (numbersCopy.isEmpty) {
+            numbersCopy = createChange.get.numbers.clone()
+          }
+        }
+        session.set(numberKey, numbersCopy.dequeue())
+      })
+      .exec(http(uniqueName).post("${url}${" + numberKey + "}/abandon"))
+
+  private val createProject = new CreateProject(projectName)
+  private val deleteProject = new DeleteProject(projectName)
+
+  setUp(
+    createProject.test.inject(
+      nothingFor(stepWaitTime(createProject) seconds),
+      atOnceUsers(single)
+    ),
+    createChange.get.test.inject(
+      nothingFor(stepWaitTime(createChange.get) seconds),
+      atOnceUsers(numberOfUsers)
+    ),
+    test.inject(
+      nothingFor(stepWaitTime(this) seconds),
+      atOnceUsers(numberOfUsers)
+    ),
+    deleteProject.test.inject(
+      nothingFor(stepWaitTime(deleteProject) seconds),
+      atOnceUsers(single)
+    ),
+  ).protocols(httpProtocol)
+}
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ApproveChange.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ApproveChange.scala
index 5e4f671..9a91153 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ApproveChange.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ApproveChange.scala
@@ -40,13 +40,13 @@
           if (numbersCopy.isEmpty) {
             numbersCopy = createChange.get.numbers.clone()
           }
-          session.set("number", numbersCopy.dequeue())
+          session.set(numberKey, numbersCopy.dequeue())
         } else {
           session
         }
       })
       .exec(http(uniqueName)
-          .post("${url}${number}/revisions/current/review")
+          .post("${url}${" + numberKey + "}/revisions/current/review")
           .body(ElFileBody(body)).asJson)
 
   setUp(
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CheckProjectsCacheFlushEntries.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CheckProjectsCacheFlushEntries.scala
index 96943ce..900702a 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CheckProjectsCacheFlushEntries.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CheckProjectsCacheFlushEntries.scala
@@ -37,7 +37,7 @@
         }
       })
       .exec(http(uniqueName).get("${url}")
-          .check(regex("\"" + memKey + "\": (\\d+)")
+          .check(regex("\"" + memKey + "\":(\\d+)")
               .is(session => session(entriesKey).as[String])))
 
   setUp(
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateChange.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateChange.scala
index b28edb5..fb41075 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateChange.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateChange.scala
@@ -24,7 +24,6 @@
 
 class CreateChange extends ProjectSimulation {
   private val data: FeederBuilder = jsonFile(resource).convert(keys).circular
-  private val numberKey = "_number"
   private val weightPerUser = 0.1
   private var createBranch: Option[CreateBranch] = None
   private var branchesCopy: mutable.Queue[String] = mutable.Queue[String]()
@@ -58,7 +57,7 @@
       })
       .exec(httpRequest
           .body(ElFileBody(body)).asJson
-          .check(regex("\"" + numberKey + "\":(\\d+),").saveAs(numberKey)))
+          .check(regex("\"_" + numberKey + "\":(\\d+),").saveAs(numberKey)))
       .exec(session => {
         number = session(numberKey).as[Int]
         numbers += number
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteChange.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteChange.scala
index e47108f..743219f 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteChange.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteChange.scala
@@ -34,12 +34,12 @@
       .feed(data)
       .exec(session => {
         if (createChange.nonEmpty) {
-          session.set("number", createChange.get.numbers.dequeue())
+          session.set(numberKey, createChange.get.numbers.dequeue())
         } else {
           session
         }
       })
-      .exec(http(uniqueName).delete("${url}${number}"))
+      .exec(http(uniqueName).delete("${url}${" + numberKey + "}"))
 
   setUp(
     test.inject(
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala
index b11c87c..c199dd9 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala
@@ -23,6 +23,8 @@
 class GerritSimulation extends Simulation {
   implicit val conf: GatlingGitConfiguration = GatlingGitConfiguration()
 
+  protected val numberKey: String = "number"
+
   private val packageName = getClass.getPackage.getName
   private val path = packageName.replaceAllLiterally(".", "/")
 
@@ -64,9 +66,9 @@
   protected val keys: PartialFunction[(String, Any), Any] = {
     case ("entries", entries) =>
       replaceProperty("projects_entries", "1", entries.toString)
-    case ("number", number) =>
-      val precedes = replaceKeyWith("_number", 0, number.toString)
-      replaceProperty("number", 1, precedes)
+    case (`numberKey`, number) =>
+      val precedes = replaceKeyWith("_" + numberKey, 0, number.toString)
+      replaceProperty(numberKey, 1, precedes)
     case ("parent", parent) =>
       replaceProperty("parent", "All-Projects", parent.toString)
     case ("project", project) =>
@@ -90,6 +92,11 @@
   }
 
   protected def replaceProperty(term: String, default: Any, in: String): String = {
+    val value = getProperty(term, default)
+    replaceKeyWith(term, value, in)
+  }
+
+  protected def getProperty(term: String, default: Any): String = {
     val property = packageName + "." + term
     var value = default
     default match {
@@ -101,7 +108,7 @@
       case _: Integer =>
         value = Integer.getInteger(property, default.asInstanceOf[Integer])
     }
-    replaceKeyWith(term, value, in)
+    value.toString
   }
 
   protected def replaceKeyWith(term: String, value: Any, in: String): String = {
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetMasterBranchRevision.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetMasterBranchRevision.scala
index 1137ad5..f2236d1 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetMasterBranchRevision.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetMasterBranchRevision.scala
@@ -23,7 +23,7 @@
   private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
   var revision: Option[String] = None
   val revisionKey = "revision"
-  val revisionPattern: String = "\"" + revisionKey + "\": \"(.+)\""
+  val revisionPattern: String = "\"" + revisionKey + "\":\"(.+)\""
 
   val test: ScenarioBuilder = scenario(uniqueName)
       .feed(data)
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetProjectsCacheEntries.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetProjectsCacheEntries.scala
index 266c0b9..0bb3afb 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetProjectsCacheEntries.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GetProjectsCacheEntries.scala
@@ -30,7 +30,7 @@
   val test: ScenarioBuilder = scenario(uniqueName)
       .feed(data)
       .exec(http(uniqueName).get("${url}")
-          .check(regex("\"" + memKey + "\": (\\d+)").saveAs(entriesKey)))
+          .check(regex("\"" + memKey + "\":(\\d+)").saveAs(entriesKey)))
       .exec(session => {
         if (consumer.nonEmpty) {
           consumer.get.entriesBeforeFlush(session(entriesKey).as[Int])
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/RestoreChange.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/RestoreChange.scala
new file mode 100644
index 0000000..81096b0
--- /dev/null
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/RestoreChange.scala
@@ -0,0 +1,74 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.scenarios
+
+import io.gatling.core.Predef.{atOnceUsers, _}
+import io.gatling.core.feeder.FeederBuilder
+import io.gatling.core.structure.ScenarioBuilder
+import io.gatling.http.Predef.http
+
+import scala.collection.mutable
+import scala.concurrent.duration.DurationInt
+
+class RestoreChange extends GerritSimulation {
+  private val data: FeederBuilder = jsonFile(resource).convert(keys).circular
+  private val projectName = className
+  private var numbersCopy: mutable.Queue[Int] = mutable.Queue[Int]()
+
+  override def relativeRuntimeWeight = 10
+
+  private val test: ScenarioBuilder = scenario(uniqueName)
+      .feed(data)
+      .exec(session => {
+        if (numbersCopy.isEmpty) {
+          numbersCopy = createChange.numbers.clone()
+        }
+        session.set(numberKey, numbersCopy.dequeue())
+      }
+      ).exec(http(uniqueName).post("${url}${" + numberKey + "}/restore"))
+
+  private val createProject = new CreateProject(projectName)
+  private val createChange = new CreateChange(projectName)
+  private val abandonChange = new AbandonChange(createChange)
+  private val deleteChange = new DeleteChange(createChange)
+  private val deleteProject = new DeleteProject(projectName)
+
+  setUp(
+    createProject.test.inject(
+      nothingFor(stepWaitTime(createProject) seconds),
+      atOnceUsers(single)
+    ),
+    createChange.test.inject(
+      nothingFor(stepWaitTime(createChange) seconds),
+      atOnceUsers(numberOfUsers)
+    ),
+    abandonChange.test.inject(
+      nothingFor(stepWaitTime(abandonChange) seconds),
+      atOnceUsers(numberOfUsers)
+    ),
+    test.inject(
+      nothingFor(stepWaitTime(this) seconds),
+      atOnceUsers(numberOfUsers)
+    ),
+    deleteChange.test.inject(
+      nothingFor(stepWaitTime(deleteChange) seconds),
+      atOnceUsers(numberOfUsers)
+    ),
+    deleteProject.test.inject(
+      nothingFor(stepWaitTime(deleteProject) seconds),
+      atOnceUsers(single)
+    ),
+  ).protocols(httpProtocol)
+}
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChange.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChange.scala
index 067496a..20be28a 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChange.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChange.scala
@@ -36,9 +36,9 @@
   val test: ScenarioBuilder = scenario(uniqueName)
       .feed(data)
       .exec(session => {
-        session.set("number", createChange.number)
+        session.set(numberKey, createChange.number)
       })
-      .exec(http(uniqueName).post("${url}${number}/submit"))
+      .exec(http(uniqueName).post("${url}${" + numberKey + "}/submit"))
 
   private val createProject = new CreateProject(projectName)
   private val approveChange = new ApproveChange(createChange)
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChangeInBranch.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChangeInBranch.scala
index 1b88503..9e1431b 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChangeInBranch.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/SubmitChangeInBranch.scala
@@ -35,9 +35,9 @@
         if (changesCopy.isEmpty) {
           changesCopy = createChange.numbers.clone()
         }
-        session.set("number", changesCopy.dequeue())
+        session.set(numberKey, changesCopy.dequeue())
       })
-      .exec(http(uniqueName).post("${url}${number}/submit"))
+      .exec(http(uniqueName).post("${url}${" + numberKey + "}/submit"))
 
   private val createProject = new CreateProject(projectName)
   private val createBranch = new CreateBranch(projectName)
diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
index 5b27088..aa0c938 100644
--- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
+++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
@@ -74,6 +74,7 @@
 import com.google.gerrit.extensions.api.changes.RevisionApi;
 import com.google.gerrit.extensions.api.changes.SubmittedTogetherInfo;
 import com.google.gerrit.extensions.api.projects.BranchApi;
+import com.google.gerrit.extensions.api.projects.BranchInfo;
 import com.google.gerrit.extensions.api.projects.BranchInput;
 import com.google.gerrit.extensions.api.projects.ProjectInput;
 import com.google.gerrit.extensions.client.InheritableBoolean;
@@ -174,6 +175,7 @@
 import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
 import org.eclipse.jgit.junit.TestRepository;
 import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.NullProgressMonitor;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.PersonIdent;
@@ -583,6 +585,7 @@
     ProjectInput in = new ProjectInput();
     TestProjectInput ann = description.getAnnotation(TestProjectInput.class);
     in.name = name("project");
+    in.branches = ImmutableList.of(Constants.R_HEADS + Constants.MASTER);
     if (ann != null) {
       in.parent = Strings.emptyToNull(ann.parent());
       in.description = Strings.emptyToNull(ann.description());
@@ -1349,6 +1352,16 @@
     assertThat(rule.getMax()).isEqualTo(expectedMax);
   }
 
+  protected void assertHead(String projectName, String expectedRef) throws Exception {
+    // Assert gerrit's project head points to the correct branch
+    assertThat(getProjectBranches(projectName).get(Constants.HEAD).revision)
+        .isEqualTo(RefNames.shortName(expectedRef));
+    // Assert git head points to the correct branch
+    try (Repository repo = repoManager.openRepository(Project.nameKey(projectName))) {
+      assertThat(repo.exactRef(Constants.HEAD).getTarget().getName()).isEqualTo(expectedRef);
+    }
+  }
+
   protected InternalGroup group(AccountGroup.UUID groupUuid) {
     InternalGroup group = groupCache.get(groupUuid).orElse(null);
     assertWithMessage(groupUuid.get()).that(group).isNotNull();
@@ -1622,6 +1635,12 @@
     return comments;
   }
 
+  protected ImmutableMap<String, BranchInfo> getProjectBranches(String projectName)
+      throws RestApiException {
+    return gApi.projects().name(projectName).branches().get().stream()
+        .collect(ImmutableMap.toImmutableMap(branch -> branch.ref, branch -> branch));
+  }
+
   protected AutoCloseable installPlugin(String pluginName, Class<? extends Module> sysModuleClass)
       throws Exception {
     return installPlugin(pluginName, sysModuleClass, null, null);
diff --git a/java/com/google/gerrit/acceptance/ExtensionRegistry.java b/java/com/google/gerrit/acceptance/ExtensionRegistry.java
index 5d01dcb..35f8ce6 100644
--- a/java/com/google/gerrit/acceptance/ExtensionRegistry.java
+++ b/java/com/google/gerrit/acceptance/ExtensionRegistry.java
@@ -39,6 +39,7 @@
 import com.google.gerrit.server.change.ChangeETagComputation;
 import com.google.gerrit.server.config.ProjectConfigEntry;
 import com.google.gerrit.server.git.ChangeMessageModifier;
+import com.google.gerrit.server.git.receive.PluginPushOption;
 import com.google.gerrit.server.git.validators.CommitValidationListener;
 import com.google.gerrit.server.git.validators.OnSubmitValidationListener;
 import com.google.gerrit.server.git.validators.RefOperationValidationListener;
@@ -84,6 +85,7 @@
   private final DynamicMap<CapabilityDefinition> capabilityDefinitions;
   private final DynamicMap<PluginProjectPermissionDefinition> pluginProjectPermissionDefinitions;
   private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
+  private final DynamicSet<PluginPushOption> pluginPushOptions;
   private final DynamicSet<OnPostReview> onPostReviews;
 
   @Inject
@@ -116,6 +118,7 @@
       DynamicMap<CapabilityDefinition> capabilityDefinitions,
       DynamicMap<PluginProjectPermissionDefinition> pluginProjectPermissionDefinitions,
       DynamicMap<ProjectConfigEntry> pluginConfigEntries,
+      DynamicSet<PluginPushOption> pluginPushOption,
       DynamicSet<OnPostReview> onPostReviews) {
     this.accountIndexedListeners = accountIndexedListeners;
     this.changeIndexedListeners = changeIndexedListeners;
@@ -145,6 +148,7 @@
     this.capabilityDefinitions = capabilityDefinitions;
     this.pluginProjectPermissionDefinitions = pluginProjectPermissionDefinitions;
     this.pluginConfigEntries = pluginConfigEntries;
+    this.pluginPushOptions = pluginPushOption;
     this.onPostReviews = onPostReviews;
   }
 
@@ -274,6 +278,10 @@
       return add(pluginConfigEntries, pluginConfigEntry, exportName);
     }
 
+    public Registration add(PluginPushOption pluginPushOption) {
+      return add(pluginPushOptions, pluginPushOption);
+    }
+
     public Registration add(OnPostReview onPostReview) {
       return add(onPostReviews, onPostReview);
     }
diff --git a/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImpl.java b/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImpl.java
index f6e5de3..e7354ab 100644
--- a/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImpl.java
+++ b/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImpl.java
@@ -138,6 +138,9 @@
         throws IOException, ConfigInvalidException {
       try (MetaDataUpdate metaDataUpdate = metaDataUpdateFactory.create(nameKey)) {
         ProjectConfig projectConfig = projectConfigFactory.read(metaDataUpdate);
+        if (projectUpdate.removeAllAccessSections()) {
+          projectConfig.getAccessSections().forEach(as -> projectConfig.remove(as));
+        }
         removePermissions(projectConfig, projectUpdate.removedPermissions());
         addCapabilities(projectConfig, projectUpdate.addedCapabilities());
         addPermissions(projectConfig, projectUpdate.addedPermissions());
diff --git a/java/com/google/gerrit/acceptance/testsuite/project/TestProjectUpdate.java b/java/com/google/gerrit/acceptance/testsuite/project/TestProjectUpdate.java
index ea20931..9a9a21a 100644
--- a/java/com/google/gerrit/acceptance/testsuite/project/TestProjectUpdate.java
+++ b/java/com/google/gerrit/acceptance/testsuite/project/TestProjectUpdate.java
@@ -294,7 +294,8 @@
     return new AutoValue_TestProjectUpdate.Builder()
         .nameKey(nameKey)
         .allProjectsName(allProjectsName)
-        .projectUpdater(projectUpdater);
+        .projectUpdater(projectUpdater)
+        .removeAllAccessSections(false);
   }
 
   /** Builder for {@link TestProjectUpdate}. */
@@ -314,6 +315,16 @@
 
     abstract ImmutableMap.Builder<TestPermissionKey, Boolean> exclusiveGroupPermissionsBuilder();
 
+    abstract Builder removeAllAccessSections(boolean value);
+
+    /**
+     * Removes all access sections. Useful when testing against a specific set of access sections or
+     * permissions.
+     */
+    public Builder removeAllAccessSections() {
+      return removeAllAccessSections(true);
+    }
+
     /** Adds a permission to be included in this update. */
     public Builder add(TestPermission testPermission) {
       addedPermissionsBuilder().add(testPermission);
@@ -418,6 +429,8 @@
 
   abstract ThrowingConsumer<TestProjectUpdate> projectUpdater();
 
+  abstract boolean removeAllAccessSections();
+
   boolean hasCapabilityUpdates() {
     return !addedCapabilities().isEmpty()
         || removedPermissions().stream().anyMatch(k -> k.section().equals(GLOBAL_CAPABILITIES));
diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
index 6f3d5c6..9b86a4f 100644
--- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
+++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -1581,9 +1581,11 @@
 
     // Check if we want to delegate to a child collection. Child collections are bound with
     // GET.name so we have to check for this since we haven't found any other views.
-    core = views.get(PluginName.GERRIT, "GET." + p.get(0));
-    if (core != null) {
-      return new ViewData(PluginName.GERRIT, core);
+    if (method.equals("GET")) {
+      core = views.get(PluginName.GERRIT, "GET." + p.get(0));
+      if (core != null) {
+        return new ViewData(PluginName.GERRIT, core);
+      }
     }
 
     Map<String, RestView<RestResource>> r = new TreeMap<>();
diff --git a/java/com/google/gerrit/pgm/Reindex.java b/java/com/google/gerrit/pgm/Reindex.java
index c8d69f1c..3935268 100644
--- a/java/com/google/gerrit/pgm/Reindex.java
+++ b/java/com/google/gerrit/pgm/Reindex.java
@@ -29,10 +29,6 @@
 import com.google.gerrit.lucene.LuceneIndexModule;
 import com.google.gerrit.pgm.util.BatchProgramModule;
 import com.google.gerrit.pgm.util.SiteProgram;
-import com.google.gerrit.server.LibModuleLoader;
-import com.google.gerrit.server.LibModuleType;
-import com.google.gerrit.server.ModuleOverloader;
-import com.google.gerrit.server.cache.h2.H2CacheModule;
 import com.google.gerrit.server.change.ChangeResource;
 import com.google.gerrit.server.config.GerritServerConfig;
 import com.google.gerrit.server.index.IndexModule;
@@ -162,8 +158,7 @@
       throw new IllegalStateException("unsupported index.type = " + indexType);
     }
     modules.add(indexModule);
-    modules.add(new BatchProgramModule());
-    modules.add(new H2CacheModule());
+    modules.add(new BatchProgramModule(dbInjector));
     modules.add(
         new FactoryModule() {
           @Override
@@ -172,9 +167,7 @@
           }
         });
 
-    return dbInjector.createChildInjector(
-        ModuleOverloader.override(
-            modules, LibModuleLoader.loadModules(dbInjector, LibModuleType.SYS_MODULE)));
+    return dbInjector.createChildInjector(modules);
   }
 
   private void overrideConfig() {
diff --git a/java/com/google/gerrit/pgm/util/BUILD b/java/com/google/gerrit/pgm/util/BUILD
index cfdd383..f7c2b75 100644
--- a/java/com/google/gerrit/pgm/util/BUILD
+++ b/java/com/google/gerrit/pgm/util/BUILD
@@ -12,6 +12,7 @@
         "//java/com/google/gerrit/metrics",
         "//java/com/google/gerrit/metrics/dropwizard",
         "//java/com/google/gerrit/server",
+        "//java/com/google/gerrit/server/cache/h2",
         "//java/com/google/gerrit/server/cache/mem",
         "//java/com/google/gerrit/server/restapi",
         "//java/com/google/gerrit/server/schema",
diff --git a/java/com/google/gerrit/pgm/util/BatchProgramModule.java b/java/com/google/gerrit/pgm/util/BatchProgramModule.java
index 894757b..6c4454f 100644
--- a/java/com/google/gerrit/pgm/util/BatchProgramModule.java
+++ b/java/com/google/gerrit/pgm/util/BatchProgramModule.java
@@ -28,6 +28,9 @@
 import com.google.gerrit.extensions.restapi.RestView;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.IdentifiedUser;
+import com.google.gerrit.server.LibModuleLoader;
+import com.google.gerrit.server.LibModuleType;
+import com.google.gerrit.server.ModuleOverloader;
 import com.google.gerrit.server.account.AccountCacheImpl;
 import com.google.gerrit.server.account.AccountVisibilityProvider;
 import com.google.gerrit.server.account.CapabilityCollection;
@@ -38,6 +41,7 @@
 import com.google.gerrit.server.account.ServiceUserClassifierImpl;
 import com.google.gerrit.server.account.externalids.ExternalIdModule;
 import com.google.gerrit.server.cache.CacheRemovalListener;
+import com.google.gerrit.server.cache.h2.H2CacheModule;
 import com.google.gerrit.server.cache.mem.DefaultMemoryCacheModule;
 import com.google.gerrit.server.change.ChangeJson;
 import com.google.gerrit.server.change.ChangeKindCacheImpl;
@@ -82,22 +86,33 @@
 import com.google.gerrit.server.rules.PrologModule;
 import com.google.gerrit.server.rules.SubmitRule;
 import com.google.gerrit.server.update.BatchUpdate;
+import com.google.inject.Injector;
+import com.google.inject.Module;
 import com.google.inject.TypeLiteral;
 import com.google.inject.util.Providers;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
 /** Module for programs that perform batch operations on a site. */
 public class BatchProgramModule extends FactoryModule {
+  private Injector parentInjector;
+
+  public BatchProgramModule(Injector parentInjector) {
+    this.parentInjector = parentInjector;
+  }
+
   @SuppressWarnings("rawtypes")
   @Override
   protected void configure() {
-    install(new DiffExecutorModule());
-    install(new SysExecutorModule());
-    install(BatchUpdate.module());
-    install(PatchListCacheImpl.module());
-    install(new DefaultUrlFormatter.Module());
+    List<Module> modules = new ArrayList<>();
+
+    modules.add(new DiffExecutorModule());
+    modules.add(new SysExecutorModule());
+    modules.add(BatchUpdate.module());
+    modules.add(PatchListCacheImpl.module());
+    modules.add(new DefaultUrlFormatter.Module());
 
     // There is the concept of LifecycleModule, in Gerrit's own extension to Guice, which has these:
     //  listener().to(SomeClassImplementingLifecycleListener.class);
@@ -106,7 +121,7 @@
     // plugins get loaded and the respective Guice modules installed so that the on-line reindexing
     // will happen with the proper classes (e.g. group backends, custom Prolog predicates) and the
     // associated rules ready to be evaluated.
-    install(new PluginModule());
+    modules.add(new PluginModule());
 
     // We're just running through each change
     // once, so don't worry about cache removal.
@@ -146,24 +161,24 @@
         .annotatedWith(GitReceivePackGroups.class)
         .toInstance(Collections.emptySet());
 
-    install(new BatchGitModule());
-    install(new DefaultPermissionBackendModule());
-    install(new DefaultMemoryCacheModule());
-
-    install(new ExternalIdModule());
-    install(new GroupModule());
-    install(new NoteDbModule());
-    install(AccountCacheImpl.module());
-    install(DefaultPreferencesCacheImpl.module());
-    install(GroupCacheImpl.module());
-    install(GroupIncludeCacheImpl.module());
-    install(ProjectCacheImpl.module());
-    install(SectionSortCache.module());
-    install(ChangeKindCacheImpl.module());
-    install(MergeabilityCacheImpl.module());
-    install(ServiceUserClassifierImpl.module());
-    install(TagCache.module());
-    install(PureRevertCache.module());
+    modules.add(new BatchGitModule());
+    modules.add(new DefaultPermissionBackendModule());
+    modules.add(new DefaultMemoryCacheModule());
+    modules.add(new H2CacheModule());
+    modules.add(new ExternalIdModule());
+    modules.add(new GroupModule());
+    modules.add(new NoteDbModule());
+    modules.add(AccountCacheImpl.module());
+    modules.add(DefaultPreferencesCacheImpl.module());
+    modules.add(GroupCacheImpl.module());
+    modules.add(GroupIncludeCacheImpl.module());
+    modules.add(ProjectCacheImpl.module());
+    modules.add(SectionSortCache.module());
+    modules.add(ChangeKindCacheImpl.module());
+    modules.add(MergeabilityCacheImpl.module());
+    modules.add(ServiceUserClassifierImpl.module());
+    modules.add(TagCache.module());
+    modules.add(PureRevertCache.module());
     factory(CapabilityCollection.Factory.class);
     factory(ChangeData.AssistedFactory.class);
     factory(ChangeIsVisibleToPredicate.Factory.class);
@@ -172,9 +187,9 @@
     // Submit rules
     DynamicSet.setOf(binder(), SubmitRule.class);
     factory(SubmitRuleEvaluator.Factory.class);
-    install(new PrologModule());
-    install(new DefaultSubmitRule.Module());
-    install(new IgnoreSelfApprovalRule.Module());
+    modules.add(new PrologModule());
+    modules.add(new DefaultSubmitRule.Module());
+    modules.add(new IgnoreSelfApprovalRule.Module());
 
     bind(ChangeJson.Factory.class).toProvider(Providers.of(null));
     bind(EventUtil.class).toProvider(Providers.of(null));
@@ -182,5 +197,10 @@
     bind(RevisionCreated.class).toInstance(RevisionCreated.DISABLED);
     bind(WorkInProgressStateChanged.class).toInstance(WorkInProgressStateChanged.DISABLED);
     bind(AccountVisibility.class).toProvider(AccountVisibilityProvider.class).in(SINGLETON);
+
+    ModuleOverloader.override(
+            modules, LibModuleLoader.loadModules(parentInjector, LibModuleType.SYS_BATCH_MODULE))
+        .stream()
+        .forEach(this::install);
   }
 }
diff --git a/java/com/google/gerrit/server/LibModuleType.java b/java/com/google/gerrit/server/LibModuleType.java
index 557f8c0..b9cb196 100644
--- a/java/com/google/gerrit/server/LibModuleType.java
+++ b/java/com/google/gerrit/server/LibModuleType.java
@@ -20,6 +20,9 @@
   /** Module for the sysInjector. */
   SYS_MODULE("Module"),
 
+  /** BatchModule for the sysInjector */
+  SYS_BATCH_MODULE("BatchModule"),
+
   /** Module for the dbInjector. */
   DB_MODULE("DbModule");
 
diff --git a/java/com/google/gerrit/server/change/ChangeInserter.java b/java/com/google/gerrit/server/change/ChangeInserter.java
index 6091091..2b49a06 100644
--- a/java/com/google/gerrit/server/change/ChangeInserter.java
+++ b/java/com/google/gerrit/server/change/ChangeInserter.java
@@ -25,6 +25,7 @@
 
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Streams;
 import com.google.common.flogger.FluentLogger;
@@ -546,6 +547,7 @@
               cmd,
               projectState.getProject(),
               change.getDest().branch(),
+              ImmutableListMultimap.of(),
               ctx.getRepoView().getConfig(),
               ctx.getRevWalk().getObjectReader(),
               commitId,
diff --git a/java/com/google/gerrit/server/change/FileInfoJsonComparingImpl.java b/java/com/google/gerrit/server/change/FileInfoJsonComparingImpl.java
new file mode 100644
index 0000000..40ad0b1
--- /dev/null
+++ b/java/com/google/gerrit/server/change/FileInfoJsonComparingImpl.java
@@ -0,0 +1,158 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.change;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.PatchSet;
+import com.google.gerrit.entities.Project;
+import com.google.gerrit.extensions.common.FileInfo;
+import com.google.gerrit.extensions.restapi.ResourceConflictException;
+import com.google.gerrit.metrics.Counter1;
+import com.google.gerrit.metrics.Description;
+import com.google.gerrit.metrics.Field;
+import com.google.gerrit.metrics.MetricMaker;
+import com.google.gerrit.server.logging.Metadata;
+import com.google.gerrit.server.patch.DiffExecutor;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import org.eclipse.jgit.lib.ObjectId;
+
+/**
+ * Implementation of FileInfoJson which uses {@link FileInfoJsonOldImpl}, but also runs {@link
+ * FileInfoJsonNewImpl} asynchronously and compares the results. This implementation is temporary
+ * and will be used to verify that the results are the same.
+ */
+public class FileInfoJsonComparingImpl implements FileInfoJson {
+  private static final FluentLogger logger = FluentLogger.forEnclosingClass();
+
+  private final FileInfoJsonOldImpl oldImpl;
+  private final FileInfoJsonNewImpl newImpl;
+  private final ExecutorService executor;
+  private final Metrics metrics;
+
+  /**
+   * TODO(ghareeb): These metrics are temporary for launching the new diff cache redesign and are
+   * not documented. These will be removed soon.
+   */
+  @VisibleForTesting
+  @Singleton
+  static class Metrics {
+    private enum Status {
+      MATCH,
+      MISMATCH,
+      ERROR
+    }
+
+    final Counter1<Status> diffs;
+
+    @Inject
+    Metrics(MetricMaker metricMaker) {
+      diffs =
+          metricMaker.newCounter(
+              "diff/list_files/dark_launch",
+              new Description(
+                      "Total number of matching, non-matching, or error in list-files diffs in the old and new diff cache implementations.")
+                  .setRate()
+                  .setUnit("count"),
+              Field.ofEnum(Status.class, "type", Metadata.Builder::eventType).build());
+    }
+  }
+
+  @Inject
+  public FileInfoJsonComparingImpl(
+      FileInfoJsonOldImpl oldImpl,
+      FileInfoJsonNewImpl newImpl,
+      @DiffExecutor ExecutorService executor,
+      Metrics metrics) {
+    this.oldImpl = oldImpl;
+    this.newImpl = newImpl;
+    this.executor = executor;
+    this.metrics = metrics;
+  }
+
+  @Override
+  public Map<String, FileInfo> getFileInfoMap(Change change, ObjectId objectId, PatchSet base)
+      throws ResourceConflictException, PatchListNotAvailableException {
+    Map<String, FileInfo> result = oldImpl.getFileInfoMap(change, objectId, base);
+    @SuppressWarnings("unused")
+    Future<?> ignored =
+        executor.submit(
+            () -> {
+              try {
+                Map<String, FileInfo> fileInfoNew = newImpl.getFileInfoMap(change, objectId, base);
+                compareAndLogMetrics(
+                    result,
+                    fileInfoNew,
+                    String.format(
+                        "Mismatch comparing old and new diff implementations for change: %s, objectId: %s and base: %s",
+                        change, objectId, base.id()));
+              } catch (ResourceConflictException | PatchListNotAvailableException e) {
+                // If an exception happens while evaluating the new diff, increment the non-matching
+                // counter
+                metrics.diffs.increment(Metrics.Status.ERROR);
+                logger.atWarning().withCause(e).log(
+                    "Error comparing old and new diff implementations.");
+              }
+            });
+    return result;
+  }
+
+  @Override
+  public Map<String, FileInfo> getFileInfoMap(
+      Project.NameKey project, ObjectId objectId, int parentNum)
+      throws ResourceConflictException, PatchListNotAvailableException {
+    Map<String, FileInfo> result = oldImpl.getFileInfoMap(project, objectId, parentNum);
+    @SuppressWarnings("unused")
+    Future<?> ignored =
+        executor.submit(
+            () -> {
+              try {
+                Map<String, FileInfo> resultNew =
+                    newImpl.getFileInfoMap(project, objectId, parentNum);
+                compareAndLogMetrics(
+                    result,
+                    resultNew,
+                    String.format(
+                        "Mismatch comparing old and new diff implementations for project: %s, objectId: %s and parentNum: %d",
+                        project, objectId, parentNum));
+              } catch (ResourceConflictException | PatchListNotAvailableException e) {
+                // If an exception happens while evaluating the new diff, increment the non-matching
+                // ctr
+                metrics.diffs.increment(Metrics.Status.ERROR);
+                logger.atWarning().withCause(e).log(
+                    "Error comparing old and new diff implementations.");
+              }
+            });
+    return result;
+  }
+
+  private void compareAndLogMetrics(
+      Map<String, FileInfo> fileInfoMapOld,
+      Map<String, FileInfo> fileInfoMapNew,
+      String warningMessage) {
+    if (fileInfoMapOld.equals(fileInfoMapNew)) {
+      metrics.diffs.increment(Metrics.Status.MATCH);
+      return;
+    }
+    metrics.diffs.increment(Metrics.Status.MISMATCH);
+    logger.atWarning().log(warningMessage);
+  }
+}
diff --git a/java/com/google/gerrit/server/change/FileInfoJsonModule.java b/java/com/google/gerrit/server/change/FileInfoJsonModule.java
index f1c2e80..11d60d1 100644
--- a/java/com/google/gerrit/server/change/FileInfoJsonModule.java
+++ b/java/com/google/gerrit/server/change/FileInfoJsonModule.java
@@ -21,12 +21,21 @@
 public class FileInfoJsonModule extends AbstractModule {
   private final boolean useNewDiffCache;
 
+  /** Used to dark launch the new diff cache with the list files endpoint. */
+  private final boolean runNewDiffCacheAsync;
+
   public FileInfoJsonModule(@GerritServerConfig Config cfg) {
     this.useNewDiffCache = cfg.getBoolean("cache", "diff_cache", "useNewDiffCache", false);
+    this.runNewDiffCacheAsync =
+        cfg.getBoolean("cache", "diff_cache", "runNewDiffCacheAsync_listFiles", false);
   }
 
   @Override
   public void configure() {
+    if (runNewDiffCacheAsync) {
+      bind(FileInfoJson.class).to(FileInfoJsonComparingImpl.class);
+      return;
+    }
     bind(FileInfoJson.class)
         .to(useNewDiffCache ? FileInfoJsonNewImpl.class : FileInfoJsonOldImpl.class);
   }
diff --git a/java/com/google/gerrit/server/change/PatchSetInserter.java b/java/com/google/gerrit/server/change/PatchSetInserter.java
index ef06ea1..4c1e9fb 100644
--- a/java/com/google/gerrit/server/change/PatchSetInserter.java
+++ b/java/com/google/gerrit/server/change/PatchSetInserter.java
@@ -20,6 +20,7 @@
 import static com.google.gerrit.server.project.ProjectCache.illegalState;
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.collect.ImmutableListMultimap;
 import com.google.common.flogger.FluentLogger;
 import com.google.gerrit.entities.Change;
 import com.google.gerrit.entities.ChangeMessage;
@@ -342,6 +343,7 @@
                 .orElseThrow(illegalState(origNotes.getProjectName()))
                 .getProject(),
             origNotes.getChange().getDest().branch(),
+            ImmutableListMultimap.of(),
             ctx.getRepoView().getConfig(),
             ctx.getRevWalk().getObjectReader(),
             commitId,
diff --git a/java/com/google/gerrit/server/config/GerritGlobalModule.java b/java/com/google/gerrit/server/config/GerritGlobalModule.java
index 52de9d5..3da3fd3 100644
--- a/java/com/google/gerrit/server/config/GerritGlobalModule.java
+++ b/java/com/google/gerrit/server/config/GerritGlobalModule.java
@@ -130,6 +130,7 @@
 import com.google.gerrit.server.git.ReceivePackInitializer;
 import com.google.gerrit.server.git.TagCache;
 import com.google.gerrit.server.git.TransferConfig;
+import com.google.gerrit.server.git.receive.PluginPushOption;
 import com.google.gerrit.server.git.receive.ReceiveCommitsModule;
 import com.google.gerrit.server.git.validators.CommentCountValidator;
 import com.google.gerrit.server.git.validators.CommentCumulativeSizeValidator;
@@ -388,6 +389,7 @@
         .toInstance(SuggestReviewers.configListener());
     DynamicSet.setOf(binder(), ExternalIncludedIn.class);
     DynamicMap.mapOf(binder(), ProjectConfigEntry.class);
+    DynamicSet.setOf(binder(), PluginPushOption.class);
     DynamicSet.setOf(binder(), PatchSetWebLink.class);
     DynamicSet.setOf(binder(), ParentWebLink.class);
     DynamicSet.setOf(binder(), FileWebLink.class);
diff --git a/java/com/google/gerrit/server/events/CommitReceivedEvent.java b/java/com/google/gerrit/server/events/CommitReceivedEvent.java
index eb4d9ee..de355ea 100644
--- a/java/com/google/gerrit/server/events/CommitReceivedEvent.java
+++ b/java/com/google/gerrit/server/events/CommitReceivedEvent.java
@@ -14,6 +14,7 @@
 
 package com.google.gerrit.server.events;
 
+import com.google.common.collect.ImmutableListMultimap;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.IdentifiedUser;
 import java.io.IOException;
@@ -29,6 +30,7 @@
   public ReceiveCommand command;
   public Project project;
   public String refName;
+  public ImmutableListMultimap<String, String> pushOptions;
   public Config repoConfig;
   public RevWalk revWalk;
   public RevCommit commit;
@@ -42,6 +44,7 @@
       ReceiveCommand command,
       Project project,
       String refName,
+      ImmutableListMultimap<String, String> pushOptions,
       Config repoConfig,
       ObjectReader reader,
       ObjectId commitId,
@@ -51,6 +54,7 @@
     this.command = command;
     this.project = project;
     this.refName = refName;
+    this.pushOptions = pushOptions;
     this.repoConfig = repoConfig;
     this.revWalk = new RevWalk(reader);
     this.commit = revWalk.parseCommit(commitId);
diff --git a/java/com/google/gerrit/server/git/GitRepositoryManager.java b/java/com/google/gerrit/server/git/GitRepositoryManager.java
index 2697eee..e4d0696 100644
--- a/java/com/google/gerrit/server/git/GitRepositoryManager.java
+++ b/java/com/google/gerrit/server/git/GitRepositoryManager.java
@@ -57,4 +57,13 @@
 
   /** @return set of all known projects, sorted by natural NameKey order. */
   SortedSet<Project.NameKey> list();
+
+  /**
+   * Check if garbage collection can be performed by the repository manager.
+   *
+   * @return true if repository can perform garbage collection.
+   */
+  default Boolean canPerformGC() {
+    return false;
+  }
 }
diff --git a/java/com/google/gerrit/server/git/LocalDiskRepositoryManager.java b/java/com/google/gerrit/server/git/LocalDiskRepositoryManager.java
index bf5a0fd..10220d8 100644
--- a/java/com/google/gerrit/server/git/LocalDiskRepositoryManager.java
+++ b/java/com/google/gerrit/server/git/LocalDiskRepositoryManager.java
@@ -199,6 +199,11 @@
     }
   }
 
+  @Override
+  public Boolean canPerformGC() {
+    return true;
+  }
+
   private boolean isUnreasonableName(Project.NameKey nameKey) {
     final String name = nameKey.get();
 
diff --git a/java/com/google/gerrit/server/git/receive/BranchCommitValidator.java b/java/com/google/gerrit/server/git/receive/BranchCommitValidator.java
index 55261223..f680b7b 100644
--- a/java/com/google/gerrit/server/git/receive/BranchCommitValidator.java
+++ b/java/com/google/gerrit/server/git/receive/BranchCommitValidator.java
@@ -19,6 +19,7 @@
 
 import com.google.auto.value.AutoValue;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
 import com.google.common.flogger.FluentLogger;
 import com.google.gerrit.common.Nullable;
 import com.google.gerrit.entities.BranchNameKey;
@@ -109,12 +110,13 @@
       ObjectReader objectReader,
       ReceiveCommand cmd,
       RevCommit commit,
+      ImmutableListMultimap<String, String> pushOptions,
       boolean isMerged,
       NoteMap rejectCommits,
       @Nullable Change change)
       throws IOException {
     return validateCommit(
-        repository, objectReader, cmd, commit, isMerged, rejectCommits, change, false);
+        repository, objectReader, cmd, commit, pushOptions, isMerged, rejectCommits, change, false);
   }
 
   /**
@@ -134,6 +136,7 @@
       ObjectReader objectReader,
       ReceiveCommand cmd,
       RevCommit commit,
+      ImmutableListMultimap<String, String> pushOptions,
       boolean isMerged,
       NoteMap rejectCommits,
       @Nullable Change change,
@@ -146,6 +149,7 @@
               cmd,
               project,
               branch.branch(),
+              pushOptions,
               new Config(repository.getConfig()),
               objectReader,
               commit,
diff --git a/java/com/google/gerrit/server/git/receive/PluginPushOption.java b/java/com/google/gerrit/server/git/receive/PluginPushOption.java
new file mode 100644
index 0000000..788df70
--- /dev/null
+++ b/java/com/google/gerrit/server/git/receive/PluginPushOption.java
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.git.receive;
+
+/**
+ * Push option that can be specified on push.
+ *
+ * <p>On push the option has to be specified as {@code -o <pluginName>~<name>=<value>}, or if a
+ * value is not required as {@code -o <pluginName>~<name>}.
+ */
+public interface PluginPushOption {
+  /** The name of the push option. */
+  public String getName();
+
+  /** The description of the push option. */
+  public String getDescription();
+}
diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
index 4c90ef9..4600f6d 100644
--- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
+++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
@@ -17,6 +17,7 @@
 import static com.google.common.base.MoreObjects.firstNonNull;
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap;
 import static com.google.common.collect.ImmutableSet.toImmutableSet;
 import static com.google.common.flogger.LazyArgs.lazy;
 import static com.google.gerrit.entities.RefNames.REFS_CHANGES;
@@ -48,6 +49,7 @@
 import com.google.common.collect.BiMap;
 import com.google.common.collect.HashBiMap;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSetMultimap;
@@ -211,6 +213,7 @@
 import java.util.concurrent.Future;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
 import org.eclipse.jgit.errors.MissingObjectException;
@@ -326,6 +329,7 @@
   private final CreateGroupPermissionSyncer createGroupPermissionSyncer;
   private final CreateRefControl createRefControl;
   private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
+  private final DynamicSet<PluginPushOption> pluginPushOptions;
   private final PluginSetContext<ReceivePackInitializer> initializers;
   private final MergedByPushOp.Factory mergedByPushOpFactory;
   private final PatchSetInfoFactory patchSetInfoFactory;
@@ -408,6 +412,7 @@
       CreateGroupPermissionSyncer createGroupPermissionSyncer,
       CreateRefControl createRefControl,
       DynamicMap<ProjectConfigEntry> pluginConfigEntries,
+      DynamicSet<PluginPushOption> pluginPushOptions,
       PluginSetContext<ReceivePackInitializer> initializers,
       PluginSetContext<CommentValidator> commentValidators,
       MergedByPushOp.Factory mergedByPushOpFactory,
@@ -467,6 +472,7 @@
     this.patchSetInfoFactory = patchSetInfoFactory;
     this.permissionBackend = permissionBackend;
     this.pluginConfigEntries = pluginConfigEntries;
+    this.pluginPushOptions = pluginPushOptions;
     this.projectCache = projectCache;
     this.psUtil = psUtil;
     this.performanceLoggers = performanceLoggers;
@@ -1788,8 +1794,13 @@
       String ref;
       magicBranch.cmdLineParser = optionParserFactory.create(magicBranch);
 
+      // Filter out plugin push options, as the parser would reject them as unknown.
+      ImmutableListMultimap<String, String> pushOptionsToParse =
+          pushOptions.entries().stream()
+              .filter(e -> !isPluginPushOption(e.getKey()))
+              .collect(toImmutableListMultimap(e -> e.getKey(), e -> e.getValue()));
       try {
-        ref = magicBranch.parse(pushOptions);
+        ref = magicBranch.parse(pushOptionsToParse);
       } catch (CmdLineException e) {
         if (!magicBranch.cmdLineParser.wasHelpRequestedByOption()) {
           logger.atFine().log("Invalid branch syntax");
@@ -1808,6 +1819,20 @@
         StringWriter w = new StringWriter();
         w.write("\nHelp for refs/for/branch:\n\n");
         magicBranch.cmdLineParser.printUsage(w, null);
+
+        String pluginPushOptionsHelp =
+            StreamSupport.stream(pluginPushOptions.entries().spliterator(), /* parallel= */ false)
+                .map(
+                    e ->
+                        String.format(
+                            "-o %s~%s: %s",
+                            e.getPluginName(), e.get().getName(), e.get().getDescription()))
+                .sorted()
+                .collect(joining("\n"));
+        if (!pluginPushOptionsHelp.isEmpty()) {
+          w.write("\nPlugin push options:\n" + pluginPushOptionsHelp);
+        }
+
         addMessage(w.toString());
         reject(cmd, "see help");
         return;
@@ -1972,6 +1997,11 @@
     }
   }
 
+  private boolean isPluginPushOption(String pushOptionName) {
+    return StreamSupport.stream(pluginPushOptions.entries().spliterator(), /* parallel= */ false)
+        .anyMatch(e -> pushOptionName.equals(e.getPluginName() + "~" + e.get().getName()));
+  }
+
   // Validate that the new commits are connected with the target
   // branch.  If they aren't, we want to abort. We do this check by
   // looking to see if we can compute a merge base between the new
@@ -2219,6 +2249,7 @@
                   receivePack.getRevWalk().getObjectReader(),
                   magicBranch.cmd,
                   c,
+                  ImmutableListMultimap.copyOf(pushOptions),
                   magicBranch.merged,
                   rejectCommits,
                   null);
@@ -3231,7 +3262,15 @@
 
           BranchCommitValidator.Result validationResult =
               validator.validateCommit(
-                  repo, walk.getObjectReader(), cmd, c, false, rejectCommits, null, skipValidation);
+                  repo,
+                  walk.getObjectReader(),
+                  cmd,
+                  c,
+                  ImmutableListMultimap.copyOf(pushOptions),
+                  false,
+                  rejectCommits,
+                  null,
+                  skipValidation);
           messages.addAll(validationResult.messages());
           if (!validationResult.isValid()) {
             break;
diff --git a/java/com/google/gerrit/server/git/validators/CommitValidators.java b/java/com/google/gerrit/server/git/validators/CommitValidators.java
index e1e4f62..1fde48c 100644
--- a/java/com/google/gerrit/server/git/validators/CommitValidators.java
+++ b/java/com/google/gerrit/server/git/validators/CommitValidators.java
@@ -452,7 +452,9 @@
       try (Repository repository = repoManager.openRepository(receiveEvent.project.getNameKey());
           DiffFormatter diffFormatter = new DiffFormatter(DisabledOutputStream.INSTANCE)) {
         diffFormatter.setRepository(repository);
-        diffFormatter.setDetectRenames(true);
+        // Do not detect renames; that would require reading file contents, which is slow for large
+        // files.
+        diffFormatter.setDetectRenames(false);
         // For merge commits, i.e. >1 parents, we use parent #0 by convention.
         List<DiffEntry> diffEntries =
             diffFormatter.scan(
diff --git a/java/com/google/gerrit/server/logging/LoggingContext.java b/java/com/google/gerrit/server/logging/LoggingContext.java
index a1b807d..f446acf 100644
--- a/java/com/google/gerrit/server/logging/LoggingContext.java
+++ b/java/com/google/gerrit/server/logging/LoggingContext.java
@@ -90,7 +90,6 @@
     return tags.get() == null
         && forceLogging.get() == null
         && performanceLogging.get() == null
-        && performanceLogRecords.get() == null
         && aclLogging.get() == null
         && aclLogRecords.get() == null;
   }
diff --git a/java/com/google/gerrit/server/patch/PatchListCache.java b/java/com/google/gerrit/server/patch/PatchListCache.java
index 63cac0e..e60302a 100644
--- a/java/com/google/gerrit/server/patch/PatchListCache.java
+++ b/java/com/google/gerrit/server/patch/PatchListCache.java
@@ -21,10 +21,38 @@
 
 /** Provides a cached list of {@link PatchListEntry}. */
 public interface PatchListCache {
+  /**
+   * Returns the patch list - list of modified files - between two commits.
+   *
+   * @param key identifies the old / new commits.
+   * @param project name key identifying a specific git project (repository).
+   * @return patch list containing the modified files between two commits.
+   * @deprecated use {@link DiffOperations} instead.
+   */
+  @Deprecated
   PatchList get(PatchListKey key, Project.NameKey project) throws PatchListNotAvailableException;
 
+  /**
+   * Returns the patch list - list of modified files - between two commits.
+   *
+   * @param change entity containing all change data.
+   * @param patchSet single revision of a {@link Change}.
+   * @return patch list containing the modified files between two commits.
+   * @deprecated use {@link DiffOperations} instead.
+   */
+  @Deprecated
   PatchList get(Change change, PatchSet patchSet) throws PatchListNotAvailableException;
 
+  /**
+   * Returns the patch list - list of modified files - between two commits.
+   *
+   * @param change entity containing all change data.
+   * @param patchSet single revision of a {@link Change}.
+   * @param parentNum 1-based parent number when new commit used in comparison is a merge commit.
+   * @return patch list containing the modified files between two commits.
+   * @deprecated use {@link DiffOperations} instead.
+   */
+  @Deprecated
   ObjectId getOldId(Change change, PatchSet patchSet, Integer parentNum)
       throws PatchListNotAvailableException;
 
diff --git a/java/com/google/gerrit/server/patch/filediff/FileDiffCacheImpl.java b/java/com/google/gerrit/server/patch/filediff/FileDiffCacheImpl.java
index 1bb407d..8163b19 100644
--- a/java/com/google/gerrit/server/patch/filediff/FileDiffCacheImpl.java
+++ b/java/com/google/gerrit/server/patch/filediff/FileDiffCacheImpl.java
@@ -93,7 +93,7 @@
         persist(DIFF, FileDiffCacheKey.class, FileDiffOutput.class)
             .maximumWeight(10 << 20)
             .weigher(FileDiffWeigher.class)
-            .version(2)
+            .version(3)
             .keySerializer(FileDiffCacheKey.Serializer.INSTANCE)
             .valueSerializer(FileDiffOutput.Serializer.INSTANCE)
             .loader(FileDiffLoader.class);
@@ -203,9 +203,8 @@
       // COMMIT_MSG and MERGE_LIST evaluations outside of the diff cache. For more details, see
       // discussion in
       // https://gerrit-review.googlesource.com/c/gerrit/+/280519/6..18/java/com/google/gerrit/server/patch/FileDiffCache.java#b540
-      Text oldCommitMsgTxt = Text.forCommit(reader, oldCommit);
-      if (oldCommitMsgTxt.size() > 0
-          && oldCommitMsgTxt.getString(0).startsWith(AutoMerger.AUTO_MERGE_MSG_PREFIX)) {
+      String oldCommitMsgTxt = new String(Text.forCommit(reader, oldCommit).getContent(), UTF_8);
+      if (oldCommitMsgTxt.contains(AutoMerger.AUTO_MERGE_MSG_PREFIX)) {
         return ComparisonType.againstAutoMerge();
       }
       return ComparisonType.againstOtherPatchSet();
diff --git a/java/com/google/gerrit/server/restapi/change/PostReview.java b/java/com/google/gerrit/server/restapi/change/PostReview.java
index 73b38b2..58321e9 100644
--- a/java/com/google/gerrit/server/restapi/change/PostReview.java
+++ b/java/com/google/gerrit/server/restapi/change/PostReview.java
@@ -356,7 +356,8 @@
       }
 
       // Add WorkInProgressOp if requested.
-      if (input.ready || input.workInProgress) {
+      if ((input.ready || input.workInProgress)
+          && didWorkInProgressChange(revision.getChange().isWorkInProgress(), input)) {
         if (input.ready && input.workInProgress) {
           output.error = ERROR_WIP_READY_MUTUALLY_EXCLUSIVE;
           return Response.withStatusCode(SC_BAD_REQUEST, output);
@@ -405,6 +406,10 @@
     return Response.ok(output);
   }
 
+  private boolean didWorkInProgressChange(boolean currentWorkInProgress, ReviewInput input) {
+    return input.ready == currentWorkInProgress || input.workInProgress != currentWorkInProgress;
+  }
+
   private NotifyHandling defaultNotify(Change c, ReviewInput in) {
     boolean workInProgress = c.isWorkInProgress();
     if (in.workInProgress) {
diff --git a/java/com/google/gerrit/server/restapi/group/GroupsCollection.java b/java/com/google/gerrit/server/restapi/group/GroupsCollection.java
index e0cfb1e..08cc974 100644
--- a/java/com/google/gerrit/server/restapi/group/GroupsCollection.java
+++ b/java/com/google/gerrit/server/restapi/group/GroupsCollection.java
@@ -87,7 +87,7 @@
     final CurrentUser user = self.get();
     if (user instanceof AnonymousUser) {
       throw new AuthException("Authentication required");
-    } else if (!(user.isIdentifiedUser())) {
+    } else if (!(user.isIdentifiedUser() || user.isInternalUser())) {
       throw new ResourceNotFoundException(id);
     }
 
diff --git a/java/com/google/gerrit/server/restapi/project/CreateProject.java b/java/com/google/gerrit/server/restapi/project/CreateProject.java
index faab241..f3b2bad 100644
--- a/java/com/google/gerrit/server/restapi/project/CreateProject.java
+++ b/java/com/google/gerrit/server/restapi/project/CreateProject.java
@@ -37,6 +37,7 @@
 import com.google.gerrit.server.ProjectUtil;
 import com.google.gerrit.server.config.AllProjectsName;
 import com.google.gerrit.server.config.AllUsersName;
+import com.google.gerrit.server.config.GerritServerConfig;
 import com.google.gerrit.server.config.ProjectOwnerGroupsProvider;
 import com.google.gerrit.server.group.GroupResolver;
 import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -60,6 +61,7 @@
 import java.util.List;
 import java.util.concurrent.locks.Lock;
 import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.lib.Config;
 import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.Repository;
 
@@ -79,6 +81,8 @@
   private final PluginItemContext<ProjectNameLockManager> lockManager;
   private final ProjectCreator projectCreator;
 
+  private final Config gerritConfig;
+
   @Inject
   CreateProject(
       ProjectCreator projectCreator,
@@ -90,7 +94,8 @@
       Provider<PutConfig> putConfig,
       AllProjectsName allProjects,
       AllUsersName allUsers,
-      PluginItemContext<ProjectNameLockManager> lockManager) {
+      PluginItemContext<ProjectNameLockManager> lockManager,
+      @GerritServerConfig Config gerritConfig) {
     this.projectsCollection = projectsCollection;
     this.projectCreator = projectCreator;
     this.groupResolver = groupResolver;
@@ -101,6 +106,7 @@
     this.allProjects = allProjects;
     this.allUsers = allUsers;
     this.lockManager = lockManager;
+    this.gerritConfig = gerritConfig;
   }
 
   @Override
@@ -190,18 +196,18 @@
 
   private List<String> normalizeBranchNames(List<String> branches) throws BadRequestException {
     if (branches == null || branches.isEmpty()) {
-      return Collections.singletonList(Constants.R_HEADS + Constants.MASTER);
+      // Use host-level default for HEAD or fall back to 'master' if nothing else was specified in
+      // the input.
+      String defaultBranch = gerritConfig.getString("gerrit", null, "defaultBranch");
+      defaultBranch =
+          defaultBranch != null
+              ? normalizeAndValidateBranch(defaultBranch)
+              : Constants.R_HEADS + Constants.MASTER;
+      return Collections.singletonList(defaultBranch);
     }
-
     List<String> normalizedBranches = new ArrayList<>();
     for (String branch : branches) {
-      while (branch.startsWith("/")) {
-        branch = branch.substring(1);
-      }
-      branch = RefNames.fullName(branch);
-      if (!Repository.isValidRefName(branch)) {
-        throw new BadRequestException(String.format("Branch \"%s\" is not a valid name.", branch));
-      }
+      branch = normalizeAndValidateBranch(branch);
       if (!normalizedBranches.contains(branch)) {
         normalizedBranches.add(branch);
       }
@@ -209,6 +215,17 @@
     return normalizedBranches;
   }
 
+  private String normalizeAndValidateBranch(String branch) throws BadRequestException {
+    while (branch.startsWith("/")) {
+      branch = branch.substring(1);
+    }
+    branch = RefNames.fullName(branch);
+    if (!Repository.isValidRefName(branch)) {
+      throw new BadRequestException(String.format("Branch \"%s\" is not a valid name.", branch));
+    }
+    return branch;
+  }
+
   static class ValidBranchListener implements ProjectCreationValidationListener {
     @Override
     public void validateNewProject(CreateProjectArgs args) throws ValidationException {
diff --git a/java/com/google/gerrit/server/restapi/project/GarbageCollect.java b/java/com/google/gerrit/server/restapi/project/GarbageCollect.java
index c5423e6..abd47e9 100644
--- a/java/com/google/gerrit/server/restapi/project/GarbageCollect.java
+++ b/java/com/google/gerrit/server/restapi/project/GarbageCollect.java
@@ -29,7 +29,6 @@
 import com.google.gerrit.server.config.UrlFormatter;
 import com.google.gerrit.server.git.GarbageCollection;
 import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gerrit.server.git.LocalDiskRepositoryManager;
 import com.google.gerrit.server.git.WorkQueue;
 import com.google.gerrit.server.ioutil.HexFormat;
 import com.google.gerrit.server.project.ProjectResource;
@@ -67,7 +66,7 @@
       DynamicItem<UrlFormatter> urlFormatter) {
     this.workQueue = workQueue;
     this.urlFormatter = urlFormatter;
-    this.canGC = repoManager instanceof LocalDiskRepositoryManager;
+    this.canGC = repoManager.canPerformGC();
     this.garbageCollectionFactory = garbageCollectionFactory;
   }
 
diff --git a/java/com/google/gerrit/sshd/commands/CreateProjectCommand.java b/java/com/google/gerrit/sshd/commands/CreateProjectCommand.java
index f2ab4e8..e2d554d 100644
--- a/java/com/google/gerrit/sshd/commands/CreateProjectCommand.java
+++ b/java/com/google/gerrit/sshd/commands/CreateProjectCommand.java
@@ -143,7 +143,7 @@
       name = "--branch",
       aliases = {"-b"},
       metaVar = "BRANCH",
-      usage = "initial branch name\n(default: master)")
+      usage = "initial branch name\n(default: gerrit.defaultProject)")
   private List<String> branch;
 
   @Option(name = "--empty-commit", usage = "to create initial empty commit")
diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
index 50b7a7c..517cf89 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
@@ -702,6 +702,8 @@
   @Test
   public void reviewWithReadyByNonOwnerReturnsError() throws Exception {
     PushOneCommit.Result r = createChange();
+    change(r).setWorkInProgress();
+
     ReviewInput in = ReviewInput.noScore().setReady(true);
     requestScopeOperations.setApiUser(user.id());
     AuthException thrown =
diff --git a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
index 6e19ac2..dd70d4a 100644
--- a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
@@ -116,7 +116,7 @@
         extensionRegistry.newRegistration().add(projectIndexedCounter)) {
       String name = name("foo");
       assertThat(gApi.projects().create(name).get().name).isEqualTo(name);
-
+      assertHead(name, "refs/heads/master");
       RevCommit head = getRemoteHead(name, RefNames.REFS_CONFIG);
       eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
 
@@ -126,6 +126,23 @@
   }
 
   @Test
+  @GerritConfig(name = "gerrit.defaultBranch", value = "main")
+  public void createProject_WhenDefaultBranchIsSetInConfig() throws Exception {
+    ProjectIndexedCounter projectIndexedCounter = new ProjectIndexedCounter();
+    try (Registration registration =
+        extensionRegistry.newRegistration().add(projectIndexedCounter)) {
+      String name = name("foo");
+      assertThat(gApi.projects().create(name).get().name).isEqualTo(name);
+      assertHead(name, "refs/heads/main");
+      RevCommit head = getRemoteHead(name, RefNames.REFS_CONFIG);
+      eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
+
+      eventRecorder.assertRefUpdatedEvents(name, "refs/heads/main", new String[] {});
+      projectIndexedCounter.assertReindexOf(name);
+    }
+  }
+
+  @Test
   public void createProjectWithInitialBranches() throws Exception {
     ProjectIndexedCounter projectIndexedCounter = new ProjectIndexedCounter();
     try (Registration registration =
@@ -135,12 +152,13 @@
       ProjectInput input = new ProjectInput();
       input.name = name;
       input.createEmptyCommit = true;
-      input.branches = ImmutableList.of("master", "foo");
+      input.branches = ImmutableList.of("foo", "master");
       assertThat(gApi.projects().create(input).get().name).isEqualTo(name);
       assertThat(
               gApi.projects().name(name).branches().get().stream().map(b -> b.ref).collect(toSet()))
           .containsExactly("refs/heads/foo", "refs/heads/master", "HEAD", RefNames.REFS_CONFIG);
 
+      assertHead(name, "refs/heads/foo");
       RevCommit head = getRemoteHead(name, RefNames.REFS_CONFIG);
       eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
 
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java
index ec59674..f443238 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java
@@ -519,6 +519,32 @@
   }
 
   @Test
+  public void diffAgainstAutoMergeCanBeRetrievedForCommitMessageAndMergeList() throws Exception {
+    PushOneCommit.Result result = createMergeCommitChange("refs/for/master", "my_file.txt");
+    String changeId = result.getChangeId();
+    addModifiedPatchSet(changeId, "my_file.txt", content -> content.concat("Line I\nLine II\n"));
+
+    DiffInfo commitMessageDiffInfo =
+        getDiffRequest(changeId, CURRENT, COMMIT_MSG)
+            .get(); // diff latest PS against base (auto-merge)
+    DiffInfo mergeListDiffInfo =
+        getDiffRequest(changeId, CURRENT, MERGE_LIST)
+            .get(); // diff latest PS against base (auto-merge)
+
+    assertThat(commitMessageDiffInfo).changeType().isEqualTo(ChangeType.ADDED);
+    assertThat(commitMessageDiffInfo).content().hasSize(1);
+
+    assertThat(mergeListDiffInfo).changeType().isEqualTo(ChangeType.ADDED);
+    assertThat(mergeListDiffInfo).content().hasSize(1);
+    assertThat(mergeListDiffInfo)
+        .content()
+        .element(0)
+        .linesOfB()
+        .element(0)
+        .isEqualTo("Merge List:");
+  }
+
+  @Test
   public void diffOfUnmodifiedFileMarksAllLinesAsCommon() throws Exception {
     String filePath = "a_new_file.txt";
     String fileContent = "Line 1\nLine 2\nLine 3\n";
diff --git a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
index 845c461..eac0f1b 100644
--- a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
+++ b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
@@ -62,6 +62,7 @@
 import com.google.gerrit.acceptance.config.GerritConfig;
 import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
 import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
+import com.google.gerrit.common.Nullable;
 import com.google.gerrit.common.data.GlobalCapability;
 import com.google.gerrit.entities.AccountGroup;
 import com.google.gerrit.entities.Address;
@@ -100,6 +101,7 @@
 import com.google.gerrit.server.ChangeMessagesUtil;
 import com.google.gerrit.server.events.CommitReceivedEvent;
 import com.google.gerrit.server.git.receive.NoteDbPushOption;
+import com.google.gerrit.server.git.receive.PluginPushOption;
 import com.google.gerrit.server.git.receive.ReceiveConstants;
 import com.google.gerrit.server.git.validators.CommitValidationListener;
 import com.google.gerrit.server.git.validators.CommitValidationMessage;
@@ -2364,6 +2366,8 @@
     private final AtomicInteger count = new AtomicInteger();
     private final boolean validateAll;
 
+    @Nullable private CommitReceivedEvent receivedEvent;
+
     TestValidator(boolean validateAll) {
       this.validateAll = validateAll;
     }
@@ -2373,7 +2377,8 @@
     }
 
     @Override
-    public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) {
+    public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receivedEvent) {
+      this.receivedEvent = receivedEvent;
       count.incrementAndGet();
       return Collections.emptyList();
     }
@@ -2386,6 +2391,31 @@
     public int count() {
       return count.get();
     }
+
+    @Nullable
+    public CommitReceivedEvent getReceivedEvent() {
+      return receivedEvent;
+    }
+  }
+
+  private static class TestPluginPushOption implements PluginPushOption {
+    private final String name;
+    private final String description;
+
+    TestPluginPushOption(String name, String description) {
+      this.name = name;
+      this.description = description;
+    }
+
+    @Override
+    public String getName() {
+      return name;
+    }
+
+    @Override
+    public String getDescription() {
+      return description;
+    }
   }
 
   private static class TopicValidator implements TopicEditedListener {
@@ -2449,6 +2479,38 @@
   }
 
   @Test
+  public void pushOptionsArePassedToCommitValidationListener() throws Exception {
+    TestValidator validator = new TestValidator();
+    PluginPushOption fooOption = new TestPluginPushOption("foo", "some description");
+    PluginPushOption barOption = new TestPluginPushOption("bar", "other description");
+    try (Registration registration =
+        extensionRegistry.newRegistration().add(validator).add(fooOption).add(barOption)) {
+      PushOneCommit push =
+          pushFactory.create(admin.newIdent(), testRepo, "change2", "b.txt", "content");
+      push.setPushOptions(ImmutableList.of("trace=123", "gerrit~foo", "gerrit~bar=456"));
+      PushOneCommit.Result r = push.to("refs/for/master");
+      r.assertOkStatus();
+      assertThat(validator.getReceivedEvent().pushOptions)
+          .containsExactly("trace", "123", "gerrit~foo", "", "gerrit~bar", "456");
+    }
+  }
+
+  @Test
+  public void pluginPushOptionsHelp() throws Exception {
+    PluginPushOption fooOption = new TestPluginPushOption("foo", "some description");
+    PluginPushOption barOption = new TestPluginPushOption("bar", "other description");
+    try (Registration registration =
+        extensionRegistry.newRegistration().add(fooOption).add(barOption)) {
+      PushOneCommit push =
+          pushFactory.create(admin.newIdent(), testRepo, "change2", "b.txt", "content");
+      push.setPushOptions(ImmutableList.of("help"));
+      PushOneCommit.Result r = push.to("refs/for/master");
+      r.assertErrorStatus("see help");
+      r.assertMessage("-o gerrit~bar: other description\n-o gerrit~foo: some description\n");
+    }
+  }
+
+  @Test
   public void pushNoteDbRef() throws Exception {
     String ref = "refs/changes/34/1234/meta";
     RevCommit c = testRepo.commit().message("Junk NoteDb commit").create();
diff --git a/javatests/com/google/gerrit/acceptance/rest/binding/PluginProvidedChildRestApiBindingsIT.java b/javatests/com/google/gerrit/acceptance/rest/binding/PluginProvidedChildRestApiBindingsIT.java
index 22feeb7..23a1d23 100644
--- a/javatests/com/google/gerrit/acceptance/rest/binding/PluginProvidedChildRestApiBindingsIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/binding/PluginProvidedChildRestApiBindingsIT.java
@@ -15,12 +15,16 @@
 package com.google.gerrit.acceptance.rest.binding;
 
 import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
+import static com.google.gerrit.server.change.RobotCommentResource.ROBOT_COMMENT_KIND;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 import com.google.gerrit.acceptance.AbstractDaemonTest;
+import com.google.gerrit.acceptance.PushOneCommit;
 import com.google.gerrit.acceptance.rest.util.RestApiCallHelper;
 import com.google.gerrit.acceptance.rest.util.RestCall;
+import com.google.gerrit.entities.Change;
 import com.google.gerrit.entities.PatchSet;
 import com.google.gerrit.extensions.registration.DynamicMap;
 import com.google.gerrit.extensions.restapi.ChildCollection;
@@ -34,6 +38,8 @@
 import com.google.gerrit.extensions.restapi.RestResource;
 import com.google.gerrit.extensions.restapi.RestView;
 import com.google.gerrit.server.change.RevisionResource;
+import com.google.gerrit.server.change.RobotCommentResource;
+import com.google.gerrit.testing.TestCommentHelper;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -47,6 +53,7 @@
  * not test the functionality of the plugin REST endpoints.
  */
 public class PluginProvidedChildRestApiBindingsIT extends AbstractDaemonTest {
+  @Inject private TestCommentHelper testCommentHelper;
 
   /** Resource to bind a child collection. */
   public static final TypeLiteral<RestView<TestPluginResource>> TEST_KIND =
@@ -54,7 +61,7 @@
 
   private static final String PLUGIN_NAME = "my-plugin";
 
-  private static final ImmutableSet<RestCall> TEST_CALLS =
+  private static final ImmutableSet<RestCall> REVISION_TEST_CALLS =
       ImmutableSet.of(
           // Calls that have the plugin name as part of the collection name
           RestCall.get("/changes/%s/revisions/%s/" + PLUGIN_NAME + "~test-collection/"),
@@ -70,6 +77,9 @@
           RestCall.post("/changes/%s/revisions/%s/test-collection/"),
           RestCall.post("/changes/%s/revisions/%s/test-collection/1/update"));
 
+  private static final ImmutableSet<RestCall> ROBOTCOMMENT_TEST_CALLS =
+      ImmutableSet.of(RestCall.delete("/changes/%s/revisions/%s/robotcomments/%s"));
+
   /**
    * Module for all sys bindings.
    *
@@ -89,6 +99,7 @@
               postOnCollection(TEST_KIND).to(TestPostOnCollection.class);
               post(TEST_KIND, "update").to(TestPost.class);
               get(TEST_KIND, "detail").to(TestGet.class);
+              delete(ROBOT_COMMENT_KIND).to(TestDelete.class);
             }
           });
     }
@@ -148,15 +159,46 @@
     }
   }
 
+  @Singleton
+  static class TestDelete implements RestModifyView<RobotCommentResource, String> {
+    @Override
+    public Response<?> apply(RobotCommentResource resource, String input) throws Exception {
+      return Response.none();
+    }
+  }
+
   @Test
-  public void testEndpoints() throws Exception {
+  public void testRevisionEndpoints() throws Exception {
     PatchSet.Id patchSetId = createChange().getPatchSetId();
     try (AutoCloseable ignored = installPlugin(PLUGIN_NAME, MyPluginSysModule.class, null, null)) {
       RestApiCallHelper.execute(
           adminRestSession,
-          TEST_CALLS.asList(),
+          REVISION_TEST_CALLS.asList(),
           String.valueOf(patchSetId.changeId().get()),
           String.valueOf(patchSetId.get()));
     }
   }
+
+  @Test
+  public void testRobotCommentEndpoints() throws Exception {
+    PatchSet.Id patchSetId = createChange().getPatchSetId();
+    String robotCommentUuid = createRobotComment(patchSetId.changeId());
+    try (AutoCloseable ignored = installPlugin(PLUGIN_NAME, MyPluginSysModule.class, null, null)) {
+      RestApiCallHelper.execute(
+          adminRestSession,
+          ROBOTCOMMENT_TEST_CALLS.asList(),
+          String.valueOf(patchSetId.changeId().get()),
+          String.valueOf(patchSetId.get()),
+          robotCommentUuid);
+    }
+  }
+
+  private String createRobotComment(Change.Id changeId) throws Exception {
+    testCommentHelper.addRobotComment(
+        changeId, TestCommentHelper.createRobotCommentInput(PushOneCommit.FILE_NAME));
+    return Iterables.getOnlyElement(
+            Iterables.getOnlyElement(
+                gApi.changes().id(changeId.get()).current().robotComments().values()))
+        .id;
+  }
 }
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java b/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java
index 7e6a822..d2a48be1 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java
@@ -495,6 +495,44 @@
   }
 
   @Test
+  public void readyForReviewHasNoEffectOnReadyChanges() throws Exception {
+    PushOneCommit.Result r = createChange();
+    change(r)
+        .current()
+        .review(ReviewInput.create().reviewer(user.email()).blockAutomaticAttentionSetRules());
+
+    change(r).current().review(ReviewInput.create().setWorkInProgress(false));
+    assertThat(r.getChange().attentionSet()).isEmpty();
+
+    change(r).current().review(ReviewInput.create().setReady(true));
+    assertThat(r.getChange().attentionSet()).isEmpty();
+  }
+
+  @Test
+  public void workInProgressHasNoEffectOnWorkInProgressChanges() throws Exception {
+    PushOneCommit.Result r = createChange();
+    change(r)
+        .current()
+        .review(
+            ReviewInput.create()
+                .reviewer(user.email())
+                .setWorkInProgress(true)
+                .addUserToAttentionSet(user.email(), /* reason= */ "reason"));
+
+    change(r).current().review(ReviewInput.create().setWorkInProgress(true));
+    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
+    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
+    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
+    assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
+
+    change(r).current().review(ReviewInput.create().setReady(false));
+    attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
+    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
+    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
+    assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
+  }
+
+  @Test
   public void rebaseDoesNotAddToAttentionSet() throws Exception {
     PushOneCommit.Result r = createChange();
     change(r).setWorkInProgress();
diff --git a/javatests/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java b/javatests/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java
index e5c5952..7090074 100644
--- a/javatests/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java
@@ -26,6 +26,7 @@
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import com.google.common.net.HttpHeaders;
@@ -40,6 +41,7 @@
 import com.google.gerrit.entities.BooleanProjectConfig;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.entities.RefNames;
+import com.google.gerrit.extensions.api.projects.BranchInfo;
 import com.google.gerrit.extensions.api.projects.ConfigInfo;
 import com.google.gerrit.extensions.api.projects.ConfigInput;
 import com.google.gerrit.extensions.api.projects.ProjectInput;
@@ -47,6 +49,7 @@
 import com.google.gerrit.extensions.client.SubmitType;
 import com.google.gerrit.extensions.common.ProjectInfo;
 import com.google.gerrit.extensions.restapi.AuthException;
+import com.google.gerrit.extensions.restapi.BadRequestException;
 import com.google.gerrit.extensions.restapi.ResourceConflictException;
 import com.google.gerrit.extensions.restapi.RestApiException;
 import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
@@ -304,13 +307,15 @@
   }
 
   @Test
-  public void createProjectWithEmptyCommit() throws Exception {
+  @GerritConfig(name = "gerrit.defaultBranch", value = "main")
+  public void createPermissionOnlyProject_WhenDefaultBranchIsSet() throws Exception {
     String newProjectName = name("newProject");
     ProjectInput in = new ProjectInput();
     in.name = newProjectName;
-    in.createEmptyCommit = true;
+    in.permissionsOnly = true;
     gApi.projects().create(in);
-    assertEmptyCommit(newProjectName, "refs/heads/master");
+    // For permissionOnly, don't use host-level default branch.
+    assertHead(newProjectName, RefNames.REFS_CONFIG);
   }
 
   @Test
@@ -344,6 +349,72 @@
   }
 
   @Test
+  @GerritConfig(name = "gerrit.defaultBranch", value = "main")
+  public void createProject_WhenDefaultBranchIsSet() throws Exception {
+    String newProjectName = name("newProject");
+    gApi.projects().create(newProjectName).get();
+    ImmutableMap<String, BranchInfo> branches = getProjectBranches(newProjectName);
+    // HEAD symbolic ref is set to the default, but the actual ref is not created.
+    assertThat(branches.keySet()).containsExactly("HEAD", "refs/meta/config");
+    assertHead(newProjectName, "refs/heads/main");
+  }
+
+  @Test
+  @GerritConfig(name = "gerrit.defaultBranch", value = "main")
+  public void createProjectWithEmptyCommit_WhenDefaultBranchIsSet() throws Exception {
+    String newProjectName = name("newProject");
+    ProjectInput in = new ProjectInput();
+    in.name = newProjectName;
+    in.createEmptyCommit = true;
+    gApi.projects().create(in);
+    ImmutableMap<String, BranchInfo> branches = getProjectBranches(newProjectName);
+    // HEAD symbolic ref is set to the default, and the actual ref is created.
+    assertThat(branches.keySet()).containsExactly("HEAD", "refs/meta/config", "refs/heads/main");
+    assertHead(newProjectName, "refs/heads/main");
+    assertEmptyCommit(newProjectName, "HEAD", "refs/heads/main");
+  }
+
+  @Test
+  @GerritConfig(name = "gerrit.defaultBranch", value = "refs/heads/main")
+  public void createProject_WhenDefaultBranchIsSet_WithBranches() throws Exception {
+    // Host-level default only applies if no branches were passed in the input
+    String newProjectName = name("newProject");
+    ProjectInput in = new ProjectInput();
+    in.name = newProjectName;
+    in.createEmptyCommit = true;
+    in.branches = ImmutableList.of("refs/heads/test", "release");
+    gApi.projects().create(in);
+    ImmutableMap<String, BranchInfo> branches = getProjectBranches(newProjectName);
+    assertThat(branches.keySet())
+        .containsExactly("HEAD", "refs/meta/config", "refs/heads/test", "refs/heads/release");
+    assertHead(newProjectName, "refs/heads/test");
+    assertEmptyCommit(newProjectName, "refs/heads/test", "refs/heads/release");
+  }
+
+  @Test
+  @GerritConfig(name = "gerrit.defaultBranch", value = "refs/users/self")
+  public void createProject_WhenDefaultBranchIsSet_ToGerritRef() throws Exception {
+    String newProjectName = name("newProject");
+    Throwable thrown =
+        assertThrows(ResourceConflictException.class, () -> gApi.projects().create(newProjectName));
+    assertThat(thrown).hasCauseThat().isInstanceOf(ValidationException.class);
+    assertThat(thrown)
+        .hasMessageThat()
+        .contains("Cannot create a project with branch refs/users/self");
+  }
+
+  @Test
+  @GerritConfig(name = "gerrit.defaultBranch", value = "refs~main")
+  public void createProject_WhenDefaultBranchIsSet_ToInvalidBranch() throws Exception {
+    String newProjectName = name("newProject");
+    Throwable thrown =
+        assertThrows(BadRequestException.class, () -> gApi.projects().create(newProjectName));
+    assertThat(thrown)
+        .hasMessageThat()
+        .isEqualTo("Branch \"refs/heads/refs~main\" is not a valid name.");
+  }
+
+  @Test
   public void createProjectWithCapability() throws Exception {
     projectOperations
         .allProjectsForUpdate()
@@ -494,12 +565,6 @@
     assertThat(cfg.defaultSubmitType.inheritedValue).isEqualTo(SubmitType.MERGE_ALWAYS);
   }
 
-  private void assertHead(String projectName, String expectedRef) throws Exception {
-    try (Repository repo = repoManager.openRepository(Project.nameKey(projectName))) {
-      assertThat(repo.exactRef(Constants.HEAD).getTarget().getName()).isEqualTo(expectedRef);
-    }
-  }
-
   private void assertEmptyCommit(String projectName, String... refs) throws Exception {
     Project.NameKey projectKey = Project.nameKey(projectName);
     try (Repository repo = repoManager.openRepository(projectKey);
diff --git a/javatests/com/google/gerrit/acceptance/ssh/CreateProjectIT.java b/javatests/com/google/gerrit/acceptance/ssh/CreateProjectIT.java
index 01b8eae..5429131 100644
--- a/javatests/com/google/gerrit/acceptance/ssh/CreateProjectIT.java
+++ b/javatests/com/google/gerrit/acceptance/ssh/CreateProjectIT.java
@@ -19,6 +19,7 @@
 
 import com.google.gerrit.acceptance.AbstractDaemonTest;
 import com.google.gerrit.acceptance.UseSsh;
+import com.google.gerrit.acceptance.config.GerritConfig;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.project.ProjectState;
 import java.util.Optional;
@@ -85,4 +86,35 @@
     assertThat(projectState).isPresent();
     assertThat(projectState.get().getName()).isEqualTo(newProjectName);
   }
+
+  @Test
+  public void withEmptyBranches() throws Exception {
+    String newProjectName = name("newProject");
+    adminSshSession.exec("gerrit create-project " + newProjectName);
+    adminSshSession.assertSuccess();
+    Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
+    assertThat(projectState).isPresent();
+    assertHead(newProjectName, "refs/heads/master");
+  }
+
+  @Test
+  public void withInitBranches() throws Exception {
+    String newProjectName = name("newProject");
+    adminSshSession.exec("gerrit create-project --branch init-branch " + newProjectName);
+    adminSshSession.assertSuccess();
+    Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
+    assertThat(projectState).isPresent();
+    assertHead(newProjectName, "refs/heads/init-branch");
+  }
+
+  @Test
+  @GerritConfig(name = "gerrit.defaultBranch", value = "refs/heads/main")
+  public void withEmptyBranches_WhenDefaultBranchIsSet() throws Exception {
+    String newProjectName = name("newProject");
+    adminSshSession.exec("gerrit create-project " + newProjectName);
+    adminSshSession.assertSuccess();
+    Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
+    assertThat(projectState).isPresent();
+    assertHead(newProjectName, "refs/heads/main");
+  }
 }
diff --git a/javatests/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImplTest.java b/javatests/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImplTest.java
index 00d01d6..7543ba8 100644
--- a/javatests/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImplTest.java
+++ b/javatests/com/google/gerrit/acceptance/testsuite/project/ProjectOperationsImplTest.java
@@ -595,6 +595,15 @@
   }
 
   @Test
+  public void removeAllAccessSections() {
+    projectOperations.allProjectsForUpdate().removeAllAccessSections().update();
+
+    assertThat(projectOperations.project(allProjects).getConfig())
+        .sectionValues("access")
+        .isEmpty();
+  }
+
+  @Test
   public void updatingCapabilitiesNotAllowedForNonAllProjects() throws Exception {
     Project.NameKey key = projectOperations.newProject().create();
     assertThrows(
diff --git a/javatests/com/google/gerrit/server/git/GitRepositoryManagerTest.java b/javatests/com/google/gerrit/server/git/GitRepositoryManagerTest.java
new file mode 100644
index 0000000..7832bec
--- /dev/null
+++ b/javatests/com/google/gerrit/server/git/GitRepositoryManagerTest.java
@@ -0,0 +1,54 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.gerrit.server.git;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.gerrit.entities.Project.NameKey;
+import java.util.SortedSet;
+import org.eclipse.jgit.lib.Repository;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GitRepositoryManagerTest {
+
+  private GitRepositoryManager objectUnderTest;
+
+  @Before
+  public void setUp() throws Exception {
+    objectUnderTest = new TestGitRepositoryManager();
+  }
+
+  @Test
+  public void shouldReturnFalseWhenDefaultCanPerformGC() {
+    assertThat(objectUnderTest.canPerformGC()).isFalse();
+  }
+
+  private static class TestGitRepositoryManager implements GitRepositoryManager {
+    @Override
+    public Repository openRepository(NameKey name) {
+      throw new UnsupportedOperationException("Not implemented");
+    }
+
+    @Override
+    public Repository createRepository(NameKey name) {
+      throw new UnsupportedOperationException("Not implemented");
+    }
+
+    @Override
+    public SortedSet<NameKey> list() {
+      throw new UnsupportedOperationException("Not implemented");
+    }
+  }
+}
diff --git a/javatests/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java b/javatests/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java
index 8ab7dd2..febb142 100644
--- a/javatests/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java
+++ b/javatests/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java
@@ -252,6 +252,11 @@
         () -> newRepoManager.createRepository(Project.nameKey("A")));
   }
 
+  @Test
+  public void testRepositoryCanPerformGC() throws Exception {
+    assertThat(repoManager.canPerformGC()).isTrue();
+  }
+
   private void createSymLink(Project.NameKey project, String link) throws IOException {
     Path base = repoManager.getBasePath(project);
     Path projectDir = base.resolve(project.get() + ".git");
diff --git a/lib/highlightjs/highlight.min.js b/lib/highlightjs/highlight.min.js
index 38fa024..458cb0c 100644
--- a/lib/highlightjs/highlight.min.js
+++ b/lib/highlightjs/highlight.min.js
@@ -1,5 +1,5 @@
 /*
-  Highlight.js 10.6.0 (eb122d3b)
+  Highlight.js 10.6.0 (d24895f4)
   License: BSD-3-Clause
   Copyright (c) 2006-2020, Ivan Sagalaev
 */
@@ -7,19 +7,19 @@
 return t instanceof Map?t.clear=t.delete=t.set=()=>{
 throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=()=>{
 throw Error("set is read-only")
-}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach((n=>{var s=t[n]
-;"object"!=typeof s||Object.isFrozen(s)||e(s)})),t}var t=e,n=e;t.default=n
-;class s{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data}
+}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach((n=>{var i=t[n]
+;"object"!=typeof i||Object.isFrozen(i)||e(i)})),t}var t=e,n=e;t.default=n
+;class i{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data}
 ignoreMatch(){this.ignore=!0}}function r(e){
 return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")
-}function a(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t]
-;return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const i=e=>!!e.kind
-;class o{constructor(e,t){
+}function s(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t]
+;return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const a=e=>!!e.kind
+;class l{constructor(e,t){
 this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){
-this.buffer+=r(e)}openNode(e){if(!i(e))return;let t=e.kind
+this.buffer+=r(e)}openNode(e){if(!a(e))return;let t=e.kind
 ;e.sublanguage||(t=`${this.classPrefix}${t}`),this.span(t)}closeNode(e){
-i(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){
-this.buffer+=`<span class="${e}">`}}class l{constructor(){this.rootNode={
+a(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){
+this.buffer+=`<span class="${e}">`}}class o{constructor(){this.rootNode={
 children:[]},this.stack=[this.rootNode]}get top(){
 return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){
 this.top.children.push(e)}openNode(e){const t={kind:e,children:[]}
@@ -30,79 +30,78 @@
 return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),
 t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){
 "string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{
-l._collapse(e)})))}}class c extends l{constructor(e){super(),this.options=e}
+o._collapse(e)})))}}class c extends o{constructor(e){super(),this.options=e}
 addKeyword(e,t){""!==e&&(this.openNode(t),this.addText(e),this.closeNode())}
 addText(e){""!==e&&this.add(e)}addSublanguage(e,t){const n=e.root
 ;n.kind=t,n.sublanguage=!0,this.add(n)}toHTML(){
-return new o(this,this.options).value()}finalize(){return!0}}function u(e){
+return new l(this,this.options).value()}finalize(){return!0}}function g(e){
 return e?"string"==typeof e?e:e.source:null}
-const g="[a-zA-Z]\\w*",d="[a-zA-Z_]\\w*",h="\\b\\d+(\\.\\d+)?",f="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",p="\\b(0b[01]+)",m={
-begin:"\\\\[\\s\\S]",relevance:0},b={className:"string",begin:"'",end:"'",
-illegal:"\\n",contains:[m]},x={className:"string",begin:'"',end:'"',
-illegal:"\\n",contains:[m]},E={
+const u=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,d="[a-zA-Z]\\w*",h="[a-zA-Z_]\\w*",f="\\b\\d+(\\.\\d+)?",p="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",m="\\b(0b[01]+)",b={
+begin:"\\\\[\\s\\S]",relevance:0},E={className:"string",begin:"'",end:"'",
+illegal:"\\n",contains:[b]},x={className:"string",begin:'"',end:'"',
+illegal:"\\n",contains:[b]},v={
 begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
-},v=(e,t,n={})=>{const s=a({className:"comment",begin:e,end:t,contains:[]},n)
-;return s.contains.push(E),s.contains.push({className:"doctag",
-begin:"(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",relevance:0}),s
-},w=v("//","$"),N=v("/\\*","\\*/"),y=v("#","$");var R=Object.freeze({
-__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:g,UNDERSCORE_IDENT_RE:d,
-NUMBER_RE:h,C_NUMBER_RE:f,BINARY_NUMBER_RE:p,
+},w=(e,t,n={})=>{const i=s({className:"comment",begin:e,end:t,contains:[]},n)
+;return i.contains.push(v),i.contains.push({className:"doctag",
+begin:"(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",relevance:0}),i
+},y=w("//","$"),N=w("/\\*","\\*/"),R=w("#","$");var _=Object.freeze({
+__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:d,UNDERSCORE_IDENT_RE:h,
+NUMBER_RE:f,C_NUMBER_RE:p,BINARY_NUMBER_RE:m,
 RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",
 SHEBANG:(e={})=>{const t=/^#![ ]*\//
-;return e.binary&&(e.begin=((...e)=>e.map((e=>u(e))).join(""))(t,/.*\b/,e.binary,/\b.*/)),
-a({className:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{
-0!==e.index&&t.ignoreMatch()}},e)},BACKSLASH_ESCAPE:m,APOS_STRING_MODE:b,
-QUOTE_STRING_MODE:x,PHRASAL_WORDS_MODE:E,COMMENT:v,C_LINE_COMMENT_MODE:w,
-C_BLOCK_COMMENT_MODE:N,HASH_COMMENT_MODE:y,NUMBER_MODE:{className:"number",
-begin:h,relevance:0},C_NUMBER_MODE:{className:"number",begin:f,relevance:0},
-BINARY_NUMBER_MODE:{className:"number",begin:p,relevance:0},CSS_NUMBER_MODE:{
+;return e.binary&&(e.begin=((...e)=>e.map((e=>g(e))).join(""))(t,/.*\b/,e.binary,/\b.*/)),
+s({className:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{
+0!==e.index&&t.ignoreMatch()}},e)},BACKSLASH_ESCAPE:b,APOS_STRING_MODE:E,
+QUOTE_STRING_MODE:x,PHRASAL_WORDS_MODE:v,COMMENT:w,C_LINE_COMMENT_MODE:y,
+C_BLOCK_COMMENT_MODE:N,HASH_COMMENT_MODE:R,NUMBER_MODE:{className:"number",
+begin:f,relevance:0},C_NUMBER_MODE:{className:"number",begin:p,relevance:0},
+BINARY_NUMBER_MODE:{className:"number",begin:m,relevance:0},CSS_NUMBER_MODE:{
 className:"number",
-begin:h+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",
+begin:f+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",
 relevance:0},REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{className:"regexp",
-begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[m,{begin:/\[/,end:/\]/,
-relevance:0,contains:[m]}]}]},TITLE_MODE:{className:"title",begin:g,relevance:0
-},UNDERSCORE_TITLE_MODE:{className:"title",begin:d,relevance:0},METHOD_GUARD:{
+begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[b,{begin:/\[/,end:/\]/,
+relevance:0,contains:[b]}]}]},TITLE_MODE:{className:"title",begin:d,relevance:0
+},UNDERSCORE_TITLE_MODE:{className:"title",begin:h,relevance:0},METHOD_GUARD:{
 begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0},END_SAME_AS_BEGIN:e=>Object.assign(e,{
 "on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{
-t.data._beginMatch!==e[1]&&t.ignoreMatch()}})});function _(e,t){
-"."===e.input[e.index-1]&&t.ignoreMatch()}function k(e,t){
+t.data._beginMatch!==e[1]&&t.ignoreMatch()}})});function k(e,t){
+"."===e.input[e.index-1]&&t.ignoreMatch()}function O(e,t){
 t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",
-e.__beforeBegin=_,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,
-void 0===e.relevance&&(e.relevance=0))}function O(e,t){
-Array.isArray(e.illegal)&&(e.illegal=((...e)=>"("+e.map((e=>u(e))).join("|")+")")(...e.illegal))
-}function M(e,t){if(e.match){
+e.__beforeBegin=k,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,
+void 0===e.relevance&&(e.relevance=0))}function M(e,t){
+Array.isArray(e.illegal)&&(e.illegal=((...e)=>"("+e.map((e=>g(e))).join("|")+")")(...e.illegal))
+}function A(e,t){if(e.match){
 if(e.begin||e.end)throw Error("begin & end are not supported with match")
-;e.begin=e.match,delete e.match}}function A(e,t){
+;e.begin=e.match,delete e.match}}function L(e,t){
 void 0===e.relevance&&(e.relevance=1)}
-const L=["of","and","for","in","not","or","if","then","parent","list","value"]
-;function B(e,t,n="keyword"){const s={}
+const j=["of","and","for","in","not","or","if","then","parent","list","value"]
+;function B(e,t,n="keyword"){const i={}
 ;return"string"==typeof e?r(n,e.split(" ")):Array.isArray(e)?r(n,e):Object.keys(e).forEach((n=>{
-Object.assign(s,B(e[n],t,n))})),s;function r(e,n){
+Object.assign(i,B(e[n],t,n))})),i;function r(e,n){
 t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((t=>{const n=t.split("|")
-;s[n[0]]=[e,I(n[0],n[1])]}))}}function I(e,t){
-return t?Number(t):(e=>L.includes(e.toLowerCase()))(e)?0:1}
+;i[n[0]]=[e,I(n[0],n[1])]}))}}function I(e,t){
+return t?Number(t):(e=>j.includes(e.toLowerCase()))(e)?0:1}
 function T(e,{plugins:t}){function n(t,n){
-return RegExp(u(t),"m"+(e.case_insensitive?"i":"")+(n?"g":""))}class s{
+return RegExp(g(t),"m"+(e.case_insensitive?"i":"")+(n?"g":""))}class i{
 constructor(){
 this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}
 addRule(e,t){
 t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),
 this.matchAt+=(e=>RegExp(e.toString()+"|").exec("").length-1)(e)+1}compile(){
 0===this.regexes.length&&(this.exec=()=>null)
-;const e=this.regexes.map((e=>e[1]));this.matcherRe=n(((e,t="|")=>{
-const n=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;let s=0,r=""
-;for(let a=0;a<e.length;a++){s+=1;const i=s;let o=u(e[a])
-;for(a>0&&(r+=t),r+="(";o.length>0;){const e=n.exec(o);if(null==e){r+=o;break}
-r+=o.substring(0,e.index),
-o=o.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?r+="\\"+(Number(e[1])+i):(r+=e[0],
-"("===e[0]&&s++)}r+=")"}return r})(e),!0),this.lastIndex=0}exec(e){
+;const e=this.regexes.map((e=>e[1]));this.matcherRe=n(((e,t="|")=>{let n=0
+;return e.map((e=>{n+=1;const t=n;let i=g(e),r="";for(;i.length>0;){
+const e=u.exec(i);if(!e){r+=i;break}
+r+=i.substring(0,e.index),i=i.substring(e.index+e[0].length),
+"\\"===e[0][0]&&e[1]?r+="\\"+(Number(e[1])+t):(r+=e[0],"("===e[0]&&n++)}return r
+})).map((e=>`(${e})`)).join(t)})(e),!0),this.lastIndex=0}exec(e){
 this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e)
 ;if(!t)return null
-;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),s=this.matchIndexes[n]
-;return t.splice(0,n),Object.assign(t,s)}}class r{constructor(){
+;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),i=this.matchIndexes[n]
+;return t.splice(0,n),Object.assign(t,i)}}class r{constructor(){
 this.rules=[],this.multiRegexes=[],
 this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){
-if(this.multiRegexes[e])return this.multiRegexes[e];const t=new s
+if(this.multiRegexes[e])return this.multiRegexes[e];const t=new i
 ;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),
 t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){
 return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){
@@ -115,30 +114,30 @@
 this.regexIndex===this.count&&this.considerAll()),n}}
 if(e.compilerExtensions||(e.compilerExtensions=[]),
 e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language.  See documentation.")
-;return e.classNameAliases=a(e.classNameAliases||{}),function t(s,i){const o=s
-;if(s.compiled)return o
-;[M].forEach((e=>e(s,i))),e.compilerExtensions.forEach((e=>e(s,i))),
-s.__beforeBegin=null,[k,O,A].forEach((e=>e(s,i))),s.compiled=!0;let l=null
-;if("object"==typeof s.keywords&&(l=s.keywords.$pattern,
-delete s.keywords.$pattern),
-s.keywords&&(s.keywords=B(s.keywords,e.case_insensitive)),
-s.lexemes&&l)throw Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ")
-;return l=l||s.lexemes||/\w+/,
-o.keywordPatternRe=n(l,!0),i&&(s.begin||(s.begin=/\B|\b/),
-o.beginRe=n(s.begin),s.endSameAsBegin&&(s.end=s.begin),
-s.end||s.endsWithParent||(s.end=/\B|\b/),
-s.end&&(o.endRe=n(s.end)),o.terminatorEnd=u(s.end)||"",
-s.endsWithParent&&i.terminatorEnd&&(o.terminatorEnd+=(s.end?"|":"")+i.terminatorEnd)),
-s.illegal&&(o.illegalRe=n(s.illegal)),
-s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>a(e,{
-variants:null},t)))),e.cachedVariants?e.cachedVariants:j(e)?a(e,{
-starts:e.starts?a(e.starts):null
-}):Object.isFrozen(e)?a(e):e))("self"===e?s:e)))),s.contains.forEach((e=>{t(e,o)
-})),s.starts&&t(s.starts,i),o.matcher=(e=>{const t=new r
+;return e.classNameAliases=s(e.classNameAliases||{}),function t(i,a){const l=i
+;if(i.compiled)return l
+;[A].forEach((e=>e(i,a))),e.compilerExtensions.forEach((e=>e(i,a))),
+i.__beforeBegin=null,[O,M,L].forEach((e=>e(i,a))),i.compiled=!0;let o=null
+;if("object"==typeof i.keywords&&(o=i.keywords.$pattern,
+delete i.keywords.$pattern),
+i.keywords&&(i.keywords=B(i.keywords,e.case_insensitive)),
+i.lexemes&&o)throw Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ")
+;return o=o||i.lexemes||/\w+/,
+l.keywordPatternRe=n(o,!0),a&&(i.begin||(i.begin=/\B|\b/),
+l.beginRe=n(i.begin),i.endSameAsBegin&&(i.end=i.begin),
+i.end||i.endsWithParent||(i.end=/\B|\b/),
+i.end&&(l.endRe=n(i.end)),l.terminatorEnd=g(i.end)||"",
+i.endsWithParent&&a.terminatorEnd&&(l.terminatorEnd+=(i.end?"|":"")+a.terminatorEnd)),
+i.illegal&&(l.illegalRe=n(i.illegal)),
+i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>s(e,{
+variants:null},t)))),e.cachedVariants?e.cachedVariants:S(e)?s(e,{
+starts:e.starts?s(e.starts):null
+}):Object.isFrozen(e)?s(e):e))("self"===e?i:e)))),i.contains.forEach((e=>{t(e,l)
+})),i.starts&&t(i.starts,a),l.matcher=(e=>{const t=new r
 ;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"
 }))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"
-}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(o),o}(e)}function j(e){
-return!!e&&(e.endsWithParent||j(e.starts))}function S(e){const t={
+}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(l),l}(e)}function S(e){
+return!!e&&(e.endsWithParent||S(e.starts))}function P(e){const t={
 props:["language","code","autodetect"],data:()=>({detectedLanguage:"",
 unknownLanguage:!1}),computed:{className(){
 return this.unknownLanguage?"":"hljs "+this.detectedLanguage},highlighted(){
@@ -150,149 +149,157 @@
 return!(this.language&&(e=this.autodetect,!e&&""!==e));var e},
 ignoreIllegals:()=>!0},render(e){return e("pre",{},[e("code",{
 class:this.className,domProps:{innerHTML:this.highlighted}})])}};return{
-Component:t,VuePlugin:{install(e){e.component("highlightjs",t)}}}}const P={
-"after:highlightBlock":({block:e,result:t,text:n})=>{const s=C(e)
-;if(!s.length)return;const a=document.createElement("div")
-;a.innerHTML=t.value,t.value=((e,t,n)=>{let s=0,a="";const i=[];function o(){
+Component:t,VuePlugin:{install(e){e.component("highlightjs",t)}}}}const D={
+"after:highlightElement":({el:e,result:t,text:n})=>{const i=H(e)
+;if(!i.length)return;const s=document.createElement("div")
+;s.innerHTML=t.value,t.value=((e,t,n)=>{let i=0,s="";const a=[];function l(){
 return e.length&&t.length?e[0].offset!==t[0].offset?e[0].offset<t[0].offset?e:t:"start"===t[0].event?e:t:e.length?e:t
-}function l(e){a+="<"+D(e)+[].map.call(e.attributes,(function(e){
+}function o(e){s+="<"+C(e)+[].map.call(e.attributes,(function(e){
 return" "+e.nodeName+'="'+r(e.value)+'"'})).join("")+">"}function c(e){
-a+="</"+D(e)+">"}function u(e){("start"===e.event?l:c)(e.node)}
-for(;e.length||t.length;){let t=o()
-;if(a+=r(n.substring(s,t[0].offset)),s=t[0].offset,t===e){i.reverse().forEach(c)
-;do{u(t.splice(0,1)[0]),t=o()}while(t===e&&t.length&&t[0].offset===s)
-;i.reverse().forEach(l)
-}else"start"===t[0].event?i.push(t[0].node):i.pop(),u(t.splice(0,1)[0])}
-return a+r(n.substr(s))})(s,C(a),n)}};function D(e){
-return e.nodeName.toLowerCase()}function C(e){const t=[];return function e(n,s){
-for(let r=n.firstChild;r;r=r.nextSibling)3===r.nodeType?s+=r.nodeValue.length:1===r.nodeType&&(t.push({
-event:"start",offset:s,node:r}),s=e(r,s),D(r).match(/br|hr|img|input/)||t.push({
-event:"stop",offset:s,node:r}));return s}(e,0),t}const H=e=>{console.error(e)
-},U=(e,...t)=>{console.log("WARN: "+e,...t)},$=(e,t)=>{
-console.log(`Deprecated as of ${e}. ${t}`)},z=r,K=a,G=Symbol("nomatch")
-;return(e=>{const n=Object.create(null),r=Object.create(null),a=[];let i=!0
-;const o=/(^(<[^>]+>|\t|)+|\n)/gm,l="Could not find the language '{}', did you forget to load/include a language module?",u={
-disableAutodetect:!0,name:"Plain text",contains:[]};let g={
+s+="</"+C(e)+">"}function g(e){("start"===e.event?o:c)(e.node)}
+for(;e.length||t.length;){let t=l()
+;if(s+=r(n.substring(i,t[0].offset)),i=t[0].offset,t===e){a.reverse().forEach(c)
+;do{g(t.splice(0,1)[0]),t=l()}while(t===e&&t.length&&t[0].offset===i)
+;a.reverse().forEach(o)
+}else"start"===t[0].event?a.push(t[0].node):a.pop(),g(t.splice(0,1)[0])}
+return s+r(n.substr(i))})(i,H(s),n)}};function C(e){
+return e.nodeName.toLowerCase()}function H(e){const t=[];return function e(n,i){
+for(let r=n.firstChild;r;r=r.nextSibling)3===r.nodeType?i+=r.nodeValue.length:1===r.nodeType&&(t.push({
+event:"start",offset:i,node:r}),i=e(r,i),C(r).match(/br|hr|img|input/)||t.push({
+event:"stop",offset:i,node:r}));return i}(e,0),t}const $=e=>{console.error(e)
+},U=(e,...t)=>{console.log("WARN: "+e,...t)},z=(e,t)=>{
+console.log(`Deprecated as of ${e}. ${t}`)},K=r,G=s,V=Symbol("nomatch")
+;return(e=>{const n=Object.create(null),r=Object.create(null),s=[];let a=!0
+;const l=/(^(<[^>]+>|\t|)+|\n)/gm,o="Could not find the language '{}', did you forget to load/include a language module?",g={
+disableAutodetect:!0,name:"Plain text",contains:[]};let u={
 noHighlightRe:/^(no-?highlight)$/i,
 languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",
 tabReplace:null,useBR:!1,languages:null,__emitter:c};function d(e){
-return g.noHighlightRe.test(e)}function h(e,t,n,s){const r={code:t,language:e}
-;M("before:highlight",r);const a=r.result?r.result:f(r.language,r.code,n,s)
-;return a.code=r.code,M("after:highlight",a),a}function f(e,t,r,o){const c=t
-;function u(e,t){const n=w.case_insensitive?t[0].toLowerCase():t[0]
+return u.noHighlightRe.test(e)}function h(e,t,n,i){const r={code:t,language:e}
+;M("before:highlight",r);const s=r.result?r.result:f(r.language,r.code,n,i)
+;return s.code=r.code,M("after:highlight",s),s}function f(e,t,r,l){const c=t
+;function g(e,t){const n=w.case_insensitive?t[0].toLowerCase():t[0]
 ;return Object.prototype.hasOwnProperty.call(e.keywords,n)&&e.keywords[n]}
-function d(){null!=R.subLanguage?(()=>{if(""===M)return;let e=null
-;if("string"==typeof R.subLanguage){
-if(!n[R.subLanguage])return void O.addText(M)
-;e=f(R.subLanguage,M,!0,k[R.subLanguage]),k[R.subLanguage]=e.top
-}else e=p(M,R.subLanguage.length?R.subLanguage:null)
-;R.relevance>0&&(A+=e.relevance),O.addSublanguage(e.emitter,e.language)
-})():(()=>{if(!R.keywords)return void O.addText(M);let e=0
-;R.keywordPatternRe.lastIndex=0;let t=R.keywordPatternRe.exec(M),n="";for(;t;){
-n+=M.substring(e,t.index);const s=u(R,t);if(s){const[e,r]=s
-;O.addText(n),n="",A+=r;const a=w.classNameAliases[e]||e;O.addKeyword(t[0],a)
-}else n+=t[0];e=R.keywordPatternRe.lastIndex,t=R.keywordPatternRe.exec(M)}
+function d(){null!=_.subLanguage?(()=>{if(""===M)return;let e=null
+;if("string"==typeof _.subLanguage){
+if(!n[_.subLanguage])return void O.addText(M)
+;e=f(_.subLanguage,M,!0,k[_.subLanguage]),k[_.subLanguage]=e.top
+}else e=p(M,_.subLanguage.length?_.subLanguage:null)
+;_.relevance>0&&(A+=e.relevance),O.addSublanguage(e.emitter,e.language)
+})():(()=>{if(!_.keywords)return void O.addText(M);let e=0
+;_.keywordPatternRe.lastIndex=0;let t=_.keywordPatternRe.exec(M),n="";for(;t;){
+n+=M.substring(e,t.index);const i=g(_,t);if(i){const[e,r]=i
+;O.addText(n),n="",A+=r;const s=w.classNameAliases[e]||e;O.addKeyword(t[0],s)
+}else n+=t[0];e=_.keywordPatternRe.lastIndex,t=_.keywordPatternRe.exec(M)}
 n+=M.substr(e),O.addText(n)})(),M=""}function h(e){
 return e.className&&O.openNode(w.classNameAliases[e.className]||e.className),
-R=Object.create(e,{parent:{value:R}}),R}function m(e,t,n){let r=((e,t)=>{
+_=Object.create(e,{parent:{value:_}}),_}function m(e,t,n){let r=((e,t)=>{
 const n=e&&e.exec(t);return n&&0===n.index})(e.endRe,n);if(r){if(e["on:end"]){
-const n=new s(e);e["on:end"](t,n),n.ignore&&(r=!1)}if(r){
+const n=new i(e);e["on:end"](t,n),n.ignore&&(r=!1)}if(r){
 for(;e.endsParent&&e.parent;)e=e.parent;return e}}
 if(e.endsWithParent)return m(e.parent,t,n)}function b(e){
-return 0===R.matcher.regexIndex?(M+=e[0],1):(I=!0,0)}function x(e){
-const t=e[0],n=c.substr(e.index),s=m(R,e,n);if(!s)return G;const r=R
+return 0===_.matcher.regexIndex?(M+=e[0],1):(B=!0,0)}function E(e){
+const t=e[0],n=c.substr(e.index),i=m(_,e,n);if(!i)return V;const r=_
 ;r.skip?M+=t:(r.returnEnd||r.excludeEnd||(M+=t),d(),r.excludeEnd&&(M=t));do{
-R.className&&O.closeNode(),R.skip||R.subLanguage||(A+=R.relevance),R=R.parent
-}while(R!==s.parent)
-;return s.starts&&(s.endSameAsBegin&&(s.starts.endRe=s.endRe),
-h(s.starts)),r.returnEnd?0:t.length}let E={};function v(t,n){const a=n&&n[0]
-;if(M+=t,null==a)return d(),0
-;if("begin"===E.type&&"end"===n.type&&E.index===n.index&&""===a){
-if(M+=c.slice(n.index,n.index+1),!i){const t=Error("0 width match regex")
-;throw t.languageName=e,t.badRule=E.rule,t}return 1}
-if(E=n,"begin"===n.type)return function(e){
-const t=e[0],n=e.rule,r=new s(n),a=[n.__beforeBegin,n["on:begin"]]
-;for(const n of a)if(n&&(n(e,r),r.ignore))return b(t)
+_.className&&O.closeNode(),_.skip||_.subLanguage||(A+=_.relevance),_=_.parent
+}while(_!==i.parent)
+;return i.starts&&(i.endSameAsBegin&&(i.starts.endRe=i.endRe),
+h(i.starts)),r.returnEnd?0:t.length}let x={};function v(t,n){const s=n&&n[0]
+;if(M+=t,null==s)return d(),0
+;if("begin"===x.type&&"end"===n.type&&x.index===n.index&&""===s){
+if(M+=c.slice(n.index,n.index+1),!a){const t=Error("0 width match regex")
+;throw t.languageName=e,t.badRule=x.rule,t}return 1}
+if(x=n,"begin"===n.type)return function(e){
+const t=e[0],n=e.rule,r=new i(n),s=[n.__beforeBegin,n["on:begin"]]
+;for(const n of s)if(n&&(n(e,r),r.ignore))return b(t)
 ;return n&&n.endSameAsBegin&&(n.endRe=RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"m")),
 n.skip?M+=t:(n.excludeBegin&&(M+=t),
 d(),n.returnBegin||n.excludeBegin||(M=t)),h(n),n.returnBegin?0:t.length}(n)
 ;if("illegal"===n.type&&!r){
-const e=Error('Illegal lexeme "'+a+'" for mode "'+(R.className||"<unnamed>")+'"')
-;throw e.mode=R,e}if("end"===n.type){const e=x(n);if(e!==G)return e}
-if("illegal"===n.type&&""===a)return 1
-;if(B>1e5&&B>3*n.index)throw Error("potential infinite loop, way more iterations than matches")
-;return M+=a,a.length}const w=_(e)
-;if(!w)throw H(l.replace("{}",e)),Error('Unknown language: "'+e+'"')
-;const N=T(w,{plugins:a});let y="",R=o||N;const k={},O=new g.__emitter(g);(()=>{
-const e=[];for(let t=R;t!==w;t=t.parent)t.className&&e.unshift(t.className)
-;e.forEach((e=>O.openNode(e)))})();let M="",A=0,L=0,B=0,I=!1;try{
-for(R.matcher.considerAll();;){
-B++,I?I=!1:R.matcher.considerAll(),R.matcher.lastIndex=L
-;const e=R.matcher.exec(c);if(!e)break;const t=v(c.substring(L,e.index),e)
-;L=e.index+t}return v(c.substr(L)),O.closeAllNodes(),O.finalize(),y=O.toHTML(),{
-relevance:Math.floor(A),value:y,language:e,illegal:!1,emitter:O,top:R}}catch(t){
+const e=Error('Illegal lexeme "'+s+'" for mode "'+(_.className||"<unnamed>")+'"')
+;throw e.mode=_,e}if("end"===n.type){const e=E(n);if(e!==V)return e}
+if("illegal"===n.type&&""===s)return 1
+;if(j>1e5&&j>3*n.index)throw Error("potential infinite loop, way more iterations than matches")
+;return M+=s,s.length}const w=R(e)
+;if(!w)throw $(o.replace("{}",e)),Error('Unknown language: "'+e+'"')
+;const y=T(w,{plugins:s});let N="",_=l||y;const k={},O=new u.__emitter(u);(()=>{
+const e=[];for(let t=_;t!==w;t=t.parent)t.className&&e.unshift(t.className)
+;e.forEach((e=>O.openNode(e)))})();let M="",A=0,L=0,j=0,B=!1;try{
+for(_.matcher.considerAll();;){
+j++,B?B=!1:_.matcher.considerAll(),_.matcher.lastIndex=L
+;const e=_.matcher.exec(c);if(!e)break;const t=v(c.substring(L,e.index),e)
+;L=e.index+t}return v(c.substr(L)),O.closeAllNodes(),O.finalize(),N=O.toHTML(),{
+relevance:Math.floor(A),value:N,language:e,illegal:!1,emitter:O,top:_}}catch(t){
 if(t.message&&t.message.includes("Illegal"))return{illegal:!0,illegalBy:{
-msg:t.message,context:c.slice(L-100,L+100),mode:t.mode},sofar:y,relevance:0,
-value:z(c),emitter:O};if(i)return{illegal:!1,relevance:0,value:z(c),emitter:O,
-language:e,top:R,errorRaised:t};throw t}}function p(e,t){
-t=t||g.languages||Object.keys(n);const s=(e=>{const t={relevance:0,
-emitter:new g.__emitter(g),value:z(e),illegal:!1,top:u}
-;return t.emitter.addText(e),t})(e),r=t.filter(_).filter(O).map((t=>f(t,e,!1)))
-;r.unshift(s);const a=r.sort(((e,t)=>{
+msg:t.message,context:c.slice(L-100,L+100),mode:t.mode},sofar:N,relevance:0,
+value:K(c),emitter:O};if(a)return{illegal:!1,relevance:0,value:K(c),emitter:O,
+language:e,top:_,errorRaised:t};throw t}}function p(e,t){
+t=t||u.languages||Object.keys(n);const i=(e=>{const t={relevance:0,
+emitter:new u.__emitter(u),value:K(e),illegal:!1,top:g}
+;return t.emitter.addText(e),t})(e),r=t.filter(R).filter(O).map((t=>f(t,e,!1)))
+;r.unshift(i);const s=r.sort(((e,t)=>{
 if(e.relevance!==t.relevance)return t.relevance-e.relevance
-;if(e.language&&t.language){if(_(e.language).supersetOf===t.language)return 1
-;if(_(t.language).supersetOf===e.language)return-1}return 0})),[i,o]=a,l=i
-;return l.second_best=o,l}const m={"before:highlightBlock":({block:e})=>{
-g.useBR&&(e.innerHTML=e.innerHTML.replace(/\n/g,"").replace(/<br[ /]*>/g,"\n"))
-},"after:highlightBlock":({result:e})=>{
-g.useBR&&(e.value=e.value.replace(/\n/g,"<br>"))}},b=/^(<[^>]+>|\t)+/gm,x={
-"after:highlightBlock":({result:e})=>{
-g.tabReplace&&(e.value=e.value.replace(b,(e=>e.replace(/\t/g,g.tabReplace))))}}
-;function E(e){let t=null;const n=(e=>{let t=e.className+" "
-;t+=e.parentNode?e.parentNode.className:"";const n=g.languageDetectRe.exec(t)
-;if(n){const t=_(n[1])
-;return t||(U(l.replace("{}",n[1])),U("Falling back to no-highlight mode for this block.",e)),
-t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>d(e)||_(e)))})(e)
-;if(d(n))return;M("before:highlightBlock",{block:e,language:n}),t=e
-;const s=t.textContent,a=n?h(n,s,!0):p(s);M("after:highlightBlock",{block:e,
-result:a,text:s}),e.innerHTML=a.value,((e,t,n)=>{const s=t?r[t]:n
-;e.classList.add("hljs"),s&&e.classList.add(s)})(e,n,a.language),e.result={
-language:a.language,re:a.relevance,relavance:a.relevance
-},a.second_best&&(e.second_best={language:a.second_best.language,
-re:a.second_best.relevance,relavance:a.second_best.relevance})}const v=()=>{
+;if(e.language&&t.language){if(R(e.language).supersetOf===t.language)return 1
+;if(R(t.language).supersetOf===e.language)return-1}return 0})),[a,l]=s,o=a
+;return o.second_best=l,o}const m={"before:highlightElement":({el:e})=>{
+u.useBR&&(e.innerHTML=e.innerHTML.replace(/\n/g,"").replace(/<br[ /]*>/g,"\n"))
+},"after:highlightElement":({result:e})=>{
+u.useBR&&(e.value=e.value.replace(/\n/g,"<br>"))}},b=/^(<[^>]+>|\t)+/gm,E={
+"after:highlightElement":({result:e})=>{
+u.tabReplace&&(e.value=e.value.replace(b,(e=>e.replace(/\t/g,u.tabReplace))))}}
+;function x(e){let t=null;const n=(e=>{let t=e.className+" "
+;t+=e.parentNode?e.parentNode.className:"";const n=u.languageDetectRe.exec(t)
+;if(n){const t=R(n[1])
+;return t||(U(o.replace("{}",n[1])),U("Falling back to no-highlight mode for this block.",e)),
+t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>d(e)||R(e)))})(e)
+;if(d(n))return;M("before:highlightElement",{el:e,language:n}),t=e
+;const i=t.textContent,s=n?h(n,i,!0):p(i);M("after:highlightElement",{el:e,
+result:s,text:i}),e.innerHTML=s.value,((e,t,n)=>{const i=t?r[t]:n
+;e.classList.add("hljs"),i&&e.classList.add(i)})(e,n,s.language),e.result={
+language:s.language,re:s.relevance,relavance:s.relevance
+},s.second_best&&(e.second_best={language:s.second_best.language,
+re:s.second_best.relevance,relavance:s.second_best.relevance})}const v=()=>{
 v.called||(v.called=!0,
-$("10.6.0","initHighlighting() is deprecated.  Use highlightAll() instead."),
-document.querySelectorAll("pre code").forEach(E))};let w=!1,N=!1;function y(){
-N?document.querySelectorAll("pre code").forEach(E):w=!0}function _(e){
+z("10.6.0","initHighlighting() is deprecated.  Use highlightAll() instead."),
+document.querySelectorAll("pre code").forEach(x))};let w=!1,y=!1;function N(){
+y?document.querySelectorAll("pre code").forEach(x):w=!0}function R(e){
 return e=(e||"").toLowerCase(),n[e]||n[r[e]]}function k(e,{languageName:t}){
-"string"==typeof e&&(e=[e]),e.forEach((e=>{r[e]=t}))}function O(e){const t=_(e)
-;return t&&!t.disableAutodetect}function M(e,t){const n=e;a.forEach((e=>{
-e[n]&&e[n](t)}))}
+"string"==typeof e&&(e=[e]),e.forEach((e=>{r[e.toLowerCase()]=t}))}
+function O(e){const t=R(e);return t&&!t.disableAutodetect}function M(e,t){
+const n=e;s.forEach((e=>{e[n]&&e[n](t)}))}
 "undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(()=>{
-N=!0,w&&y()}),!1),Object.assign(e,{highlight:h,highlightAuto:p,highlightAll:y,
+y=!0,w&&N()}),!1),Object.assign(e,{highlight:h,highlightAuto:p,highlightAll:N,
 fixMarkup:e=>{
-return $("10.2.0","fixMarkup will be removed entirely in v11.0"),$("10.2.0","Please see https://github.com/highlightjs/highlight.js/issues/2534"),
+return z("10.2.0","fixMarkup will be removed entirely in v11.0"),z("10.2.0","Please see https://github.com/highlightjs/highlight.js/issues/2534"),
 t=e,
-g.tabReplace||g.useBR?t.replace(o,(e=>"\n"===e?g.useBR?"<br>":e:g.tabReplace?e.replace(/\t/g,g.tabReplace):e)):t
-;var t},highlightBlock:E,configure:e=>{
-e.useBR&&($("10.3.0","'useBR' will be removed entirely in v11.0"),
-$("10.3.0","Please see https://github.com/highlightjs/highlight.js/issues/2559")),
-g=K(g,e)},initHighlighting:v,initHighlightingOnLoad:()=>{
-$("10.6.0","initHighlightingOnLoad() is deprecated.  Use highlightAll() instead."),
-w=!0},registerLanguage:(t,s)=>{let r=null;try{r=s(e)}catch(e){
-if(H("Language definition for '{}' could not be registered.".replace("{}",t)),
-!i)throw e;H(e),r=u}
-r.name||(r.name=t),n[t]=r,r.rawDefinition=s.bind(null,e),r.aliases&&k(r.aliases,{
-languageName:t})},listLanguages:()=>Object.keys(n),getLanguage:_,
-registerAliases:k,requireLanguage:e=>{
-$("10.4.0","requireLanguage will be removed entirely in v11."),
-$("10.4.0","Please see https://github.com/highlightjs/highlight.js/pull/2844")
-;const t=_(e);if(t)return t
+u.tabReplace||u.useBR?t.replace(l,(e=>"\n"===e?u.useBR?"<br>":e:u.tabReplace?e.replace(/\t/g,u.tabReplace):e)):t
+;var t},highlightElement:x,
+highlightBlock:e=>(z("10.7.0","highlightBlock will be removed entirely in v12.0"),
+z("10.7.0","Please use highlightElement now."),x(e)),configure:e=>{
+e.useBR&&(z("10.3.0","'useBR' will be removed entirely in v11.0"),
+z("10.3.0","Please see https://github.com/highlightjs/highlight.js/issues/2559")),
+u=G(u,e)},initHighlighting:v,initHighlightingOnLoad:()=>{
+z("10.6.0","initHighlightingOnLoad() is deprecated.  Use highlightAll() instead."),
+w=!0},registerLanguage:(t,i)=>{let r=null;try{r=i(e)}catch(e){
+if($("Language definition for '{}' could not be registered.".replace("{}",t)),
+!a)throw e;$(e),r=g}
+r.name||(r.name=t),n[t]=r,r.rawDefinition=i.bind(null,e),r.aliases&&k(r.aliases,{
+languageName:t})},unregisterLanguage:e=>{delete n[e]
+;for(const t of Object.keys(r))r[t]===e&&delete r[t]},
+listLanguages:()=>Object.keys(n),getLanguage:R,registerAliases:k,
+requireLanguage:e=>{
+z("10.4.0","requireLanguage will be removed entirely in v11."),
+z("10.4.0","Please see https://github.com/highlightjs/highlight.js/pull/2844")
+;const t=R(e);if(t)return t
 ;throw Error("The '{}' language is required, but not loaded.".replace("{}",e))},
-autoDetection:O,inherit:K,addPlugin:e=>{a.push(e)},vuePlugin:S(e).VuePlugin
-}),e.debugMode=()=>{i=!1},e.safeMode=()=>{i=!0},e.versionString="10.6.0"
-;for(const e in R)"object"==typeof R[e]&&t(R[e])
-;return Object.assign(e,R),e.addPlugin(m),e.addPlugin(P),e.addPlugin(x),e})({})
+autoDetection:O,inherit:G,addPlugin:e=>{(e=>{
+e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{
+e["before:highlightBlock"](Object.assign({block:t.el},t))
+}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{
+e["after:highlightBlock"](Object.assign({block:t.el},t))})})(e),s.push(e)},
+vuePlugin:P(e).VuePlugin}),e.debugMode=()=>{a=!1},e.safeMode=()=>{a=!0
+},e.versionString="10.6.0";for(const e in _)"object"==typeof _[e]&&t(_[e])
+;return Object.assign(e,_),e.addPlugin(m),e.addPlugin(D),e.addPlugin(E),e})({})
 }();"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs);
 hljs.registerLanguage("1c",(()=>{"use strict";return s=>{
 var x="[A-Za-z\u0410-\u042f\u0430-\u044f\u0451\u0401_][A-Za-z\u0410-\u042f\u0430-\u044f\u0451\u0401_0-9]+",n="\u0434\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u0435\u0441\u043b\u0438 \u0438 \u0438\u0437 \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0438\u043d\u0430\u0447\u0435\u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u0435\u0446\u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0446\u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043a\u043e\u043d\u0435\u0446\u0446\u0438\u043a\u043b\u0430 \u043d\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043f\u0435\u0440\u0435\u043c \u043f\u043e \u043f\u043e\u043a\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0442\u043e\u0433\u0434\u0430 \u0446\u0438\u043a\u043b \u044d\u043a\u0441\u043f\u043e\u0440\u0442 ",e="null \u0438\u0441\u0442\u0438\u043d\u0430 \u043b\u043e\u0436\u044c \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e",o=s.inherit(s.NUMBER_MODE),t={
@@ -492,11 +499,11 @@
 relevance:0},g={className:"function",begin:"("+i+"[\\*&\\s]+)+"+d,
 returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:u,illegal:/[^\w\s\*&:<>.]/,
 contains:[{begin:"decltype\\(auto\\)",keywords:u,relevance:0},{begin:d,
-returnBegin:!0,contains:[c],relevance:0},{className:"params",begin:/\(/,
-end:/\)/,keywords:u,relevance:0,contains:[r,t.C_BLOCK_COMMENT_MODE,s,o,a,{
-begin:/\(/,end:/\)/,keywords:u,relevance:0,
-contains:["self",r,t.C_BLOCK_COMMENT_MODE,s,o,a]}]
-},a,r,t.C_BLOCK_COMMENT_MODE,l]};return{name:"C++",
+returnBegin:!0,contains:[c],relevance:0},{begin:/::/,relevance:0},{begin:/:/,
+endsWithParent:!0,contains:[s,o]},{className:"params",begin:/\(/,end:/\)/,
+keywords:u,relevance:0,contains:[r,t.C_BLOCK_COMMENT_MODE,s,o,a,{begin:/\(/,
+end:/\)/,keywords:u,relevance:0,contains:["self",r,t.C_BLOCK_COMMENT_MODE,s,o,a]
+}]},a,r,t.C_BLOCK_COMMENT_MODE,l]};return{name:"C++",
 aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:u,illegal:"</",
 contains:[].concat(p,g,m,[l,{
 begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",
@@ -639,11 +646,11 @@
 contains:[{begin:/""/,relevance:0}]},{begin:/'/,end:/'/,contains:[{begin:/''/,
 relevance:0}]}]},n={variants:[e.BINARY_NUMBER_MODE,e.C_NUMBER_MODE]};return{
 name:"AutoIt",case_insensitive:!0,illegal:/\/\*/,keywords:{
-keyword:"ByRef Case Const ContinueCase ContinueLoop Default Dim Do Else ElseIf EndFunc EndIf EndSelect EndSwitch EndWith Enum Exit ExitLoop For Func Global If In Local Next ReDim Return Select Static Step Switch Then To Until Volatile WEnd While With",
-built_in:"Abs ACos AdlibRegister AdlibUnRegister Asc AscW ASin Assign ATan AutoItSetOption AutoItWinGetTitle AutoItWinSetTitle Beep Binary BinaryLen BinaryMid BinaryToString BitAND BitNOT BitOR BitRotate BitShift BitXOR BlockInput Break Call CDTray Ceiling Chr ChrW ClipGet ClipPut ConsoleRead ConsoleWrite ConsoleWriteError ControlClick ControlCommand ControlDisable ControlEnable ControlFocus ControlGetFocus ControlGetHandle ControlGetPos ControlGetText ControlHide ControlListView ControlMove ControlSend ControlSetText ControlShow ControlTreeView Cos Dec DirCopy DirCreate DirGetSize DirMove DirRemove DllCall DllCallAddress DllCallbackFree DllCallbackGetPtr DllCallbackRegister DllClose DllOpen DllStructCreate DllStructGetData DllStructGetPtr DllStructGetSize DllStructSetData DriveGetDrive DriveGetFileSystem DriveGetLabel DriveGetSerial DriveGetType DriveMapAdd DriveMapDel DriveMapGet DriveSetLabel DriveSpaceFree DriveSpaceTotal DriveStatus EnvGet EnvSet EnvUpdate Eval Execute Exp FileChangeDir FileClose FileCopy FileCreateNTFSLink FileCreateShortcut FileDelete FileExists FileFindFirstFile FileFindNextFile FileFlush FileGetAttrib FileGetEncoding FileGetLongName FileGetPos FileGetShortcut FileGetShortName FileGetSize FileGetTime FileGetVersion FileInstall FileMove FileOpen FileOpenDialog FileRead FileReadLine FileReadToArray FileRecycle FileRecycleEmpty FileSaveDialog FileSelectFolder FileSetAttrib FileSetEnd FileSetPos FileSetTime FileWrite FileWriteLine Floor FtpSetProxy FuncName GUICreate GUICtrlCreateAvi GUICtrlCreateButton GUICtrlCreateCheckbox GUICtrlCreateCombo GUICtrlCreateContextMenu GUICtrlCreateDate GUICtrlCreateDummy GUICtrlCreateEdit GUICtrlCreateGraphic GUICtrlCreateGroup GUICtrlCreateIcon GUICtrlCreateInput GUICtrlCreateLabel GUICtrlCreateList GUICtrlCreateListView GUICtrlCreateListViewItem GUICtrlCreateMenu GUICtrlCreateMenuItem GUICtrlCreateMonthCal GUICtrlCreateObj GUICtrlCreatePic GUICtrlCreateProgress GUICtrlCreateRadio GUICtrlCreateSlider GUICtrlCreateTab GUICtrlCreateTabItem GUICtrlCreateTreeView GUICtrlCreateTreeViewItem GUICtrlCreateUpdown GUICtrlDelete GUICtrlGetHandle GUICtrlGetState GUICtrlRead GUICtrlRecvMsg GUICtrlRegisterListViewSort GUICtrlSendMsg GUICtrlSendToDummy GUICtrlSetBkColor GUICtrlSetColor GUICtrlSetCursor GUICtrlSetData GUICtrlSetDefBkColor GUICtrlSetDefColor GUICtrlSetFont GUICtrlSetGraphic GUICtrlSetImage GUICtrlSetLimit GUICtrlSetOnEvent GUICtrlSetPos GUICtrlSetResizing GUICtrlSetState GUICtrlSetStyle GUICtrlSetTip GUIDelete GUIGetCursorInfo GUIGetMsg GUIGetStyle GUIRegisterMsg GUISetAccelerators GUISetBkColor GUISetCoord GUISetCursor GUISetFont GUISetHelp GUISetIcon GUISetOnEvent GUISetState GUISetStyle GUIStartGroup GUISwitch Hex HotKeySet HttpSetProxy HttpSetUserAgent HWnd InetClose InetGet InetGetInfo InetGetSize InetRead IniDelete IniRead IniReadSection IniReadSectionNames IniRenameSection IniWrite IniWriteSection InputBox Int IsAdmin IsArray IsBinary IsBool IsDeclared IsDllStruct IsFloat IsFunc IsHWnd IsInt IsKeyword IsNumber IsObj IsPtr IsString Log MemGetStats Mod MouseClick MouseClickDrag MouseDown MouseGetCursor MouseGetPos MouseMove MouseUp MouseWheel MsgBox Number ObjCreate ObjCreateInterface ObjEvent ObjGet ObjName OnAutoItExitRegister OnAutoItExitUnRegister Ping PixelChecksum PixelGetColor PixelSearch ProcessClose ProcessExists ProcessGetStats ProcessList ProcessSetPriority ProcessWait ProcessWaitClose ProgressOff ProgressOn ProgressSet Ptr Random RegDelete RegEnumKey RegEnumVal RegRead RegWrite Round Run RunAs RunAsWait RunWait Send SendKeepActive SetError SetExtended ShellExecute ShellExecuteWait Shutdown Sin Sleep SoundPlay SoundSetWaveVolume SplashImageOn SplashOff SplashTextOn Sqrt SRandom StatusbarGetText StderrRead StdinWrite StdioClose StdoutRead String StringAddCR StringCompare StringFormat StringFromASCIIArray StringInStr StringIsAlNum StringIsAlpha StringIsASCII StringIsDigit StringIsFloat StringIsInt StringIsLower StringIsSpace StringIsUpper StringIsXDigit StringLeft StringLen StringLower StringMid StringRegExp StringRegExpReplace StringReplace StringReverse StringRight StringSplit StringStripCR StringStripWS StringToASCIIArray StringToBinary StringTrimLeft StringTrimRight StringUpper Tan TCPAccept TCPCloseSocket TCPConnect TCPListen TCPNameToIP TCPRecv TCPSend TCPShutdown, UDPShutdown TCPStartup, UDPStartup TimerDiff TimerInit ToolTip TrayCreateItem TrayCreateMenu TrayGetMsg TrayItemDelete TrayItemGetHandle TrayItemGetState TrayItemGetText TrayItemSetOnEvent TrayItemSetState TrayItemSetText TraySetClick TraySetIcon TraySetOnEvent TraySetPauseIcon TraySetState TraySetToolTip TrayTip UBound UDPBind UDPCloseSocket UDPOpen UDPRecv UDPSend VarGetType WinActivate WinActive WinClose WinExists WinFlash WinGetCaretPos WinGetClassList WinGetClientSize WinGetHandle WinGetPos WinGetProcess WinGetState WinGetText WinGetTitle WinKill WinList WinMenuSelectItem WinMinimizeAll WinMinimizeAllUndo WinMove WinSetOnTop WinSetState WinSetTitle WinSetTrans WinWait",
-literal:"True False And Null Not Or"},contains:[t,r,i,n,{className:"meta",
-begin:"#",end:"$",keywords:{
-"meta-keyword":"comments include include-once NoTrayIcon OnAutoItStartRegister pragma compile RequireAdmin"
+keyword:"ByRef Case Const ContinueCase ContinueLoop Dim Do Else ElseIf EndFunc EndIf EndSelect EndSwitch EndWith Enum Exit ExitLoop For Func Global If In Local Next ReDim Return Select Static Step Switch Then To Until Volatile WEnd While With",
+built_in:"Abs ACos AdlibRegister AdlibUnRegister Asc AscW ASin Assign ATan AutoItSetOption AutoItWinGetTitle AutoItWinSetTitle Beep Binary BinaryLen BinaryMid BinaryToString BitAND BitNOT BitOR BitRotate BitShift BitXOR BlockInput Break Call CDTray Ceiling Chr ChrW ClipGet ClipPut ConsoleRead ConsoleWrite ConsoleWriteError ControlClick ControlCommand ControlDisable ControlEnable ControlFocus ControlGetFocus ControlGetHandle ControlGetPos ControlGetText ControlHide ControlListView ControlMove ControlSend ControlSetText ControlShow ControlTreeView Cos Dec DirCopy DirCreate DirGetSize DirMove DirRemove DllCall DllCallAddress DllCallbackFree DllCallbackGetPtr DllCallbackRegister DllClose DllOpen DllStructCreate DllStructGetData DllStructGetPtr DllStructGetSize DllStructSetData DriveGetDrive DriveGetFileSystem DriveGetLabel DriveGetSerial DriveGetType DriveMapAdd DriveMapDel DriveMapGet DriveSetLabel DriveSpaceFree DriveSpaceTotal DriveStatus EnvGet EnvSet EnvUpdate Eval Execute Exp FileChangeDir FileClose FileCopy FileCreateNTFSLink FileCreateShortcut FileDelete FileExists FileFindFirstFile FileFindNextFile FileFlush FileGetAttrib FileGetEncoding FileGetLongName FileGetPos FileGetShortcut FileGetShortName FileGetSize FileGetTime FileGetVersion FileInstall FileMove FileOpen FileOpenDialog FileRead FileReadLine FileReadToArray FileRecycle FileRecycleEmpty FileSaveDialog FileSelectFolder FileSetAttrib FileSetEnd FileSetPos FileSetTime FileWrite FileWriteLine Floor FtpSetProxy FuncName GUICreate GUICtrlCreateAvi GUICtrlCreateButton GUICtrlCreateCheckbox GUICtrlCreateCombo GUICtrlCreateContextMenu GUICtrlCreateDate GUICtrlCreateDummy GUICtrlCreateEdit GUICtrlCreateGraphic GUICtrlCreateGroup GUICtrlCreateIcon GUICtrlCreateInput GUICtrlCreateLabel GUICtrlCreateList GUICtrlCreateListView GUICtrlCreateListViewItem GUICtrlCreateMenu GUICtrlCreateMenuItem GUICtrlCreateMonthCal GUICtrlCreateObj GUICtrlCreatePic GUICtrlCreateProgress GUICtrlCreateRadio GUICtrlCreateSlider GUICtrlCreateTab GUICtrlCreateTabItem GUICtrlCreateTreeView GUICtrlCreateTreeViewItem GUICtrlCreateUpdown GUICtrlDelete GUICtrlGetHandle GUICtrlGetState GUICtrlRead GUICtrlRecvMsg GUICtrlRegisterListViewSort GUICtrlSendMsg GUICtrlSendToDummy GUICtrlSetBkColor GUICtrlSetColor GUICtrlSetCursor GUICtrlSetData GUICtrlSetDefBkColor GUICtrlSetDefColor GUICtrlSetFont GUICtrlSetGraphic GUICtrlSetImage GUICtrlSetLimit GUICtrlSetOnEvent GUICtrlSetPos GUICtrlSetResizing GUICtrlSetState GUICtrlSetStyle GUICtrlSetTip GUIDelete GUIGetCursorInfo GUIGetMsg GUIGetStyle GUIRegisterMsg GUISetAccelerators GUISetBkColor GUISetCoord GUISetCursor GUISetFont GUISetHelp GUISetIcon GUISetOnEvent GUISetState GUISetStyle GUIStartGroup GUISwitch Hex HotKeySet HttpSetProxy HttpSetUserAgent HWnd InetClose InetGet InetGetInfo InetGetSize InetRead IniDelete IniRead IniReadSection IniReadSectionNames IniRenameSection IniWrite IniWriteSection InputBox Int IsAdmin IsArray IsBinary IsBool IsDeclared IsDllStruct IsFloat IsFunc IsHWnd IsInt IsKeyword IsNumber IsObj IsPtr IsString Log MemGetStats Mod MouseClick MouseClickDrag MouseDown MouseGetCursor MouseGetPos MouseMove MouseUp MouseWheel MsgBox Number ObjCreate ObjCreateInterface ObjEvent ObjGet ObjName OnAutoItExitRegister OnAutoItExitUnRegister Ping PixelChecksum PixelGetColor PixelSearch ProcessClose ProcessExists ProcessGetStats ProcessList ProcessSetPriority ProcessWait ProcessWaitClose ProgressOff ProgressOn ProgressSet Ptr Random RegDelete RegEnumKey RegEnumVal RegRead RegWrite Round Run RunAs RunAsWait RunWait Send SendKeepActive SetError SetExtended ShellExecute ShellExecuteWait Shutdown Sin Sleep SoundPlay SoundSetWaveVolume SplashImageOn SplashOff SplashTextOn Sqrt SRandom StatusbarGetText StderrRead StdinWrite StdioClose StdoutRead String StringAddCR StringCompare StringFormat StringFromASCIIArray StringInStr StringIsAlNum StringIsAlpha StringIsASCII StringIsDigit StringIsFloat StringIsInt StringIsLower StringIsSpace StringIsUpper StringIsXDigit StringLeft StringLen StringLower StringMid StringRegExp StringRegExpReplace StringReplace StringReverse StringRight StringSplit StringStripCR StringStripWS StringToASCIIArray StringToBinary StringTrimLeft StringTrimRight StringUpper Tan TCPAccept TCPCloseSocket TCPConnect TCPListen TCPNameToIP TCPRecv TCPSend TCPShutdown, UDPShutdown TCPStartup, UDPStartup TimerDiff TimerInit ToolTip TrayCreateItem TrayCreateMenu TrayGetMsg TrayItemDelete TrayItemGetHandle TrayItemGetState TrayItemGetText TrayItemSetOnEvent TrayItemSetState TrayItemSetText TraySetClick TraySetIcon TraySetOnEvent TraySetPauseIcon TraySetState TraySetToolTip TrayTip UBound UDPBind UDPCloseSocket UDPOpen UDPRecv UDPSend VarGetType WinActivate WinActive WinClose WinExists WinFlash WinGetCaretPos WinGetClassList WinGetClientSize WinGetHandle WinGetPos WinGetProcess WinGetState WinGetText WinGetTitle WinKill WinList WinMenuSelectItem WinMinimizeAll WinMinimizeAllUndo WinMove WinSetOnTop WinSetState WinSetTitle WinSetTrans WinWait WinWaitActive WinWaitClose WinWaitNotActive",
+literal:"True False And Null Not Or Default"},contains:[t,r,i,n,{
+className:"meta",begin:"#",end:"$",keywords:{
+"meta-keyword":["EndRegion","forcedef","forceref","ignorefunc","include","include-once","NoTrayIcon","OnAutoItStartRegister","pragma","Region","RequireAdmin","Tidy_Off","Tidy_On","Tidy_Parameters"]
 },contains:[{begin:/\\\n/,relevance:0},{beginKeywords:"include",keywords:{
 "meta-keyword":"include"},end:"$",contains:[i,{className:"meta-string",
 variants:[{begin:"<",end:">"},{begin:/"/,end:/"/,contains:[{begin:/""/,
@@ -746,16 +753,16 @@
 variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{
 beginKeywords:"new throw return else",end:/;/}],keywords:u,contains:p.concat([{
 begin:/\(/,end:/\)/,keywords:u,contains:p.concat(["self"]),relevance:0}]),
-relevance:0},_={className:"function",begin:"("+r+"[\\*&\\s]+)+"+d,
+relevance:0},g={className:"function",begin:"("+r+"[\\*&\\s]+)+"+d,
 returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:u,illegal:/[^\w\s\*&:<>.]/,
 contains:[{begin:"decltype\\(auto\\)",keywords:u,relevance:0},{begin:d,
-returnBegin:!0,contains:[l],relevance:0},{className:"params",begin:/\(/,
-end:/\)/,keywords:u,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,i,c,s,{
-begin:/\(/,end:/\)/,keywords:u,relevance:0,
-contains:["self",n,t.C_BLOCK_COMMENT_MODE,i,c,s]}]
-},s,n,t.C_BLOCK_COMMENT_MODE,o]};return{name:"C++",
+returnBegin:!0,contains:[l],relevance:0},{begin:/::/,relevance:0},{begin:/:/,
+endsWithParent:!0,contains:[i,c]},{className:"params",begin:/\(/,end:/\)/,
+keywords:u,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,i,c,s,{begin:/\(/,
+end:/\)/,keywords:u,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,i,c,s]
+}]},s,n,t.C_BLOCK_COMMENT_MODE,o]};return{name:"C++",
 aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:u,illegal:"</",
-contains:[].concat(m,_,p,[o,{
+contains:[].concat(m,g,p,[o,{
 begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",
 end:">",keywords:u,contains:["self",s]},{begin:t.IDENT_RE+"::",keywords:u},{
 className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,
@@ -842,7 +849,7 @@
 contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),{
 className:"meta",begin:'@[a-z]\\w*(?::"[^"]*")?'}].concat(n)}}})());
 hljs.registerLanguage("clean",(()=>{"use strict";return e=>({name:"Clean",
-aliases:["clean","icl","dcl"],keywords:{
+aliases:["icl","dcl"],keywords:{
 keyword:"if let in with where case of class instance otherwise implementation definition system module from import qualified as special code inline foreign export ccall stdcall generic derive infix infixl infixr",
 built_in:"Int Real Char Bool",literal:"True False"},
 contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.C_NUMBER_MODE,{
@@ -873,7 +880,7 @@
 },contains:[{className:"variable",begin:/\$\{/,end:/\}/
 },e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE]})})());
 hljs.registerLanguage("coffeescript",(()=>{"use strict"
-;const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
+;const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer","BigInt64Array","BigUint64Array","BigInt"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
 ;return r=>{const t={
 keyword:e.concat(["then","unless","until","loop","by","when","and","or","is","isnt","not"]).filter((i=["var","const","let","function","static"],
 e=>!i.includes(e))),literal:n.concat(["yes","no","on","off"]),
@@ -906,7 +913,7 @@
 className:"type",excludeBegin:!0,begin:"\\|\\s*",end:"\\w+"},{begin:/[-=]>/}]})
 })());
 hljs.registerLanguage("cos",(()=>{"use strict";return e=>({
-name:"Cach\xe9 Object Script",case_insensitive:!0,aliases:["cos","cls"],
+name:"Cach\xe9 Object Script",case_insensitive:!0,aliases:["cls"],
 keywords:"property parameter class classmethod clientmethod extends as break catch close continue do d|0 else elseif for goto halt hang h|0 if job j|0 kill k|0 lock l|0 merge new open quit q|0 read r|0 return set s|0 tcommit throw trollback try tstart use view while write w|0 xecute x|0 zkill znspace zn ztrap zwrite zw zzdump zzwrite print zbreak zinsert zload zprint zremove zsave zzprint mv mvcall mvcrt mvdim mvprint zquit zsync ascii",
 contains:[{className:"number",begin:"\\b(\\d+(\\.\\d*)?|\\.\\d+)",relevance:0},{
 className:"string",variants:[{begin:'"',end:'"',contains:[{begin:'""',
@@ -948,11 +955,11 @@
 relevance:0},_={className:"function",begin:"("+a+"[\\*&\\s]+)+"+d,
 returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:u,illegal:/[^\w\s\*&:<>.]/,
 contains:[{begin:"decltype\\(auto\\)",keywords:u,relevance:0},{begin:d,
-returnBegin:!0,contains:[l],relevance:0},{className:"params",begin:/\(/,
-end:/\)/,keywords:u,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,s,o,i,{
-begin:/\(/,end:/\)/,keywords:u,relevance:0,
-contains:["self",n,t.C_BLOCK_COMMENT_MODE,s,o,i]}]
-},i,n,t.C_BLOCK_COMMENT_MODE,c]};return{name:"C++",
+returnBegin:!0,contains:[l],relevance:0},{begin:/::/,relevance:0},{begin:/:/,
+endsWithParent:!0,contains:[s,o]},{className:"params",begin:/\(/,end:/\)/,
+keywords:u,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,s,o,i,{begin:/\(/,
+end:/\)/,keywords:u,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,s,o,i]
+}]},i,n,t.C_BLOCK_COMMENT_MODE,c]};return{name:"C++",
 aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:u,illegal:"</",
 contains:[].concat(p,_,m,[c,{
 begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",
@@ -1557,9 +1564,9 @@
 contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,{
 className:"meta",begin:"#",end:"$"}]})})());
 hljs.registerLanguage("gml",(()=>{"use strict";return e=>({name:"GML",
-aliases:["gml","GML"],case_insensitive:!1,keywords:{
-keyword:"begin end if then else while do for break continue with until repeat exit and or xor not return mod div switch case default var globalvar enum #macro #region #endregion",
-built_in:"is_real is_string is_array is_undefined is_int32 is_int64 is_ptr is_vec3 is_vec4 is_matrix is_bool typeof variable_global_exists variable_global_get variable_global_set variable_instance_exists variable_instance_get variable_instance_set variable_instance_get_names array_length_1d array_length_2d array_height_2d array_equals array_create array_copy random random_range irandom irandom_range random_set_seed random_get_seed randomize randomise choose abs round floor ceil sign frac sqrt sqr exp ln log2 log10 sin cos tan arcsin arccos arctan arctan2 dsin dcos dtan darcsin darccos darctan darctan2 degtorad radtodeg power logn min max mean median clamp lerp dot_product dot_product_3d dot_product_normalised dot_product_3d_normalised dot_product_normalized dot_product_3d_normalized math_set_epsilon math_get_epsilon angle_difference point_distance_3d point_distance point_direction lengthdir_x lengthdir_y real string int64 ptr string_format chr ansi_char ord string_length string_byte_length string_pos string_copy string_char_at string_ord_at string_byte_at string_set_byte_at string_delete string_insert string_lower string_upper string_repeat string_letters string_digits string_lettersdigits string_replace string_replace_all string_count string_hash_to_newline clipboard_has_text clipboard_set_text clipboard_get_text date_current_datetime date_create_datetime date_valid_datetime date_inc_year date_inc_month date_inc_week date_inc_day date_inc_hour date_inc_minute date_inc_second date_get_year date_get_month date_get_week date_get_day date_get_hour date_get_minute date_get_second date_get_weekday date_get_day_of_year date_get_hour_of_year date_get_minute_of_year date_get_second_of_year date_year_span date_month_span date_week_span date_day_span date_hour_span date_minute_span date_second_span date_compare_datetime date_compare_date date_compare_time date_date_of date_time_of date_datetime_string date_date_string date_time_string date_days_in_month date_days_in_year date_leap_year date_is_today date_set_timezone date_get_timezone game_set_speed game_get_speed motion_set motion_add place_free place_empty place_meeting place_snapped move_random move_snap move_towards_point move_contact_solid move_contact_all move_outside_solid move_outside_all move_bounce_solid move_bounce_all move_wrap distance_to_point distance_to_object position_empty position_meeting path_start path_end mp_linear_step mp_potential_step mp_linear_step_object mp_potential_step_object mp_potential_settings mp_linear_path mp_potential_path mp_linear_path_object mp_potential_path_object mp_grid_create mp_grid_destroy mp_grid_clear_all mp_grid_clear_cell mp_grid_clear_rectangle mp_grid_add_cell mp_grid_get_cell mp_grid_add_rectangle mp_grid_add_instances mp_grid_path mp_grid_draw mp_grid_to_ds_grid collision_point collision_rectangle collision_circle collision_ellipse collision_line collision_point_list collision_rectangle_list collision_circle_list collision_ellipse_list collision_line_list instance_position_list instance_place_list point_in_rectangle point_in_triangle point_in_circle rectangle_in_rectangle rectangle_in_triangle rectangle_in_circle instance_find instance_exists instance_number instance_position instance_nearest instance_furthest instance_place instance_create_depth instance_create_layer instance_copy instance_change instance_destroy position_destroy position_change instance_id_get instance_deactivate_all instance_deactivate_object instance_deactivate_region instance_activate_all instance_activate_object instance_activate_region room_goto room_goto_previous room_goto_next room_previous room_next room_restart game_end game_restart game_load game_save game_save_buffer game_load_buffer event_perform event_user event_perform_object event_inherited show_debug_message show_debug_overlay debug_event debug_get_callstack alarm_get alarm_set font_texture_page_size keyboard_set_map keyboard_get_map keyboard_unset_map keyboard_check keyboard_check_pressed keyboard_check_released keyboard_check_direct keyboard_get_numlock keyboard_set_numlock keyboard_key_press keyboard_key_release keyboard_clear io_clear mouse_check_button mouse_check_button_pressed mouse_check_button_released mouse_wheel_up mouse_wheel_down mouse_clear draw_self draw_sprite draw_sprite_pos draw_sprite_ext draw_sprite_stretched draw_sprite_stretched_ext draw_sprite_tiled draw_sprite_tiled_ext draw_sprite_part draw_sprite_part_ext draw_sprite_general draw_clear draw_clear_alpha draw_point draw_line draw_line_width draw_rectangle draw_roundrect draw_roundrect_ext draw_triangle draw_circle draw_ellipse draw_set_circle_precision draw_arrow draw_button draw_path draw_healthbar draw_getpixel draw_getpixel_ext draw_set_colour draw_set_color draw_set_alpha draw_get_colour draw_get_color draw_get_alpha merge_colour make_colour_rgb make_colour_hsv colour_get_red colour_get_green colour_get_blue colour_get_hue colour_get_saturation colour_get_value merge_color make_color_rgb make_color_hsv color_get_red color_get_green color_get_blue color_get_hue color_get_saturation color_get_value merge_color screen_save screen_save_part draw_set_font draw_set_halign draw_set_valign draw_text draw_text_ext string_width string_height string_width_ext string_height_ext draw_text_transformed draw_text_ext_transformed draw_text_colour draw_text_ext_colour draw_text_transformed_colour draw_text_ext_transformed_colour draw_text_color draw_text_ext_color draw_text_transformed_color draw_text_ext_transformed_color draw_point_colour draw_line_colour draw_line_width_colour draw_rectangle_colour draw_roundrect_colour draw_roundrect_colour_ext draw_triangle_colour draw_circle_colour draw_ellipse_colour draw_point_color draw_line_color draw_line_width_color draw_rectangle_color draw_roundrect_color draw_roundrect_color_ext draw_triangle_color draw_circle_color draw_ellipse_color draw_primitive_begin draw_vertex draw_vertex_colour draw_vertex_color draw_primitive_end sprite_get_uvs font_get_uvs sprite_get_texture font_get_texture texture_get_width texture_get_height texture_get_uvs draw_primitive_begin_texture draw_vertex_texture draw_vertex_texture_colour draw_vertex_texture_color texture_global_scale surface_create surface_create_ext surface_resize surface_free surface_exists surface_get_width surface_get_height surface_get_texture surface_set_target surface_set_target_ext surface_reset_target surface_depth_disable surface_get_depth_disable draw_surface draw_surface_stretched draw_surface_tiled draw_surface_part draw_surface_ext draw_surface_stretched_ext draw_surface_tiled_ext draw_surface_part_ext draw_surface_general surface_getpixel surface_getpixel_ext surface_save surface_save_part surface_copy surface_copy_part application_surface_draw_enable application_get_position application_surface_enable application_surface_is_enabled display_get_width display_get_height display_get_orientation display_get_gui_width display_get_gui_height display_reset display_mouse_get_x display_mouse_get_y display_mouse_set display_set_ui_visibility window_set_fullscreen window_get_fullscreen window_set_caption window_set_min_width window_set_max_width window_set_min_height window_set_max_height window_get_visible_rects window_get_caption window_set_cursor window_get_cursor window_set_colour window_get_colour window_set_color window_get_color window_set_position window_set_size window_set_rectangle window_center window_get_x window_get_y window_get_width window_get_height window_mouse_get_x window_mouse_get_y window_mouse_set window_view_mouse_get_x window_view_mouse_get_y window_views_mouse_get_x window_views_mouse_get_y audio_listener_position audio_listener_velocity audio_listener_orientation audio_emitter_position audio_emitter_create audio_emitter_free audio_emitter_exists audio_emitter_pitch audio_emitter_velocity audio_emitter_falloff audio_emitter_gain audio_play_sound audio_play_sound_on audio_play_sound_at audio_stop_sound audio_resume_music audio_music_is_playing audio_resume_sound audio_pause_sound audio_pause_music audio_channel_num audio_sound_length audio_get_type audio_falloff_set_model audio_play_music audio_stop_music audio_master_gain audio_music_gain audio_sound_gain audio_sound_pitch audio_stop_all audio_resume_all audio_pause_all audio_is_playing audio_is_paused audio_exists audio_sound_set_track_position audio_sound_get_track_position audio_emitter_get_gain audio_emitter_get_pitch audio_emitter_get_x audio_emitter_get_y audio_emitter_get_z audio_emitter_get_vx audio_emitter_get_vy audio_emitter_get_vz audio_listener_set_position audio_listener_set_velocity audio_listener_set_orientation audio_listener_get_data audio_set_master_gain audio_get_master_gain audio_sound_get_gain audio_sound_get_pitch audio_get_name audio_sound_set_track_position audio_sound_get_track_position audio_create_stream audio_destroy_stream audio_create_sync_group audio_destroy_sync_group audio_play_in_sync_group audio_start_sync_group audio_stop_sync_group audio_pause_sync_group audio_resume_sync_group audio_sync_group_get_track_pos audio_sync_group_debug audio_sync_group_is_playing audio_debug audio_group_load audio_group_unload audio_group_is_loaded audio_group_load_progress audio_group_name audio_group_stop_all audio_group_set_gain audio_create_buffer_sound audio_free_buffer_sound audio_create_play_queue audio_free_play_queue audio_queue_sound audio_get_recorder_count audio_get_recorder_info audio_start_recording audio_stop_recording audio_sound_get_listener_mask audio_emitter_get_listener_mask audio_get_listener_mask audio_sound_set_listener_mask audio_emitter_set_listener_mask audio_set_listener_mask audio_get_listener_count audio_get_listener_info audio_system show_message show_message_async clickable_add clickable_add_ext clickable_change clickable_change_ext clickable_delete clickable_exists clickable_set_style show_question show_question_async get_integer get_string get_integer_async get_string_async get_login_async get_open_filename get_save_filename get_open_filename_ext get_save_filename_ext show_error highscore_clear highscore_add highscore_value highscore_name draw_highscore sprite_exists sprite_get_name sprite_get_number sprite_get_width sprite_get_height sprite_get_xoffset sprite_get_yoffset sprite_get_bbox_left sprite_get_bbox_right sprite_get_bbox_top sprite_get_bbox_bottom sprite_save sprite_save_strip sprite_set_cache_size sprite_set_cache_size_ext sprite_get_tpe sprite_prefetch sprite_prefetch_multi sprite_flush sprite_flush_multi sprite_set_speed sprite_get_speed_type sprite_get_speed font_exists font_get_name font_get_fontname font_get_bold font_get_italic font_get_first font_get_last font_get_size font_set_cache_size path_exists path_get_name path_get_length path_get_time path_get_kind path_get_closed path_get_precision path_get_number path_get_point_x path_get_point_y path_get_point_speed path_get_x path_get_y path_get_speed script_exists script_get_name timeline_add timeline_delete timeline_clear timeline_exists timeline_get_name timeline_moment_clear timeline_moment_add_script timeline_size timeline_max_moment object_exists object_get_name object_get_sprite object_get_solid object_get_visible object_get_persistent object_get_mask object_get_parent object_get_physics object_is_ancestor room_exists room_get_name sprite_set_offset sprite_duplicate sprite_assign sprite_merge sprite_add sprite_replace sprite_create_from_surface sprite_add_from_surface sprite_delete sprite_set_alpha_from_sprite sprite_collision_mask font_add_enable_aa font_add_get_enable_aa font_add font_add_sprite font_add_sprite_ext font_replace font_replace_sprite font_replace_sprite_ext font_delete path_set_kind path_set_closed path_set_precision path_add path_assign path_duplicate path_append path_delete path_add_point path_insert_point path_change_point path_delete_point path_clear_points path_reverse path_mirror path_flip path_rotate path_rescale path_shift script_execute object_set_sprite object_set_solid object_set_visible object_set_persistent object_set_mask room_set_width room_set_height room_set_persistent room_set_background_colour room_set_background_color room_set_view room_set_viewport room_get_viewport room_set_view_enabled room_add room_duplicate room_assign room_instance_add room_instance_clear room_get_camera room_set_camera asset_get_index asset_get_type file_text_open_from_string file_text_open_read file_text_open_write file_text_open_append file_text_close file_text_write_string file_text_write_real file_text_writeln file_text_read_string file_text_read_real file_text_readln file_text_eof file_text_eoln file_exists file_delete file_rename file_copy directory_exists directory_create directory_destroy file_find_first file_find_next file_find_close file_attributes filename_name filename_path filename_dir filename_drive filename_ext filename_change_ext file_bin_open file_bin_rewrite file_bin_close file_bin_position file_bin_size file_bin_seek file_bin_write_byte file_bin_read_byte parameter_count parameter_string environment_get_variable ini_open_from_string ini_open ini_close ini_read_string ini_read_real ini_write_string ini_write_real ini_key_exists ini_section_exists ini_key_delete ini_section_delete ds_set_precision ds_exists ds_stack_create ds_stack_destroy ds_stack_clear ds_stack_copy ds_stack_size ds_stack_empty ds_stack_push ds_stack_pop ds_stack_top ds_stack_write ds_stack_read ds_queue_create ds_queue_destroy ds_queue_clear ds_queue_copy ds_queue_size ds_queue_empty ds_queue_enqueue ds_queue_dequeue ds_queue_head ds_queue_tail ds_queue_write ds_queue_read ds_list_create ds_list_destroy ds_list_clear ds_list_copy ds_list_size ds_list_empty ds_list_add ds_list_insert ds_list_replace ds_list_delete ds_list_find_index ds_list_find_value ds_list_mark_as_list ds_list_mark_as_map ds_list_sort ds_list_shuffle ds_list_write ds_list_read ds_list_set ds_map_create ds_map_destroy ds_map_clear ds_map_copy ds_map_size ds_map_empty ds_map_add ds_map_add_list ds_map_add_map ds_map_replace ds_map_replace_map ds_map_replace_list ds_map_delete ds_map_exists ds_map_find_value ds_map_find_previous ds_map_find_next ds_map_find_first ds_map_find_last ds_map_write ds_map_read ds_map_secure_save ds_map_secure_load ds_map_secure_load_buffer ds_map_secure_save_buffer ds_map_set ds_priority_create ds_priority_destroy ds_priority_clear ds_priority_copy ds_priority_size ds_priority_empty ds_priority_add ds_priority_change_priority ds_priority_find_priority ds_priority_delete_value ds_priority_delete_min ds_priority_find_min ds_priority_delete_max ds_priority_find_max ds_priority_write ds_priority_read ds_grid_create ds_grid_destroy ds_grid_copy ds_grid_resize ds_grid_width ds_grid_height ds_grid_clear ds_grid_set ds_grid_add ds_grid_multiply ds_grid_set_region ds_grid_add_region ds_grid_multiply_region ds_grid_set_disk ds_grid_add_disk ds_grid_multiply_disk ds_grid_set_grid_region ds_grid_add_grid_region ds_grid_multiply_grid_region ds_grid_get ds_grid_get_sum ds_grid_get_max ds_grid_get_min ds_grid_get_mean ds_grid_get_disk_sum ds_grid_get_disk_min ds_grid_get_disk_max ds_grid_get_disk_mean ds_grid_value_exists ds_grid_value_x ds_grid_value_y ds_grid_value_disk_exists ds_grid_value_disk_x ds_grid_value_disk_y ds_grid_shuffle ds_grid_write ds_grid_read ds_grid_sort ds_grid_set ds_grid_get effect_create_below effect_create_above effect_clear part_type_create part_type_destroy part_type_exists part_type_clear part_type_shape part_type_sprite part_type_size part_type_scale part_type_orientation part_type_life part_type_step part_type_death part_type_speed part_type_direction part_type_gravity part_type_colour1 part_type_colour2 part_type_colour3 part_type_colour_mix part_type_colour_rgb part_type_colour_hsv part_type_color1 part_type_color2 part_type_color3 part_type_color_mix part_type_color_rgb part_type_color_hsv part_type_alpha1 part_type_alpha2 part_type_alpha3 part_type_blend part_system_create part_system_create_layer part_system_destroy part_system_exists part_system_clear part_system_draw_order part_system_depth part_system_position part_system_automatic_update part_system_automatic_draw part_system_update part_system_drawit part_system_get_layer part_system_layer part_particles_create part_particles_create_colour part_particles_create_color part_particles_clear part_particles_count part_emitter_create part_emitter_destroy part_emitter_destroy_all part_emitter_exists part_emitter_clear part_emitter_region part_emitter_burst part_emitter_stream external_call external_define external_free window_handle window_device matrix_get matrix_set matrix_build_identity matrix_build matrix_build_lookat matrix_build_projection_ortho matrix_build_projection_perspective matrix_build_projection_perspective_fov matrix_multiply matrix_transform_vertex matrix_stack_push matrix_stack_pop matrix_stack_multiply matrix_stack_set matrix_stack_clear matrix_stack_top matrix_stack_is_empty browser_input_capture os_get_config os_get_info os_get_language os_get_region os_lock_orientation display_get_dpi_x display_get_dpi_y display_set_gui_size display_set_gui_maximise display_set_gui_maximize device_mouse_dbclick_enable display_set_timing_method display_get_timing_method display_set_sleep_margin display_get_sleep_margin virtual_key_add virtual_key_hide virtual_key_delete virtual_key_show draw_enable_drawevent draw_enable_swf_aa draw_set_swf_aa_level draw_get_swf_aa_level draw_texture_flush draw_flush gpu_set_blendenable gpu_set_ztestenable gpu_set_zfunc gpu_set_zwriteenable gpu_set_lightingenable gpu_set_fog gpu_set_cullmode gpu_set_blendmode gpu_set_blendmode_ext gpu_set_blendmode_ext_sepalpha gpu_set_colorwriteenable gpu_set_colourwriteenable gpu_set_alphatestenable gpu_set_alphatestref gpu_set_alphatestfunc gpu_set_texfilter gpu_set_texfilter_ext gpu_set_texrepeat gpu_set_texrepeat_ext gpu_set_tex_filter gpu_set_tex_filter_ext gpu_set_tex_repeat gpu_set_tex_repeat_ext gpu_set_tex_mip_filter gpu_set_tex_mip_filter_ext gpu_set_tex_mip_bias gpu_set_tex_mip_bias_ext gpu_set_tex_min_mip gpu_set_tex_min_mip_ext gpu_set_tex_max_mip gpu_set_tex_max_mip_ext gpu_set_tex_max_aniso gpu_set_tex_max_aniso_ext gpu_set_tex_mip_enable gpu_set_tex_mip_enable_ext gpu_get_blendenable gpu_get_ztestenable gpu_get_zfunc gpu_get_zwriteenable gpu_get_lightingenable gpu_get_fog gpu_get_cullmode gpu_get_blendmode gpu_get_blendmode_ext gpu_get_blendmode_ext_sepalpha gpu_get_blendmode_src gpu_get_blendmode_dest gpu_get_blendmode_srcalpha gpu_get_blendmode_destalpha gpu_get_colorwriteenable gpu_get_colourwriteenable gpu_get_alphatestenable gpu_get_alphatestref gpu_get_alphatestfunc gpu_get_texfilter gpu_get_texfilter_ext gpu_get_texrepeat gpu_get_texrepeat_ext gpu_get_tex_filter gpu_get_tex_filter_ext gpu_get_tex_repeat gpu_get_tex_repeat_ext gpu_get_tex_mip_filter gpu_get_tex_mip_filter_ext gpu_get_tex_mip_bias gpu_get_tex_mip_bias_ext gpu_get_tex_min_mip gpu_get_tex_min_mip_ext gpu_get_tex_max_mip gpu_get_tex_max_mip_ext gpu_get_tex_max_aniso gpu_get_tex_max_aniso_ext gpu_get_tex_mip_enable gpu_get_tex_mip_enable_ext gpu_push_state gpu_pop_state gpu_get_state gpu_set_state draw_light_define_ambient draw_light_define_direction draw_light_define_point draw_light_enable draw_set_lighting draw_light_get_ambient draw_light_get draw_get_lighting shop_leave_rating url_get_domain url_open url_open_ext url_open_full get_timer achievement_login achievement_logout achievement_post achievement_increment achievement_post_score achievement_available achievement_show_achievements achievement_show_leaderboards achievement_load_friends achievement_load_leaderboard achievement_send_challenge achievement_load_progress achievement_reset achievement_login_status achievement_get_pic achievement_show_challenge_notifications achievement_get_challenges achievement_event achievement_show achievement_get_info cloud_file_save cloud_string_save cloud_synchronise ads_enable ads_disable ads_setup ads_engagement_launch ads_engagement_available ads_engagement_active ads_event ads_event_preload ads_set_reward_callback ads_get_display_height ads_get_display_width ads_move ads_interstitial_available ads_interstitial_display device_get_tilt_x device_get_tilt_y device_get_tilt_z device_is_keypad_open device_mouse_check_button device_mouse_check_button_pressed device_mouse_check_button_released device_mouse_x device_mouse_y device_mouse_raw_x device_mouse_raw_y device_mouse_x_to_gui device_mouse_y_to_gui iap_activate iap_status iap_enumerate_products iap_restore_all iap_acquire iap_consume iap_product_details iap_purchase_details facebook_init facebook_login facebook_status facebook_graph_request facebook_dialog facebook_logout facebook_launch_offerwall facebook_post_message facebook_send_invite facebook_user_id facebook_accesstoken facebook_check_permission facebook_request_read_permissions facebook_request_publish_permissions gamepad_is_supported gamepad_get_device_count gamepad_is_connected gamepad_get_description gamepad_get_button_threshold gamepad_set_button_threshold gamepad_get_axis_deadzone gamepad_set_axis_deadzone gamepad_button_count gamepad_button_check gamepad_button_check_pressed gamepad_button_check_released gamepad_button_value gamepad_axis_count gamepad_axis_value gamepad_set_vibration gamepad_set_colour gamepad_set_color os_is_paused window_has_focus code_is_compiled http_get http_get_file http_post_string http_request json_encode json_decode zip_unzip load_csv base64_encode base64_decode md5_string_unicode md5_string_utf8 md5_file os_is_network_connected sha1_string_unicode sha1_string_utf8 sha1_file os_powersave_enable analytics_event analytics_event_ext win8_livetile_tile_notification win8_livetile_tile_clear win8_livetile_badge_notification win8_livetile_badge_clear win8_livetile_queue_enable win8_secondarytile_pin win8_secondarytile_badge_notification win8_secondarytile_delete win8_livetile_notification_begin win8_livetile_notification_secondary_begin win8_livetile_notification_expiry win8_livetile_notification_tag win8_livetile_notification_text_add win8_livetile_notification_image_add win8_livetile_notification_end win8_appbar_enable win8_appbar_add_element win8_appbar_remove_element win8_settingscharm_add_entry win8_settingscharm_add_html_entry win8_settingscharm_add_xaml_entry win8_settingscharm_set_xaml_property win8_settingscharm_get_xaml_property win8_settingscharm_remove_entry win8_share_image win8_share_screenshot win8_share_file win8_share_url win8_share_text win8_search_enable win8_search_disable win8_search_add_suggestions win8_device_touchscreen_available win8_license_initialize_sandbox win8_license_trial_version winphone_license_trial_version winphone_tile_title winphone_tile_count winphone_tile_back_title winphone_tile_back_content winphone_tile_back_content_wide winphone_tile_front_image winphone_tile_front_image_small winphone_tile_front_image_wide winphone_tile_back_image winphone_tile_back_image_wide winphone_tile_background_colour winphone_tile_background_color winphone_tile_icon_image winphone_tile_small_icon_image winphone_tile_wide_content winphone_tile_cycle_images winphone_tile_small_background_image physics_world_create physics_world_gravity physics_world_update_speed physics_world_update_iterations physics_world_draw_debug physics_pause_enable physics_fixture_create physics_fixture_set_kinematic physics_fixture_set_density physics_fixture_set_awake physics_fixture_set_restitution physics_fixture_set_friction physics_fixture_set_collision_group physics_fixture_set_sensor physics_fixture_set_linear_damping physics_fixture_set_angular_damping physics_fixture_set_circle_shape physics_fixture_set_box_shape physics_fixture_set_edge_shape physics_fixture_set_polygon_shape physics_fixture_set_chain_shape physics_fixture_add_point physics_fixture_bind physics_fixture_bind_ext physics_fixture_delete physics_apply_force physics_apply_impulse physics_apply_angular_impulse physics_apply_local_force physics_apply_local_impulse physics_apply_torque physics_mass_properties physics_draw_debug physics_test_overlap physics_remove_fixture physics_set_friction physics_set_density physics_set_restitution physics_get_friction physics_get_density physics_get_restitution physics_joint_distance_create physics_joint_rope_create physics_joint_revolute_create physics_joint_prismatic_create physics_joint_pulley_create physics_joint_wheel_create physics_joint_weld_create physics_joint_friction_create physics_joint_gear_create physics_joint_enable_motor physics_joint_get_value physics_joint_set_value physics_joint_delete physics_particle_create physics_particle_delete physics_particle_delete_region_circle physics_particle_delete_region_box physics_particle_delete_region_poly physics_particle_set_flags physics_particle_set_category_flags physics_particle_draw physics_particle_draw_ext physics_particle_count physics_particle_get_data physics_particle_get_data_particle physics_particle_group_begin physics_particle_group_circle physics_particle_group_box physics_particle_group_polygon physics_particle_group_add_point physics_particle_group_end physics_particle_group_join physics_particle_group_delete physics_particle_group_count physics_particle_group_get_data physics_particle_group_get_mass physics_particle_group_get_inertia physics_particle_group_get_centre_x physics_particle_group_get_centre_y physics_particle_group_get_vel_x physics_particle_group_get_vel_y physics_particle_group_get_ang_vel physics_particle_group_get_x physics_particle_group_get_y physics_particle_group_get_angle physics_particle_set_group_flags physics_particle_get_group_flags physics_particle_get_max_count physics_particle_get_radius physics_particle_get_density physics_particle_get_damping physics_particle_get_gravity_scale physics_particle_set_max_count physics_particle_set_radius physics_particle_set_density physics_particle_set_damping physics_particle_set_gravity_scale network_create_socket network_create_socket_ext network_create_server network_create_server_raw network_connect network_connect_raw network_send_packet network_send_raw network_send_broadcast network_send_udp network_send_udp_raw network_set_timeout network_set_config network_resolve network_destroy buffer_create buffer_write buffer_read buffer_seek buffer_get_surface buffer_set_surface buffer_delete buffer_exists buffer_get_type buffer_get_alignment buffer_poke buffer_peek buffer_save buffer_save_ext buffer_load buffer_load_ext buffer_load_partial buffer_copy buffer_fill buffer_get_size buffer_tell buffer_resize buffer_md5 buffer_sha1 buffer_base64_encode buffer_base64_decode buffer_base64_decode_ext buffer_sizeof buffer_get_address buffer_create_from_vertex_buffer buffer_create_from_vertex_buffer_ext buffer_copy_from_vertex_buffer buffer_async_group_begin buffer_async_group_option buffer_async_group_end buffer_load_async buffer_save_async gml_release_mode gml_pragma steam_activate_overlay steam_is_overlay_enabled steam_is_overlay_activated steam_get_persona_name steam_initialised steam_is_cloud_enabled_for_app steam_is_cloud_enabled_for_account steam_file_persisted steam_get_quota_total steam_get_quota_free steam_file_write steam_file_write_file steam_file_read steam_file_delete steam_file_exists steam_file_size steam_file_share steam_is_screenshot_requested steam_send_screenshot steam_is_user_logged_on steam_get_user_steam_id steam_user_owns_dlc steam_user_installed_dlc steam_set_achievement steam_get_achievement steam_clear_achievement steam_set_stat_int steam_set_stat_float steam_set_stat_avg_rate steam_get_stat_int steam_get_stat_float steam_get_stat_avg_rate steam_reset_all_stats steam_reset_all_stats_achievements steam_stats_ready steam_create_leaderboard steam_upload_score steam_upload_score_ext steam_download_scores_around_user steam_download_scores steam_download_friends_scores steam_upload_score_buffer steam_upload_score_buffer_ext steam_current_game_language steam_available_languages steam_activate_overlay_browser steam_activate_overlay_user steam_activate_overlay_store steam_get_user_persona_name steam_get_app_id steam_get_user_account_id steam_ugc_download steam_ugc_create_item steam_ugc_start_item_update steam_ugc_set_item_title steam_ugc_set_item_description steam_ugc_set_item_visibility steam_ugc_set_item_tags steam_ugc_set_item_content steam_ugc_set_item_preview steam_ugc_submit_item_update steam_ugc_get_item_update_progress steam_ugc_subscribe_item steam_ugc_unsubscribe_item steam_ugc_num_subscribed_items steam_ugc_get_subscribed_items steam_ugc_get_item_install_info steam_ugc_get_item_update_info steam_ugc_request_item_details steam_ugc_create_query_user steam_ugc_create_query_user_ex steam_ugc_create_query_all steam_ugc_create_query_all_ex steam_ugc_query_set_cloud_filename_filter steam_ugc_query_set_match_any_tag steam_ugc_query_set_search_text steam_ugc_query_set_ranked_by_trend_days steam_ugc_query_add_required_tag steam_ugc_query_add_excluded_tag steam_ugc_query_set_return_long_description steam_ugc_query_set_return_total_only steam_ugc_query_set_allow_cached_response steam_ugc_send_query shader_set shader_get_name shader_reset shader_current shader_is_compiled shader_get_sampler_index shader_get_uniform shader_set_uniform_i shader_set_uniform_i_array shader_set_uniform_f shader_set_uniform_f_array shader_set_uniform_matrix shader_set_uniform_matrix_array shader_enable_corner_id texture_set_stage texture_get_texel_width texture_get_texel_height shaders_are_supported vertex_format_begin vertex_format_end vertex_format_delete vertex_format_add_position vertex_format_add_position_3d vertex_format_add_colour vertex_format_add_color vertex_format_add_normal vertex_format_add_texcoord vertex_format_add_textcoord vertex_format_add_custom vertex_create_buffer vertex_create_buffer_ext vertex_delete_buffer vertex_begin vertex_end vertex_position vertex_position_3d vertex_colour vertex_color vertex_argb vertex_texcoord vertex_normal vertex_float1 vertex_float2 vertex_float3 vertex_float4 vertex_ubyte4 vertex_submit vertex_freeze vertex_get_number vertex_get_buffer_size vertex_create_buffer_from_buffer vertex_create_buffer_from_buffer_ext push_local_notification push_get_first_local_notification push_get_next_local_notification push_cancel_local_notification skeleton_animation_set skeleton_animation_get skeleton_animation_mix skeleton_animation_set_ext skeleton_animation_get_ext skeleton_animation_get_duration skeleton_animation_get_frames skeleton_animation_clear skeleton_skin_set skeleton_skin_get skeleton_attachment_set skeleton_attachment_get skeleton_attachment_create skeleton_collision_draw_set skeleton_bone_data_get skeleton_bone_data_set skeleton_bone_state_get skeleton_bone_state_set skeleton_get_minmax skeleton_get_num_bounds skeleton_get_bounds skeleton_animation_get_frame skeleton_animation_set_frame draw_skeleton draw_skeleton_time draw_skeleton_instance draw_skeleton_collision skeleton_animation_list skeleton_skin_list skeleton_slot_data layer_get_id layer_get_id_at_depth layer_get_depth layer_create layer_destroy layer_destroy_instances layer_add_instance layer_has_instance layer_set_visible layer_get_visible layer_exists layer_x layer_y layer_get_x layer_get_y layer_hspeed layer_vspeed layer_get_hspeed layer_get_vspeed layer_script_begin layer_script_end layer_shader layer_get_script_begin layer_get_script_end layer_get_shader layer_set_target_room layer_get_target_room layer_reset_target_room layer_get_all layer_get_all_elements layer_get_name layer_depth layer_get_element_layer layer_get_element_type layer_element_move layer_force_draw_depth layer_is_draw_depth_forced layer_get_forced_depth layer_background_get_id layer_background_exists layer_background_create layer_background_destroy layer_background_visible layer_background_change layer_background_sprite layer_background_htiled layer_background_vtiled layer_background_stretch layer_background_yscale layer_background_xscale layer_background_blend layer_background_alpha layer_background_index layer_background_speed layer_background_get_visible layer_background_get_sprite layer_background_get_htiled layer_background_get_vtiled layer_background_get_stretch layer_background_get_yscale layer_background_get_xscale layer_background_get_blend layer_background_get_alpha layer_background_get_index layer_background_get_speed layer_sprite_get_id layer_sprite_exists layer_sprite_create layer_sprite_destroy layer_sprite_change layer_sprite_index layer_sprite_speed layer_sprite_xscale layer_sprite_yscale layer_sprite_angle layer_sprite_blend layer_sprite_alpha layer_sprite_x layer_sprite_y layer_sprite_get_sprite layer_sprite_get_index layer_sprite_get_speed layer_sprite_get_xscale layer_sprite_get_yscale layer_sprite_get_angle layer_sprite_get_blend layer_sprite_get_alpha layer_sprite_get_x layer_sprite_get_y layer_tilemap_get_id layer_tilemap_exists layer_tilemap_create layer_tilemap_destroy tilemap_tileset tilemap_x tilemap_y tilemap_set tilemap_set_at_pixel tilemap_get_tileset tilemap_get_tile_width tilemap_get_tile_height tilemap_get_width tilemap_get_height tilemap_get_x tilemap_get_y tilemap_get tilemap_get_at_pixel tilemap_get_cell_x_at_pixel tilemap_get_cell_y_at_pixel tilemap_clear draw_tilemap draw_tile tilemap_set_global_mask tilemap_get_global_mask tilemap_set_mask tilemap_get_mask tilemap_get_frame tile_set_empty tile_set_index tile_set_flip tile_set_mirror tile_set_rotate tile_get_empty tile_get_index tile_get_flip tile_get_mirror tile_get_rotate layer_tile_exists layer_tile_create layer_tile_destroy layer_tile_change layer_tile_xscale layer_tile_yscale layer_tile_blend layer_tile_alpha layer_tile_x layer_tile_y layer_tile_region layer_tile_visible layer_tile_get_sprite layer_tile_get_xscale layer_tile_get_yscale layer_tile_get_blend layer_tile_get_alpha layer_tile_get_x layer_tile_get_y layer_tile_get_region layer_tile_get_visible layer_instance_get_instance instance_activate_layer instance_deactivate_layer camera_create camera_create_view camera_destroy camera_apply camera_get_active camera_get_default camera_set_default camera_set_view_mat camera_set_proj_mat camera_set_update_script camera_set_begin_script camera_set_end_script camera_set_view_pos camera_set_view_size camera_set_view_speed camera_set_view_border camera_set_view_angle camera_set_view_target camera_get_view_mat camera_get_proj_mat camera_get_update_script camera_get_begin_script camera_get_end_script camera_get_view_x camera_get_view_y camera_get_view_width camera_get_view_height camera_get_view_speed_x camera_get_view_speed_y camera_get_view_border_x camera_get_view_border_y camera_get_view_angle camera_get_view_target view_get_camera view_get_visible view_get_xport view_get_yport view_get_wport view_get_hport view_get_surface_id view_set_camera view_set_visible view_set_xport view_set_yport view_set_wport view_set_hport view_set_surface_id gesture_drag_time gesture_drag_distance gesture_flick_speed gesture_double_tap_time gesture_double_tap_distance gesture_pinch_distance gesture_pinch_angle_towards gesture_pinch_angle_away gesture_rotate_time gesture_rotate_angle gesture_tap_count gesture_get_drag_time gesture_get_drag_distance gesture_get_flick_speed gesture_get_double_tap_time gesture_get_double_tap_distance gesture_get_pinch_distance gesture_get_pinch_angle_towards gesture_get_pinch_angle_away gesture_get_rotate_time gesture_get_rotate_angle gesture_get_tap_count keyboard_virtual_show keyboard_virtual_hide keyboard_virtual_status keyboard_virtual_height",
+aliases:["GML"],case_insensitive:!1,keywords:{
+keyword:"begin end if then else while do for break continue with until repeat exit and or xor not return mod div switch case default var globalvar enum function constructor delete #macro #region #endregion",
+built_in:"is_real is_string is_array is_undefined is_int32 is_int64 is_ptr is_vec3 is_vec4 is_matrix is_bool is_method is_struct is_infinity is_nan is_numeric typeof variable_global_exists variable_global_get variable_global_set variable_instance_exists variable_instance_get variable_instance_set variable_instance_get_names variable_struct_exists variable_struct_get variable_struct_get_names variable_struct_names_count variable_struct_remove variable_struct_set array_delete array_insert array_length array_length_1d array_length_2d array_height_2d array_equals array_create array_copy array_pop array_push array_resize array_sort random random_range irandom irandom_range random_set_seed random_get_seed randomize randomise choose abs round floor ceil sign frac sqrt sqr exp ln log2 log10 sin cos tan arcsin arccos arctan arctan2 dsin dcos dtan darcsin darccos darctan darctan2 degtorad radtodeg power logn min max mean median clamp lerp dot_product dot_product_3d dot_product_normalised dot_product_3d_normalised dot_product_normalized dot_product_3d_normalized math_set_epsilon math_get_epsilon angle_difference point_distance_3d point_distance point_direction lengthdir_x lengthdir_y real string int64 ptr string_format chr ansi_char ord string_length string_byte_length string_pos string_copy string_char_at string_ord_at string_byte_at string_set_byte_at string_delete string_insert string_lower string_upper string_repeat string_letters string_digits string_lettersdigits string_replace string_replace_all string_count string_hash_to_newline clipboard_has_text clipboard_set_text clipboard_get_text date_current_datetime date_create_datetime date_valid_datetime date_inc_year date_inc_month date_inc_week date_inc_day date_inc_hour date_inc_minute date_inc_second date_get_year date_get_month date_get_week date_get_day date_get_hour date_get_minute date_get_second date_get_weekday date_get_day_of_year date_get_hour_of_year date_get_minute_of_year date_get_second_of_year date_year_span date_month_span date_week_span date_day_span date_hour_span date_minute_span date_second_span date_compare_datetime date_compare_date date_compare_time date_date_of date_time_of date_datetime_string date_date_string date_time_string date_days_in_month date_days_in_year date_leap_year date_is_today date_set_timezone date_get_timezone game_set_speed game_get_speed motion_set motion_add place_free place_empty place_meeting place_snapped move_random move_snap move_towards_point move_contact_solid move_contact_all move_outside_solid move_outside_all move_bounce_solid move_bounce_all move_wrap distance_to_point distance_to_object position_empty position_meeting path_start path_end mp_linear_step mp_potential_step mp_linear_step_object mp_potential_step_object mp_potential_settings mp_linear_path mp_potential_path mp_linear_path_object mp_potential_path_object mp_grid_create mp_grid_destroy mp_grid_clear_all mp_grid_clear_cell mp_grid_clear_rectangle mp_grid_add_cell mp_grid_get_cell mp_grid_add_rectangle mp_grid_add_instances mp_grid_path mp_grid_draw mp_grid_to_ds_grid collision_point collision_rectangle collision_circle collision_ellipse collision_line collision_point_list collision_rectangle_list collision_circle_list collision_ellipse_list collision_line_list instance_position_list instance_place_list point_in_rectangle point_in_triangle point_in_circle rectangle_in_rectangle rectangle_in_triangle rectangle_in_circle instance_find instance_exists instance_number instance_position instance_nearest instance_furthest instance_place instance_create_depth instance_create_layer instance_copy instance_change instance_destroy position_destroy position_change instance_id_get instance_deactivate_all instance_deactivate_object instance_deactivate_region instance_activate_all instance_activate_object instance_activate_region room_goto room_goto_previous room_goto_next room_previous room_next room_restart game_end game_restart game_load game_save game_save_buffer game_load_buffer event_perform event_user event_perform_object event_inherited show_debug_message show_debug_overlay debug_event debug_get_callstack alarm_get alarm_set font_texture_page_size keyboard_set_map keyboard_get_map keyboard_unset_map keyboard_check keyboard_check_pressed keyboard_check_released keyboard_check_direct keyboard_get_numlock keyboard_set_numlock keyboard_key_press keyboard_key_release keyboard_clear io_clear mouse_check_button mouse_check_button_pressed mouse_check_button_released mouse_wheel_up mouse_wheel_down mouse_clear draw_self draw_sprite draw_sprite_pos draw_sprite_ext draw_sprite_stretched draw_sprite_stretched_ext draw_sprite_tiled draw_sprite_tiled_ext draw_sprite_part draw_sprite_part_ext draw_sprite_general draw_clear draw_clear_alpha draw_point draw_line draw_line_width draw_rectangle draw_roundrect draw_roundrect_ext draw_triangle draw_circle draw_ellipse draw_set_circle_precision draw_arrow draw_button draw_path draw_healthbar draw_getpixel draw_getpixel_ext draw_set_colour draw_set_color draw_set_alpha draw_get_colour draw_get_color draw_get_alpha merge_colour make_colour_rgb make_colour_hsv colour_get_red colour_get_green colour_get_blue colour_get_hue colour_get_saturation colour_get_value merge_color make_color_rgb make_color_hsv color_get_red color_get_green color_get_blue color_get_hue color_get_saturation color_get_value merge_color screen_save screen_save_part draw_set_font draw_set_halign draw_set_valign draw_text draw_text_ext string_width string_height string_width_ext string_height_ext draw_text_transformed draw_text_ext_transformed draw_text_colour draw_text_ext_colour draw_text_transformed_colour draw_text_ext_transformed_colour draw_text_color draw_text_ext_color draw_text_transformed_color draw_text_ext_transformed_color draw_point_colour draw_line_colour draw_line_width_colour draw_rectangle_colour draw_roundrect_colour draw_roundrect_colour_ext draw_triangle_colour draw_circle_colour draw_ellipse_colour draw_point_color draw_line_color draw_line_width_color draw_rectangle_color draw_roundrect_color draw_roundrect_color_ext draw_triangle_color draw_circle_color draw_ellipse_color draw_primitive_begin draw_vertex draw_vertex_colour draw_vertex_color draw_primitive_end sprite_get_uvs font_get_uvs sprite_get_texture font_get_texture texture_get_width texture_get_height texture_get_uvs draw_primitive_begin_texture draw_vertex_texture draw_vertex_texture_colour draw_vertex_texture_color texture_global_scale surface_create surface_create_ext surface_resize surface_free surface_exists surface_get_width surface_get_height surface_get_texture surface_set_target surface_set_target_ext surface_reset_target surface_depth_disable surface_get_depth_disable draw_surface draw_surface_stretched draw_surface_tiled draw_surface_part draw_surface_ext draw_surface_stretched_ext draw_surface_tiled_ext draw_surface_part_ext draw_surface_general surface_getpixel surface_getpixel_ext surface_save surface_save_part surface_copy surface_copy_part application_surface_draw_enable application_get_position application_surface_enable application_surface_is_enabled display_get_width display_get_height display_get_orientation display_get_gui_width display_get_gui_height display_reset display_mouse_get_x display_mouse_get_y display_mouse_set display_set_ui_visibility window_set_fullscreen window_get_fullscreen window_set_caption window_set_min_width window_set_max_width window_set_min_height window_set_max_height window_get_visible_rects window_get_caption window_set_cursor window_get_cursor window_set_colour window_get_colour window_set_color window_get_color window_set_position window_set_size window_set_rectangle window_center window_get_x window_get_y window_get_width window_get_height window_mouse_get_x window_mouse_get_y window_mouse_set window_view_mouse_get_x window_view_mouse_get_y window_views_mouse_get_x window_views_mouse_get_y audio_listener_position audio_listener_velocity audio_listener_orientation audio_emitter_position audio_emitter_create audio_emitter_free audio_emitter_exists audio_emitter_pitch audio_emitter_velocity audio_emitter_falloff audio_emitter_gain audio_play_sound audio_play_sound_on audio_play_sound_at audio_stop_sound audio_resume_music audio_music_is_playing audio_resume_sound audio_pause_sound audio_pause_music audio_channel_num audio_sound_length audio_get_type audio_falloff_set_model audio_play_music audio_stop_music audio_master_gain audio_music_gain audio_sound_gain audio_sound_pitch audio_stop_all audio_resume_all audio_pause_all audio_is_playing audio_is_paused audio_exists audio_sound_set_track_position audio_sound_get_track_position audio_emitter_get_gain audio_emitter_get_pitch audio_emitter_get_x audio_emitter_get_y audio_emitter_get_z audio_emitter_get_vx audio_emitter_get_vy audio_emitter_get_vz audio_listener_set_position audio_listener_set_velocity audio_listener_set_orientation audio_listener_get_data audio_set_master_gain audio_get_master_gain audio_sound_get_gain audio_sound_get_pitch audio_get_name audio_sound_set_track_position audio_sound_get_track_position audio_create_stream audio_destroy_stream audio_create_sync_group audio_destroy_sync_group audio_play_in_sync_group audio_start_sync_group audio_stop_sync_group audio_pause_sync_group audio_resume_sync_group audio_sync_group_get_track_pos audio_sync_group_debug audio_sync_group_is_playing audio_debug audio_group_load audio_group_unload audio_group_is_loaded audio_group_load_progress audio_group_name audio_group_stop_all audio_group_set_gain audio_create_buffer_sound audio_free_buffer_sound audio_create_play_queue audio_free_play_queue audio_queue_sound audio_get_recorder_count audio_get_recorder_info audio_start_recording audio_stop_recording audio_sound_get_listener_mask audio_emitter_get_listener_mask audio_get_listener_mask audio_sound_set_listener_mask audio_emitter_set_listener_mask audio_set_listener_mask audio_get_listener_count audio_get_listener_info audio_system show_message show_message_async clickable_add clickable_add_ext clickable_change clickable_change_ext clickable_delete clickable_exists clickable_set_style show_question show_question_async get_integer get_string get_integer_async get_string_async get_login_async get_open_filename get_save_filename get_open_filename_ext get_save_filename_ext show_error highscore_clear highscore_add highscore_value highscore_name draw_highscore sprite_exists sprite_get_name sprite_get_number sprite_get_width sprite_get_height sprite_get_xoffset sprite_get_yoffset sprite_get_bbox_left sprite_get_bbox_right sprite_get_bbox_top sprite_get_bbox_bottom sprite_save sprite_save_strip sprite_set_cache_size sprite_set_cache_size_ext sprite_get_tpe sprite_prefetch sprite_prefetch_multi sprite_flush sprite_flush_multi sprite_set_speed sprite_get_speed_type sprite_get_speed font_exists font_get_name font_get_fontname font_get_bold font_get_italic font_get_first font_get_last font_get_size font_set_cache_size path_exists path_get_name path_get_length path_get_time path_get_kind path_get_closed path_get_precision path_get_number path_get_point_x path_get_point_y path_get_point_speed path_get_x path_get_y path_get_speed script_exists script_get_name timeline_add timeline_delete timeline_clear timeline_exists timeline_get_name timeline_moment_clear timeline_moment_add_script timeline_size timeline_max_moment object_exists object_get_name object_get_sprite object_get_solid object_get_visible object_get_persistent object_get_mask object_get_parent object_get_physics object_is_ancestor room_exists room_get_name sprite_set_offset sprite_duplicate sprite_assign sprite_merge sprite_add sprite_replace sprite_create_from_surface sprite_add_from_surface sprite_delete sprite_set_alpha_from_sprite sprite_collision_mask font_add_enable_aa font_add_get_enable_aa font_add font_add_sprite font_add_sprite_ext font_replace font_replace_sprite font_replace_sprite_ext font_delete path_set_kind path_set_closed path_set_precision path_add path_assign path_duplicate path_append path_delete path_add_point path_insert_point path_change_point path_delete_point path_clear_points path_reverse path_mirror path_flip path_rotate path_rescale path_shift script_execute object_set_sprite object_set_solid object_set_visible object_set_persistent object_set_mask room_set_width room_set_height room_set_persistent room_set_background_colour room_set_background_color room_set_view room_set_viewport room_get_viewport room_set_view_enabled room_add room_duplicate room_assign room_instance_add room_instance_clear room_get_camera room_set_camera asset_get_index asset_get_type file_text_open_from_string file_text_open_read file_text_open_write file_text_open_append file_text_close file_text_write_string file_text_write_real file_text_writeln file_text_read_string file_text_read_real file_text_readln file_text_eof file_text_eoln file_exists file_delete file_rename file_copy directory_exists directory_create directory_destroy file_find_first file_find_next file_find_close file_attributes filename_name filename_path filename_dir filename_drive filename_ext filename_change_ext file_bin_open file_bin_rewrite file_bin_close file_bin_position file_bin_size file_bin_seek file_bin_write_byte file_bin_read_byte parameter_count parameter_string environment_get_variable ini_open_from_string ini_open ini_close ini_read_string ini_read_real ini_write_string ini_write_real ini_key_exists ini_section_exists ini_key_delete ini_section_delete ds_set_precision ds_exists ds_stack_create ds_stack_destroy ds_stack_clear ds_stack_copy ds_stack_size ds_stack_empty ds_stack_push ds_stack_pop ds_stack_top ds_stack_write ds_stack_read ds_queue_create ds_queue_destroy ds_queue_clear ds_queue_copy ds_queue_size ds_queue_empty ds_queue_enqueue ds_queue_dequeue ds_queue_head ds_queue_tail ds_queue_write ds_queue_read ds_list_create ds_list_destroy ds_list_clear ds_list_copy ds_list_size ds_list_empty ds_list_add ds_list_insert ds_list_replace ds_list_delete ds_list_find_index ds_list_find_value ds_list_mark_as_list ds_list_mark_as_map ds_list_sort ds_list_shuffle ds_list_write ds_list_read ds_list_set ds_map_create ds_map_destroy ds_map_clear ds_map_copy ds_map_size ds_map_empty ds_map_add ds_map_add_list ds_map_add_map ds_map_replace ds_map_replace_map ds_map_replace_list ds_map_delete ds_map_exists ds_map_find_value ds_map_find_previous ds_map_find_next ds_map_find_first ds_map_find_last ds_map_write ds_map_read ds_map_secure_save ds_map_secure_load ds_map_secure_load_buffer ds_map_secure_save_buffer ds_map_set ds_priority_create ds_priority_destroy ds_priority_clear ds_priority_copy ds_priority_size ds_priority_empty ds_priority_add ds_priority_change_priority ds_priority_find_priority ds_priority_delete_value ds_priority_delete_min ds_priority_find_min ds_priority_delete_max ds_priority_find_max ds_priority_write ds_priority_read ds_grid_create ds_grid_destroy ds_grid_copy ds_grid_resize ds_grid_width ds_grid_height ds_grid_clear ds_grid_set ds_grid_add ds_grid_multiply ds_grid_set_region ds_grid_add_region ds_grid_multiply_region ds_grid_set_disk ds_grid_add_disk ds_grid_multiply_disk ds_grid_set_grid_region ds_grid_add_grid_region ds_grid_multiply_grid_region ds_grid_get ds_grid_get_sum ds_grid_get_max ds_grid_get_min ds_grid_get_mean ds_grid_get_disk_sum ds_grid_get_disk_min ds_grid_get_disk_max ds_grid_get_disk_mean ds_grid_value_exists ds_grid_value_x ds_grid_value_y ds_grid_value_disk_exists ds_grid_value_disk_x ds_grid_value_disk_y ds_grid_shuffle ds_grid_write ds_grid_read ds_grid_sort ds_grid_set ds_grid_get effect_create_below effect_create_above effect_clear part_type_create part_type_destroy part_type_exists part_type_clear part_type_shape part_type_sprite part_type_size part_type_scale part_type_orientation part_type_life part_type_step part_type_death part_type_speed part_type_direction part_type_gravity part_type_colour1 part_type_colour2 part_type_colour3 part_type_colour_mix part_type_colour_rgb part_type_colour_hsv part_type_color1 part_type_color2 part_type_color3 part_type_color_mix part_type_color_rgb part_type_color_hsv part_type_alpha1 part_type_alpha2 part_type_alpha3 part_type_blend part_system_create part_system_create_layer part_system_destroy part_system_exists part_system_clear part_system_draw_order part_system_depth part_system_position part_system_automatic_update part_system_automatic_draw part_system_update part_system_drawit part_system_get_layer part_system_layer part_particles_create part_particles_create_colour part_particles_create_color part_particles_clear part_particles_count part_emitter_create part_emitter_destroy part_emitter_destroy_all part_emitter_exists part_emitter_clear part_emitter_region part_emitter_burst part_emitter_stream external_call external_define external_free window_handle window_device matrix_get matrix_set matrix_build_identity matrix_build matrix_build_lookat matrix_build_projection_ortho matrix_build_projection_perspective matrix_build_projection_perspective_fov matrix_multiply matrix_transform_vertex matrix_stack_push matrix_stack_pop matrix_stack_multiply matrix_stack_set matrix_stack_clear matrix_stack_top matrix_stack_is_empty browser_input_capture os_get_config os_get_info os_get_language os_get_region os_lock_orientation display_get_dpi_x display_get_dpi_y display_set_gui_size display_set_gui_maximise display_set_gui_maximize device_mouse_dbclick_enable display_set_timing_method display_get_timing_method display_set_sleep_margin display_get_sleep_margin virtual_key_add virtual_key_hide virtual_key_delete virtual_key_show draw_enable_drawevent draw_enable_swf_aa draw_set_swf_aa_level draw_get_swf_aa_level draw_texture_flush draw_flush gpu_set_blendenable gpu_set_ztestenable gpu_set_zfunc gpu_set_zwriteenable gpu_set_lightingenable gpu_set_fog gpu_set_cullmode gpu_set_blendmode gpu_set_blendmode_ext gpu_set_blendmode_ext_sepalpha gpu_set_colorwriteenable gpu_set_colourwriteenable gpu_set_alphatestenable gpu_set_alphatestref gpu_set_alphatestfunc gpu_set_texfilter gpu_set_texfilter_ext gpu_set_texrepeat gpu_set_texrepeat_ext gpu_set_tex_filter gpu_set_tex_filter_ext gpu_set_tex_repeat gpu_set_tex_repeat_ext gpu_set_tex_mip_filter gpu_set_tex_mip_filter_ext gpu_set_tex_mip_bias gpu_set_tex_mip_bias_ext gpu_set_tex_min_mip gpu_set_tex_min_mip_ext gpu_set_tex_max_mip gpu_set_tex_max_mip_ext gpu_set_tex_max_aniso gpu_set_tex_max_aniso_ext gpu_set_tex_mip_enable gpu_set_tex_mip_enable_ext gpu_get_blendenable gpu_get_ztestenable gpu_get_zfunc gpu_get_zwriteenable gpu_get_lightingenable gpu_get_fog gpu_get_cullmode gpu_get_blendmode gpu_get_blendmode_ext gpu_get_blendmode_ext_sepalpha gpu_get_blendmode_src gpu_get_blendmode_dest gpu_get_blendmode_srcalpha gpu_get_blendmode_destalpha gpu_get_colorwriteenable gpu_get_colourwriteenable gpu_get_alphatestenable gpu_get_alphatestref gpu_get_alphatestfunc gpu_get_texfilter gpu_get_texfilter_ext gpu_get_texrepeat gpu_get_texrepeat_ext gpu_get_tex_filter gpu_get_tex_filter_ext gpu_get_tex_repeat gpu_get_tex_repeat_ext gpu_get_tex_mip_filter gpu_get_tex_mip_filter_ext gpu_get_tex_mip_bias gpu_get_tex_mip_bias_ext gpu_get_tex_min_mip gpu_get_tex_min_mip_ext gpu_get_tex_max_mip gpu_get_tex_max_mip_ext gpu_get_tex_max_aniso gpu_get_tex_max_aniso_ext gpu_get_tex_mip_enable gpu_get_tex_mip_enable_ext gpu_push_state gpu_pop_state gpu_get_state gpu_set_state draw_light_define_ambient draw_light_define_direction draw_light_define_point draw_light_enable draw_set_lighting draw_light_get_ambient draw_light_get draw_get_lighting shop_leave_rating url_get_domain url_open url_open_ext url_open_full get_timer achievement_login achievement_logout achievement_post achievement_increment achievement_post_score achievement_available achievement_show_achievements achievement_show_leaderboards achievement_load_friends achievement_load_leaderboard achievement_send_challenge achievement_load_progress achievement_reset achievement_login_status achievement_get_pic achievement_show_challenge_notifications achievement_get_challenges achievement_event achievement_show achievement_get_info cloud_file_save cloud_string_save cloud_synchronise ads_enable ads_disable ads_setup ads_engagement_launch ads_engagement_available ads_engagement_active ads_event ads_event_preload ads_set_reward_callback ads_get_display_height ads_get_display_width ads_move ads_interstitial_available ads_interstitial_display device_get_tilt_x device_get_tilt_y device_get_tilt_z device_is_keypad_open device_mouse_check_button device_mouse_check_button_pressed device_mouse_check_button_released device_mouse_x device_mouse_y device_mouse_raw_x device_mouse_raw_y device_mouse_x_to_gui device_mouse_y_to_gui iap_activate iap_status iap_enumerate_products iap_restore_all iap_acquire iap_consume iap_product_details iap_purchase_details facebook_init facebook_login facebook_status facebook_graph_request facebook_dialog facebook_logout facebook_launch_offerwall facebook_post_message facebook_send_invite facebook_user_id facebook_accesstoken facebook_check_permission facebook_request_read_permissions facebook_request_publish_permissions gamepad_is_supported gamepad_get_device_count gamepad_is_connected gamepad_get_description gamepad_get_button_threshold gamepad_set_button_threshold gamepad_get_axis_deadzone gamepad_set_axis_deadzone gamepad_button_count gamepad_button_check gamepad_button_check_pressed gamepad_button_check_released gamepad_button_value gamepad_axis_count gamepad_axis_value gamepad_set_vibration gamepad_set_colour gamepad_set_color os_is_paused window_has_focus code_is_compiled http_get http_get_file http_post_string http_request json_encode json_decode zip_unzip load_csv base64_encode base64_decode md5_string_unicode md5_string_utf8 md5_file os_is_network_connected sha1_string_unicode sha1_string_utf8 sha1_file os_powersave_enable analytics_event analytics_event_ext win8_livetile_tile_notification win8_livetile_tile_clear win8_livetile_badge_notification win8_livetile_badge_clear win8_livetile_queue_enable win8_secondarytile_pin win8_secondarytile_badge_notification win8_secondarytile_delete win8_livetile_notification_begin win8_livetile_notification_secondary_begin win8_livetile_notification_expiry win8_livetile_notification_tag win8_livetile_notification_text_add win8_livetile_notification_image_add win8_livetile_notification_end win8_appbar_enable win8_appbar_add_element win8_appbar_remove_element win8_settingscharm_add_entry win8_settingscharm_add_html_entry win8_settingscharm_add_xaml_entry win8_settingscharm_set_xaml_property win8_settingscharm_get_xaml_property win8_settingscharm_remove_entry win8_share_image win8_share_screenshot win8_share_file win8_share_url win8_share_text win8_search_enable win8_search_disable win8_search_add_suggestions win8_device_touchscreen_available win8_license_initialize_sandbox win8_license_trial_version winphone_license_trial_version winphone_tile_title winphone_tile_count winphone_tile_back_title winphone_tile_back_content winphone_tile_back_content_wide winphone_tile_front_image winphone_tile_front_image_small winphone_tile_front_image_wide winphone_tile_back_image winphone_tile_back_image_wide winphone_tile_background_colour winphone_tile_background_color winphone_tile_icon_image winphone_tile_small_icon_image winphone_tile_wide_content winphone_tile_cycle_images winphone_tile_small_background_image physics_world_create physics_world_gravity physics_world_update_speed physics_world_update_iterations physics_world_draw_debug physics_pause_enable physics_fixture_create physics_fixture_set_kinematic physics_fixture_set_density physics_fixture_set_awake physics_fixture_set_restitution physics_fixture_set_friction physics_fixture_set_collision_group physics_fixture_set_sensor physics_fixture_set_linear_damping physics_fixture_set_angular_damping physics_fixture_set_circle_shape physics_fixture_set_box_shape physics_fixture_set_edge_shape physics_fixture_set_polygon_shape physics_fixture_set_chain_shape physics_fixture_add_point physics_fixture_bind physics_fixture_bind_ext physics_fixture_delete physics_apply_force physics_apply_impulse physics_apply_angular_impulse physics_apply_local_force physics_apply_local_impulse physics_apply_torque physics_mass_properties physics_draw_debug physics_test_overlap physics_remove_fixture physics_set_friction physics_set_density physics_set_restitution physics_get_friction physics_get_density physics_get_restitution physics_joint_distance_create physics_joint_rope_create physics_joint_revolute_create physics_joint_prismatic_create physics_joint_pulley_create physics_joint_wheel_create physics_joint_weld_create physics_joint_friction_create physics_joint_gear_create physics_joint_enable_motor physics_joint_get_value physics_joint_set_value physics_joint_delete physics_particle_create physics_particle_delete physics_particle_delete_region_circle physics_particle_delete_region_box physics_particle_delete_region_poly physics_particle_set_flags physics_particle_set_category_flags physics_particle_draw physics_particle_draw_ext physics_particle_count physics_particle_get_data physics_particle_get_data_particle physics_particle_group_begin physics_particle_group_circle physics_particle_group_box physics_particle_group_polygon physics_particle_group_add_point physics_particle_group_end physics_particle_group_join physics_particle_group_delete physics_particle_group_count physics_particle_group_get_data physics_particle_group_get_mass physics_particle_group_get_inertia physics_particle_group_get_centre_x physics_particle_group_get_centre_y physics_particle_group_get_vel_x physics_particle_group_get_vel_y physics_particle_group_get_ang_vel physics_particle_group_get_x physics_particle_group_get_y physics_particle_group_get_angle physics_particle_set_group_flags physics_particle_get_group_flags physics_particle_get_max_count physics_particle_get_radius physics_particle_get_density physics_particle_get_damping physics_particle_get_gravity_scale physics_particle_set_max_count physics_particle_set_radius physics_particle_set_density physics_particle_set_damping physics_particle_set_gravity_scale network_create_socket network_create_socket_ext network_create_server network_create_server_raw network_connect network_connect_raw network_send_packet network_send_raw network_send_broadcast network_send_udp network_send_udp_raw network_set_timeout network_set_config network_resolve network_destroy buffer_create buffer_write buffer_read buffer_seek buffer_get_surface buffer_set_surface buffer_delete buffer_exists buffer_get_type buffer_get_alignment buffer_poke buffer_peek buffer_save buffer_save_ext buffer_load buffer_load_ext buffer_load_partial buffer_copy buffer_fill buffer_get_size buffer_tell buffer_resize buffer_md5 buffer_sha1 buffer_base64_encode buffer_base64_decode buffer_base64_decode_ext buffer_sizeof buffer_get_address buffer_create_from_vertex_buffer buffer_create_from_vertex_buffer_ext buffer_copy_from_vertex_buffer buffer_async_group_begin buffer_async_group_option buffer_async_group_end buffer_load_async buffer_save_async gml_release_mode gml_pragma steam_activate_overlay steam_is_overlay_enabled steam_is_overlay_activated steam_get_persona_name steam_initialised steam_is_cloud_enabled_for_app steam_is_cloud_enabled_for_account steam_file_persisted steam_get_quota_total steam_get_quota_free steam_file_write steam_file_write_file steam_file_read steam_file_delete steam_file_exists steam_file_size steam_file_share steam_is_screenshot_requested steam_send_screenshot steam_is_user_logged_on steam_get_user_steam_id steam_user_owns_dlc steam_user_installed_dlc steam_set_achievement steam_get_achievement steam_clear_achievement steam_set_stat_int steam_set_stat_float steam_set_stat_avg_rate steam_get_stat_int steam_get_stat_float steam_get_stat_avg_rate steam_reset_all_stats steam_reset_all_stats_achievements steam_stats_ready steam_create_leaderboard steam_upload_score steam_upload_score_ext steam_download_scores_around_user steam_download_scores steam_download_friends_scores steam_upload_score_buffer steam_upload_score_buffer_ext steam_current_game_language steam_available_languages steam_activate_overlay_browser steam_activate_overlay_user steam_activate_overlay_store steam_get_user_persona_name steam_get_app_id steam_get_user_account_id steam_ugc_download steam_ugc_create_item steam_ugc_start_item_update steam_ugc_set_item_title steam_ugc_set_item_description steam_ugc_set_item_visibility steam_ugc_set_item_tags steam_ugc_set_item_content steam_ugc_set_item_preview steam_ugc_submit_item_update steam_ugc_get_item_update_progress steam_ugc_subscribe_item steam_ugc_unsubscribe_item steam_ugc_num_subscribed_items steam_ugc_get_subscribed_items steam_ugc_get_item_install_info steam_ugc_get_item_update_info steam_ugc_request_item_details steam_ugc_create_query_user steam_ugc_create_query_user_ex steam_ugc_create_query_all steam_ugc_create_query_all_ex steam_ugc_query_set_cloud_filename_filter steam_ugc_query_set_match_any_tag steam_ugc_query_set_search_text steam_ugc_query_set_ranked_by_trend_days steam_ugc_query_add_required_tag steam_ugc_query_add_excluded_tag steam_ugc_query_set_return_long_description steam_ugc_query_set_return_total_only steam_ugc_query_set_allow_cached_response steam_ugc_send_query shader_set shader_get_name shader_reset shader_current shader_is_compiled shader_get_sampler_index shader_get_uniform shader_set_uniform_i shader_set_uniform_i_array shader_set_uniform_f shader_set_uniform_f_array shader_set_uniform_matrix shader_set_uniform_matrix_array shader_enable_corner_id texture_set_stage texture_get_texel_width texture_get_texel_height shaders_are_supported vertex_format_begin vertex_format_end vertex_format_delete vertex_format_add_position vertex_format_add_position_3d vertex_format_add_colour vertex_format_add_color vertex_format_add_normal vertex_format_add_texcoord vertex_format_add_textcoord vertex_format_add_custom vertex_create_buffer vertex_create_buffer_ext vertex_delete_buffer vertex_begin vertex_end vertex_position vertex_position_3d vertex_colour vertex_color vertex_argb vertex_texcoord vertex_normal vertex_float1 vertex_float2 vertex_float3 vertex_float4 vertex_ubyte4 vertex_submit vertex_freeze vertex_get_number vertex_get_buffer_size vertex_create_buffer_from_buffer vertex_create_buffer_from_buffer_ext push_local_notification push_get_first_local_notification push_get_next_local_notification push_cancel_local_notification skeleton_animation_set skeleton_animation_get skeleton_animation_mix skeleton_animation_set_ext skeleton_animation_get_ext skeleton_animation_get_duration skeleton_animation_get_frames skeleton_animation_clear skeleton_skin_set skeleton_skin_get skeleton_attachment_set skeleton_attachment_get skeleton_attachment_create skeleton_collision_draw_set skeleton_bone_data_get skeleton_bone_data_set skeleton_bone_state_get skeleton_bone_state_set skeleton_get_minmax skeleton_get_num_bounds skeleton_get_bounds skeleton_animation_get_frame skeleton_animation_set_frame draw_skeleton draw_skeleton_time draw_skeleton_instance draw_skeleton_collision skeleton_animation_list skeleton_skin_list skeleton_slot_data layer_get_id layer_get_id_at_depth layer_get_depth layer_create layer_destroy layer_destroy_instances layer_add_instance layer_has_instance layer_set_visible layer_get_visible layer_exists layer_x layer_y layer_get_x layer_get_y layer_hspeed layer_vspeed layer_get_hspeed layer_get_vspeed layer_script_begin layer_script_end layer_shader layer_get_script_begin layer_get_script_end layer_get_shader layer_set_target_room layer_get_target_room layer_reset_target_room layer_get_all layer_get_all_elements layer_get_name layer_depth layer_get_element_layer layer_get_element_type layer_element_move layer_force_draw_depth layer_is_draw_depth_forced layer_get_forced_depth layer_background_get_id layer_background_exists layer_background_create layer_background_destroy layer_background_visible layer_background_change layer_background_sprite layer_background_htiled layer_background_vtiled layer_background_stretch layer_background_yscale layer_background_xscale layer_background_blend layer_background_alpha layer_background_index layer_background_speed layer_background_get_visible layer_background_get_sprite layer_background_get_htiled layer_background_get_vtiled layer_background_get_stretch layer_background_get_yscale layer_background_get_xscale layer_background_get_blend layer_background_get_alpha layer_background_get_index layer_background_get_speed layer_sprite_get_id layer_sprite_exists layer_sprite_create layer_sprite_destroy layer_sprite_change layer_sprite_index layer_sprite_speed layer_sprite_xscale layer_sprite_yscale layer_sprite_angle layer_sprite_blend layer_sprite_alpha layer_sprite_x layer_sprite_y layer_sprite_get_sprite layer_sprite_get_index layer_sprite_get_speed layer_sprite_get_xscale layer_sprite_get_yscale layer_sprite_get_angle layer_sprite_get_blend layer_sprite_get_alpha layer_sprite_get_x layer_sprite_get_y layer_tilemap_get_id layer_tilemap_exists layer_tilemap_create layer_tilemap_destroy tilemap_tileset tilemap_x tilemap_y tilemap_set tilemap_set_at_pixel tilemap_get_tileset tilemap_get_tile_width tilemap_get_tile_height tilemap_get_width tilemap_get_height tilemap_get_x tilemap_get_y tilemap_get tilemap_get_at_pixel tilemap_get_cell_x_at_pixel tilemap_get_cell_y_at_pixel tilemap_clear draw_tilemap draw_tile tilemap_set_global_mask tilemap_get_global_mask tilemap_set_mask tilemap_get_mask tilemap_get_frame tile_set_empty tile_set_index tile_set_flip tile_set_mirror tile_set_rotate tile_get_empty tile_get_index tile_get_flip tile_get_mirror tile_get_rotate layer_tile_exists layer_tile_create layer_tile_destroy layer_tile_change layer_tile_xscale layer_tile_yscale layer_tile_blend layer_tile_alpha layer_tile_x layer_tile_y layer_tile_region layer_tile_visible layer_tile_get_sprite layer_tile_get_xscale layer_tile_get_yscale layer_tile_get_blend layer_tile_get_alpha layer_tile_get_x layer_tile_get_y layer_tile_get_region layer_tile_get_visible layer_instance_get_instance instance_activate_layer instance_deactivate_layer camera_create camera_create_view camera_destroy camera_apply camera_get_active camera_get_default camera_set_default camera_set_view_mat camera_set_proj_mat camera_set_update_script camera_set_begin_script camera_set_end_script camera_set_view_pos camera_set_view_size camera_set_view_speed camera_set_view_border camera_set_view_angle camera_set_view_target camera_get_view_mat camera_get_proj_mat camera_get_update_script camera_get_begin_script camera_get_end_script camera_get_view_x camera_get_view_y camera_get_view_width camera_get_view_height camera_get_view_speed_x camera_get_view_speed_y camera_get_view_border_x camera_get_view_border_y camera_get_view_angle camera_get_view_target view_get_camera view_get_visible view_get_xport view_get_yport view_get_wport view_get_hport view_get_surface_id view_set_camera view_set_visible view_set_xport view_set_yport view_set_wport view_set_hport view_set_surface_id gesture_drag_time gesture_drag_distance gesture_flick_speed gesture_double_tap_time gesture_double_tap_distance gesture_pinch_distance gesture_pinch_angle_towards gesture_pinch_angle_away gesture_rotate_time gesture_rotate_angle gesture_tap_count gesture_get_drag_time gesture_get_drag_distance gesture_get_flick_speed gesture_get_double_tap_time gesture_get_double_tap_distance gesture_get_pinch_distance gesture_get_pinch_angle_towards gesture_get_pinch_angle_away gesture_get_rotate_time gesture_get_rotate_angle gesture_get_tap_count keyboard_virtual_show keyboard_virtual_hide keyboard_virtual_status keyboard_virtual_height",
 literal:"self other all noone global local undefined pointer_invalid pointer_null path_action_stop path_action_restart path_action_continue path_action_reverse true false pi GM_build_date GM_version GM_runtime_version  timezone_local timezone_utc gamespeed_fps gamespeed_microseconds  ev_create ev_destroy ev_step ev_alarm ev_keyboard ev_mouse ev_collision ev_other ev_draw ev_draw_begin ev_draw_end ev_draw_pre ev_draw_post ev_keypress ev_keyrelease ev_trigger ev_left_button ev_right_button ev_middle_button ev_no_button ev_left_press ev_right_press ev_middle_press ev_left_release ev_right_release ev_middle_release ev_mouse_enter ev_mouse_leave ev_mouse_wheel_up ev_mouse_wheel_down ev_global_left_button ev_global_right_button ev_global_middle_button ev_global_left_press ev_global_right_press ev_global_middle_press ev_global_left_release ev_global_right_release ev_global_middle_release ev_joystick1_left ev_joystick1_right ev_joystick1_up ev_joystick1_down ev_joystick1_button1 ev_joystick1_button2 ev_joystick1_button3 ev_joystick1_button4 ev_joystick1_button5 ev_joystick1_button6 ev_joystick1_button7 ev_joystick1_button8 ev_joystick2_left ev_joystick2_right ev_joystick2_up ev_joystick2_down ev_joystick2_button1 ev_joystick2_button2 ev_joystick2_button3 ev_joystick2_button4 ev_joystick2_button5 ev_joystick2_button6 ev_joystick2_button7 ev_joystick2_button8 ev_outside ev_boundary ev_game_start ev_game_end ev_room_start ev_room_end ev_no_more_lives ev_animation_end ev_end_of_path ev_no_more_health ev_close_button ev_user0 ev_user1 ev_user2 ev_user3 ev_user4 ev_user5 ev_user6 ev_user7 ev_user8 ev_user9 ev_user10 ev_user11 ev_user12 ev_user13 ev_user14 ev_user15 ev_step_normal ev_step_begin ev_step_end ev_gui ev_gui_begin ev_gui_end ev_cleanup ev_gesture ev_gesture_tap ev_gesture_double_tap ev_gesture_drag_start ev_gesture_dragging ev_gesture_drag_end ev_gesture_flick ev_gesture_pinch_start ev_gesture_pinch_in ev_gesture_pinch_out ev_gesture_pinch_end ev_gesture_rotate_start ev_gesture_rotating ev_gesture_rotate_end ev_global_gesture_tap ev_global_gesture_double_tap ev_global_gesture_drag_start ev_global_gesture_dragging ev_global_gesture_drag_end ev_global_gesture_flick ev_global_gesture_pinch_start ev_global_gesture_pinch_in ev_global_gesture_pinch_out ev_global_gesture_pinch_end ev_global_gesture_rotate_start ev_global_gesture_rotating ev_global_gesture_rotate_end vk_nokey vk_anykey vk_enter vk_return vk_shift vk_control vk_alt vk_escape vk_space vk_backspace vk_tab vk_pause vk_printscreen vk_left vk_right vk_up vk_down vk_home vk_end vk_delete vk_insert vk_pageup vk_pagedown vk_f1 vk_f2 vk_f3 vk_f4 vk_f5 vk_f6 vk_f7 vk_f8 vk_f9 vk_f10 vk_f11 vk_f12 vk_numpad0 vk_numpad1 vk_numpad2 vk_numpad3 vk_numpad4 vk_numpad5 vk_numpad6 vk_numpad7 vk_numpad8 vk_numpad9 vk_divide vk_multiply vk_subtract vk_add vk_decimal vk_lshift vk_lcontrol vk_lalt vk_rshift vk_rcontrol vk_ralt  mb_any mb_none mb_left mb_right mb_middle c_aqua c_black c_blue c_dkgray c_fuchsia c_gray c_green c_lime c_ltgray c_maroon c_navy c_olive c_purple c_red c_silver c_teal c_white c_yellow c_orange fa_left fa_center fa_right fa_top fa_middle fa_bottom pr_pointlist pr_linelist pr_linestrip pr_trianglelist pr_trianglestrip pr_trianglefan bm_complex bm_normal bm_add bm_max bm_subtract bm_zero bm_one bm_src_colour bm_inv_src_colour bm_src_color bm_inv_src_color bm_src_alpha bm_inv_src_alpha bm_dest_alpha bm_inv_dest_alpha bm_dest_colour bm_inv_dest_colour bm_dest_color bm_inv_dest_color bm_src_alpha_sat tf_point tf_linear tf_anisotropic mip_off mip_on mip_markedonly audio_falloff_none audio_falloff_inverse_distance audio_falloff_inverse_distance_clamped audio_falloff_linear_distance audio_falloff_linear_distance_clamped audio_falloff_exponent_distance audio_falloff_exponent_distance_clamped audio_old_system audio_new_system audio_mono audio_stereo audio_3d cr_default cr_none cr_arrow cr_cross cr_beam cr_size_nesw cr_size_ns cr_size_nwse cr_size_we cr_uparrow cr_hourglass cr_drag cr_appstart cr_handpoint cr_size_all spritespeed_framespersecond spritespeed_framespergameframe asset_object asset_unknown asset_sprite asset_sound asset_room asset_path asset_script asset_font asset_timeline asset_tiles asset_shader fa_readonly fa_hidden fa_sysfile fa_volumeid fa_directory fa_archive  ds_type_map ds_type_list ds_type_stack ds_type_queue ds_type_grid ds_type_priority ef_explosion ef_ring ef_ellipse ef_firework ef_smoke ef_smokeup ef_star ef_spark ef_flare ef_cloud ef_rain ef_snow pt_shape_pixel pt_shape_disk pt_shape_square pt_shape_line pt_shape_star pt_shape_circle pt_shape_ring pt_shape_sphere pt_shape_flare pt_shape_spark pt_shape_explosion pt_shape_cloud pt_shape_smoke pt_shape_snow ps_distr_linear ps_distr_gaussian ps_distr_invgaussian ps_shape_rectangle ps_shape_ellipse ps_shape_diamond ps_shape_line ty_real ty_string dll_cdecl dll_stdcall matrix_view matrix_projection matrix_world os_win32 os_windows os_macosx os_ios os_android os_symbian os_linux os_unknown os_winphone os_tizen os_win8native os_wiiu os_3ds  os_psvita os_bb10 os_ps4 os_xboxone os_ps3 os_xbox360 os_uwp os_tvos os_switch browser_not_a_browser browser_unknown browser_ie browser_firefox browser_chrome browser_safari browser_safari_mobile browser_opera browser_tizen browser_edge browser_windows_store browser_ie_mobile  device_ios_unknown device_ios_iphone device_ios_iphone_retina device_ios_ipad device_ios_ipad_retina device_ios_iphone5 device_ios_iphone6 device_ios_iphone6plus device_emulator device_tablet display_landscape display_landscape_flipped display_portrait display_portrait_flipped tm_sleep tm_countvsyncs of_challenge_win of_challen ge_lose of_challenge_tie leaderboard_type_number leaderboard_type_time_mins_secs cmpfunc_never cmpfunc_less cmpfunc_equal cmpfunc_lessequal cmpfunc_greater cmpfunc_notequal cmpfunc_greaterequal cmpfunc_always cull_noculling cull_clockwise cull_counterclockwise lighttype_dir lighttype_point iap_ev_storeload iap_ev_product iap_ev_purchase iap_ev_consume iap_ev_restore iap_storeload_ok iap_storeload_failed iap_status_uninitialised iap_status_unavailable iap_status_loading iap_status_available iap_status_processing iap_status_restoring iap_failed iap_unavailable iap_available iap_purchased iap_canceled iap_refunded fb_login_default fb_login_fallback_to_webview fb_login_no_fallback_to_webview fb_login_forcing_webview fb_login_use_system_account fb_login_forcing_safari  phy_joint_anchor_1_x phy_joint_anchor_1_y phy_joint_anchor_2_x phy_joint_anchor_2_y phy_joint_reaction_force_x phy_joint_reaction_force_y phy_joint_reaction_torque phy_joint_motor_speed phy_joint_angle phy_joint_motor_torque phy_joint_max_motor_torque phy_joint_translation phy_joint_speed phy_joint_motor_force phy_joint_max_motor_force phy_joint_length_1 phy_joint_length_2 phy_joint_damping_ratio phy_joint_frequency phy_joint_lower_angle_limit phy_joint_upper_angle_limit phy_joint_angle_limits phy_joint_max_length phy_joint_max_torque phy_joint_max_force phy_debug_render_aabb phy_debug_render_collision_pairs phy_debug_render_coms phy_debug_render_core_shapes phy_debug_render_joints phy_debug_render_obb phy_debug_render_shapes  phy_particle_flag_water phy_particle_flag_zombie phy_particle_flag_wall phy_particle_flag_spring phy_particle_flag_elastic phy_particle_flag_viscous phy_particle_flag_powder phy_particle_flag_tensile phy_particle_flag_colourmixing phy_particle_flag_colormixing phy_particle_group_flag_solid phy_particle_group_flag_rigid phy_particle_data_flag_typeflags phy_particle_data_flag_position phy_particle_data_flag_velocity phy_particle_data_flag_colour phy_particle_data_flag_color phy_particle_data_flag_category  achievement_our_info achievement_friends_info achievement_leaderboard_info achievement_achievement_info achievement_filter_all_players achievement_filter_friends_only achievement_filter_favorites_only achievement_type_achievement_challenge achievement_type_score_challenge achievement_pic_loaded  achievement_show_ui achievement_show_profile achievement_show_leaderboard achievement_show_achievement achievement_show_bank achievement_show_friend_picker achievement_show_purchase_prompt network_socket_tcp network_socket_udp network_socket_bluetooth network_type_connect network_type_disconnect network_type_data network_type_non_blocking_connect network_config_connect_timeout network_config_use_non_blocking_socket network_config_enable_reliable_udp network_config_disable_reliable_udp buffer_fixed buffer_grow buffer_wrap buffer_fast buffer_vbuffer buffer_network buffer_u8 buffer_s8 buffer_u16 buffer_s16 buffer_u32 buffer_s32 buffer_u64 buffer_f16 buffer_f32 buffer_f64 buffer_bool buffer_text buffer_string buffer_surface_copy buffer_seek_start buffer_seek_relative buffer_seek_end buffer_generalerror buffer_outofspace buffer_outofbounds buffer_invalidtype  text_type button_type input_type ANSI_CHARSET DEFAULT_CHARSET EASTEUROPE_CHARSET RUSSIAN_CHARSET SYMBOL_CHARSET SHIFTJIS_CHARSET HANGEUL_CHARSET GB2312_CHARSET CHINESEBIG5_CHARSET JOHAB_CHARSET HEBREW_CHARSET ARABIC_CHARSET GREEK_CHARSET TURKISH_CHARSET VIETNAMESE_CHARSET THAI_CHARSET MAC_CHARSET BALTIC_CHARSET OEM_CHARSET  gp_face1 gp_face2 gp_face3 gp_face4 gp_shoulderl gp_shoulderr gp_shoulderlb gp_shoulderrb gp_select gp_start gp_stickl gp_stickr gp_padu gp_padd gp_padl gp_padr gp_axislh gp_axislv gp_axisrh gp_axisrv ov_friends ov_community ov_players ov_settings ov_gamegroup ov_achievements lb_sort_none lb_sort_ascending lb_sort_descending lb_disp_none lb_disp_numeric lb_disp_time_sec lb_disp_time_ms ugc_result_success ugc_filetype_community ugc_filetype_microtrans ugc_visibility_public ugc_visibility_friends_only ugc_visibility_private ugc_query_RankedByVote ugc_query_RankedByPublicationDate ugc_query_AcceptedForGameRankedByAcceptanceDate ugc_query_RankedByTrend ugc_query_FavoritedByFriendsRankedByPublicationDate ugc_query_CreatedByFriendsRankedByPublicationDate ugc_query_RankedByNumTimesReported ugc_query_CreatedByFollowedUsersRankedByPublicationDate ugc_query_NotYetRated ugc_query_RankedByTotalVotesAsc ugc_query_RankedByVotesUp ugc_query_RankedByTextSearch ugc_sortorder_CreationOrderDesc ugc_sortorder_CreationOrderAsc ugc_sortorder_TitleAsc ugc_sortorder_LastUpdatedDesc ugc_sortorder_SubscriptionDateDesc ugc_sortorder_VoteScoreDesc ugc_sortorder_ForModeration ugc_list_Published ugc_list_VotedOn ugc_list_VotedUp ugc_list_VotedDown ugc_list_WillVoteLater ugc_list_Favorited ugc_list_Subscribed ugc_list_UsedOrPlayed ugc_list_Followed ugc_match_Items ugc_match_Items_Mtx ugc_match_Items_ReadyToUse ugc_match_Collections ugc_match_Artwork ugc_match_Videos ugc_match_Screenshots ugc_match_AllGuides ugc_match_WebGuides ugc_match_IntegratedGuides ugc_match_UsableInGame ugc_match_ControllerBindings  vertex_usage_position vertex_usage_colour vertex_usage_color vertex_usage_normal vertex_usage_texcoord vertex_usage_textcoord vertex_usage_blendweight vertex_usage_blendindices vertex_usage_psize vertex_usage_tangent vertex_usage_binormal vertex_usage_fog vertex_usage_depth vertex_usage_sample vertex_type_float1 vertex_type_float2 vertex_type_float3 vertex_type_float4 vertex_type_colour vertex_type_color vertex_type_ubyte4 layerelementtype_undefined layerelementtype_background layerelementtype_instance layerelementtype_oldtilemap layerelementtype_sprite layerelementtype_tilemap layerelementtype_particlesystem layerelementtype_tile tile_rotate tile_flip tile_mirror tile_index_mask kbv_type_default kbv_type_ascii kbv_type_url kbv_type_email kbv_type_numbers kbv_type_phone kbv_type_phone_name kbv_returnkey_default kbv_returnkey_go kbv_returnkey_google kbv_returnkey_join kbv_returnkey_next kbv_returnkey_route kbv_returnkey_search kbv_returnkey_send kbv_returnkey_yahoo kbv_returnkey_done kbv_returnkey_continue kbv_returnkey_emergency kbv_autocapitalize_none kbv_autocapitalize_words kbv_autocapitalize_sentences kbv_autocapitalize_characters",
 symbol:"argument_relative argument argument0 argument1 argument2 argument3 argument4 argument5 argument6 argument7 argument8 argument9 argument10 argument11 argument12 argument13 argument14 argument15 argument_count x|0 y|0 xprevious yprevious xstart ystart hspeed vspeed direction speed friction gravity gravity_direction path_index path_position path_positionprevious path_speed path_scale path_orientation path_endaction object_index id solid persistent mask_index instance_count instance_id room_speed fps fps_real current_time current_year current_month current_day current_weekday current_hour current_minute current_second alarm timeline_index timeline_position timeline_speed timeline_running timeline_loop room room_first room_last room_width room_height room_caption room_persistent score lives health show_score show_lives show_health caption_score caption_lives caption_health event_type event_number event_object event_action application_surface gamemaker_pro gamemaker_registered gamemaker_version error_occurred error_last debug_mode keyboard_key keyboard_lastkey keyboard_lastchar keyboard_string mouse_x mouse_y mouse_button mouse_lastbutton cursor_sprite visible sprite_index sprite_width sprite_height sprite_xoffset sprite_yoffset image_number image_index image_speed depth image_xscale image_yscale image_angle image_alpha image_blend bbox_left bbox_right bbox_top bbox_bottom layer background_colour  background_showcolour background_color background_showcolor view_enabled view_current view_visible view_xview view_yview view_wview view_hview view_xport view_yport view_wport view_hport view_angle view_hborder view_vborder view_hspeed view_vspeed view_object view_surface_id view_camera game_id game_display_name game_project_name game_save_id working_directory temp_directory program_directory browser_width browser_height os_type os_device os_browser os_version display_aa async_load delta_time webgl_enabled event_data iap_data phy_rotation phy_position_x phy_position_y phy_angular_velocity phy_linear_velocity_x phy_linear_velocity_y phy_speed_x phy_speed_y phy_speed phy_angular_damping phy_linear_damping phy_bullet phy_fixed_rotation phy_active phy_mass phy_inertia phy_com_x phy_com_y phy_dynamic phy_kinematic phy_sleeping phy_collision_points phy_collision_x phy_collision_y phy_col_normal_x phy_col_normal_y phy_position_xprevious phy_position_yprevious"
 },
@@ -1826,7 +1833,7 @@
 end:"[ \\t]*=",excludeEnd:!0},A={className:"variable",keywords:C,begin:E,
 relevance:0,contains:[N,I]
 },e="[A-Za-z\u0410-\u042f\u0430-\u044f\u0451\u0401_][A-Za-z\u0410-\u042f\u0430-\u044f\u0451\u0401_0-9]*\\("
-;return{name:"ISBL",aliases:["isbl"],case_insensitive:!0,keywords:C,
+;return{name:"ISBL",case_insensitive:!0,keywords:C,
 illegal:"\\$|\\?|%|,|;$|~|#|@|</",contains:[{className:"function",begin:e,
 end:"\\)$",returnBegin:!0,keywords:C,illegal:"[\\[\\]\\|\\$\\?%,~#@]",
 contains:[{className:"title",keywords:{$pattern:E,
@@ -1869,7 +1876,7 @@
 contains:[s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.C_BLOCK_COMMENT_MODE]
 },e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},r,s]}}})());
 hljs.registerLanguage("javascript",(()=>{"use strict"
-;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],a=["true","false","null","undefined","NaN","Infinity"],s=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
+;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],a=["true","false","null","undefined","NaN","Infinity"],s=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer","BigInt64Array","BigUint64Array","BigInt"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
 ;function r(e){return t("(?=",e,")")}function t(...e){return e.map((e=>{
 return(n=e)?"string"==typeof n?n:n.source:null;var n})).join("")}return i=>{
 const c=e,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,
@@ -1877,10 +1884,10 @@
 ;"<"!==s?">"===s&&(((e,{after:n})=>{const a="</"+e[0].slice(1)
 ;return-1!==e.input.indexOf(a,n)})(e,{after:a
 })||n.ignoreMatch()):n.ignoreMatch()}},l={$pattern:e,keyword:n,literal:a,
-built_in:s},b="\\.([0-9](_?[0-9])*)",g="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={
+built_in:s},g="\\.([0-9](_?[0-9])*)",b="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={
 className:"number",variants:[{
-begin:`(\\b(${g})((${b})|\\.)?|(${b}))[eE][+-]?([0-9](_?[0-9])*)\\b`},{
-begin:`\\b(${g})\\b((${b})\\b|\\.)?|(${b})\\b`},{
+begin:`(\\b(${b})((${g})|\\.)?|(${g}))[eE][+-]?([0-9](_?[0-9])*)\\b`},{
+begin:`\\b(${b})\\b((${g})\\b|\\.)?|(${g})\\b`},{
 begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{
 begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{
 begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{
@@ -1889,30 +1896,30 @@
 returnEnd:!1,contains:[i.BACKSLASH_ESCAPE,E],subLanguage:"xml"}},_={
 begin:"css`",end:"",starts:{end:"`",returnEnd:!1,
 contains:[i.BACKSLASH_ESCAPE,E],subLanguage:"css"}},m={className:"string",
-begin:"`",end:"`",contains:[i.BACKSLASH_ESCAPE,E]},N={className:"comment",
+begin:"`",end:"`",contains:[i.BACKSLASH_ESCAPE,E]},y={className:"comment",
 variants:[i.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{
 className:"doctag",begin:"@[A-Za-z]+",contains:[{className:"type",begin:"\\{",
 end:"\\}",relevance:0},{className:"variable",begin:c+"(?=\\s*(-)|$)",
 endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]
 }),i.C_BLOCK_COMMENT_MODE,i.C_LINE_COMMENT_MODE]
-},y=[i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,u,_,m,d,i.REGEXP_MODE]
-;E.contains=y.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(y)
-});const f=[].concat(N,E.contains),A=f.concat([{begin:/\(/,end:/\)/,keywords:l,
-contains:["self"].concat(f)}]),p={className:"params",begin:/\(/,end:/\)/,
-excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A};return{name:"Javascript",
-aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:A},
+},N=[i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,u,_,m,d,i.REGEXP_MODE]
+;E.contains=N.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(N)
+});const A=[].concat(y,E.contains),f=A.concat([{begin:/\(/,end:/\)/,keywords:l,
+contains:["self"].concat(A)}]),p={className:"params",begin:/\(/,end:/\)/,
+excludeBegin:!0,excludeEnd:!0,keywords:l,contains:f};return{name:"Javascript",
+aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:f},
 illegal:/#(?![$_A-z])/,contains:[i.SHEBANG({label:"shebang",binary:"node",
 relevance:5}),{label:"use_strict",className:"meta",relevance:10,
 begin:/^\s*['"]use (strict|asm)['"]/
-},i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,u,_,m,N,d,{
+},i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,u,_,m,y,d,{
 begin:t(/[{,\n]\s*/,r(t(/(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,c+"\\s*:"))),
 relevance:0,contains:[{className:"attr",begin:c+r("\\s*:"),relevance:0}]},{
 begin:"("+i.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",
-keywords:"return throw case",contains:[N,i.REGEXP_MODE,{className:"function",
+keywords:"return throw case",contains:[y,i.REGEXP_MODE,{className:"function",
 begin:"(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+i.UNDERSCORE_IDENT_RE+")\\s*=>",
 returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{
 begin:i.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0
-},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A}]}]
+},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:f}]}]
 },{begin:/,/,relevance:0},{className:"",begin:/\s/,end:/\s*/,skip:!0},{
 variants:[{begin:"<>",end:"</>"},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,
 end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,
@@ -1992,9 +1999,9 @@
 },o=a,b=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),E={
 variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,
 contains:[]}]},d=E;return d.variants[1].contains=[E],E.variants[1].contains=[d],
-{name:"Kotlin",aliases:["kt"],keywords:n,contains:[e.COMMENT("/\\*\\*","\\*/",{
-relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]
-}),e.C_LINE_COMMENT_MODE,b,{className:"keyword",
+{name:"Kotlin",aliases:["kt","kts"],keywords:n,
+contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",
+begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,b,{className:"keyword",
 begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",
 begin:/@\w+/}]}},i,l,c,{className:"function",beginKeywords:"fun",end:"[(]|$",
 returnBegin:!0,excludeEnd:!0,keywords:n,relevance:5,contains:[{
@@ -2155,13 +2162,13 @@
 },e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.BINARY_NUMBER_MODE,e.C_NUMBER_MODE,a].concat(t),
 illegal:";$|^\\[|^=|&|\\{"}}})());
 hljs.registerLanguage("livescript",(()=>{"use strict"
-;const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
+;const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer","BigInt64Array","BigUint64Array","BigInt"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
 ;return t=>{const r={
 keyword:e.concat(["then","unless","until","loop","of","by","when","and","or","is","isnt","not","it","that","otherwise","from","to","til","fallthrough","case","enum","native","list","map","__hasProp","__extends","__slice","__bind","__indexOf"]),
 literal:n.concat(["yes","no","on","off","it","that","void"]),
 built_in:a.concat(["npm","print"])
-},s="[A-Za-z$_](?:-[0-9A-Za-z$_]|[0-9A-Za-z$_])*",i=t.inherit(t.TITLE_MODE,{
-begin:s}),o={className:"subst",begin:/#\{/,end:/\}/,keywords:r},c={
+},i="[A-Za-z$_](?:-[0-9A-Za-z$_]|[0-9A-Za-z$_])*",s=t.inherit(t.TITLE_MODE,{
+begin:i}),o={className:"subst",begin:/#\{/,end:/\}/,keywords:r},c={
 className:"subst",begin:/#[A-Za-z$_]/,end:/(?:-[0-9A-Za-z$_]|[0-9A-Za-z$_])*/,
 keywords:r},l=[t.BINARY_NUMBER_MODE,{className:"number",
 begin:"(\\b0[xX][a-fA-F0-9_]+)|(\\b\\d(\\d|_\\d)*(\\.(\\d(\\d|_\\d)*)?)?(_*[eE]([-+]\\d(_\\d|\\d)*)?)?[_a-z]*)",
@@ -2172,21 +2179,21 @@
 contains:[t.BACKSLASH_ESCAPE,o,c]},{begin:/\\/,end:/(\s|$)/,excludeEnd:!0}]},{
 className:"regexp",variants:[{begin:"//",end:"//[gim]*",
 contains:[o,t.HASH_COMMENT_MODE]},{
-begin:/\/(?![ *])(\\.|[^\\\n])*?\/[gim]*(?=\W)/}]},{begin:"@"+s},{begin:"``",
+begin:/\/(?![ *])(\\.|[^\\\n])*?\/[gim]*(?=\W)/}]},{begin:"@"+i},{begin:"``",
 end:"``",excludeBegin:!0,excludeEnd:!0,subLanguage:"javascript"}];o.contains=l
 ;const d={className:"params",begin:"\\(",returnBegin:!0,contains:[{begin:/\(/,
 end:/\)/,keywords:r,contains:["self"].concat(l)}]};return{name:"LiveScript",
 aliases:["ls"],keywords:r,illegal:/\/\*/,
 contains:l.concat([t.COMMENT("\\/\\*","\\*\\/"),t.HASH_COMMENT_MODE,{
-begin:"(#=>|=>|\\|>>|-?->|!->)"},{className:"function",contains:[i,d],
+begin:"(#=>|=>|\\|>>|-?->|!->)"},{className:"function",contains:[s,d],
 returnBegin:!0,variants:[{
-begin:"("+s+"\\s*(?:=|:=)\\s*)?(\\(.*\\)\\s*)?\\B->\\*?",end:"->\\*?"},{
-begin:"("+s+"\\s*(?:=|:=)\\s*)?!?(\\(.*\\)\\s*)?\\B[-~]{1,2}>\\*?",
+begin:"("+i+"\\s*(?:=|:=)\\s*)?(\\(.*\\)\\s*)?\\B->\\*?",end:"->\\*?"},{
+begin:"("+i+"\\s*(?:=|:=)\\s*)?!?(\\(.*\\)\\s*)?\\B[-~]{1,2}>\\*?",
 end:"[-~]{1,2}>\\*?"},{
-begin:"("+s+"\\s*(?:=|:=)\\s*)?(\\(.*\\)\\s*)?\\B!?[-~]{1,2}>\\*?",
+begin:"("+i+"\\s*(?:=|:=)\\s*)?(\\(.*\\)\\s*)?\\B!?[-~]{1,2}>\\*?",
 end:"!?[-~]{1,2}>\\*?"}]},{className:"class",beginKeywords:"class",end:"$",
 illegal:/[:="\[\]]/,contains:[{beginKeywords:"extends",endsWithParent:!0,
-illegal:/[:="\[\]]/,contains:[i]},i]},{begin:s+":",end:":",returnBegin:!0,
+illegal:/[:="\[\]]/,contains:[s]},s]},{begin:i+":",end:":",returnBegin:!0,
 returnEnd:!0,relevance:0}])}}})());
 hljs.registerLanguage("llvm",(()=>{"use strict";function e(...e){
 return e.map((e=>{return(n=e)?"string"==typeof n?n:n.source:null;var n
@@ -2440,8 +2447,7 @@
 begin:e.UNDERSCORE_IDENT_RE+"\\s",end:";|\\{",returnBegin:!0,contains:[{
 className:"attribute",begin:e.UNDERSCORE_IDENT_RE,starts:a}],relevance:0}],
 illegal:"[^\\s\\}]"}}})());
-hljs.registerLanguage("nim",(()=>{"use strict";return e=>({name:"Nim",
-aliases:["nim"],keywords:{
+hljs.registerLanguage("nim",(()=>{"use strict";return e=>({name:"Nim",keywords:{
 keyword:"addr and as asm bind block break case cast const continue converter discard distinct div do elif else end enum except export finally for from func generic if import in include interface is isnot iterator let macro method mixin mod nil not notin object of or out proc ptr raise ref return shl shr static template try tuple type using var when while with without xor yield",
 literal:"shared guarded stdin stdout stderr result true false",
 built_in:"int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64 bool char string cstring pointer expr stmt void auto any range array openarray varargs seq set clong culong cchar cschar cshort cint csize clonglong cfloat cdouble clongdouble cuchar cushort cuint culonglong cstringarray semistatic"
@@ -2646,27 +2652,32 @@
 begin:/<<<[ \t]*(\w+)\n/,end:/[ \t]*(\w+)\b/,
 contains:e.QUOTE_STRING_MODE.contains.concat(a)}),l={className:"string",
 contains:[e.BACKSLASH_ESCAPE,t],variants:[e.inherit(n,{begin:"b'",end:"'"
-}),e.inherit(i,{begin:'b"',end:'"'}),i,n,o]},c={
-variants:[e.BINARY_NUMBER_MODE,e.C_NUMBER_MODE]},s={
-keyword:"__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ die echo exit include include_once print require require_once array abstract and as binary bool boolean break callable case catch class clone const continue declare default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends final finally float for foreach from global goto if implements instanceof insteadof int integer interface isset iterable list match|0 new object or private protected public real return string switch throw trait try unset use var void while xor yield",
+}),e.inherit(i,{begin:'b"',end:'"'}),i,n,o]},s={className:"number",variants:[{
+begin:"\\b0b[01]+(?:_[01]+)*\\b"},{begin:"\\b0o[0-7]+(?:_[0-7]+)*\\b"},{
+begin:"\\b0x[\\da-f]+(?:_[\\da-f]+)*\\b"},{
+begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:e[+-]?\\d+)?"
+}],relevance:0},c={
+keyword:"__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ die echo exit include include_once print require require_once array abstract and as binary bool boolean break callable case catch class clone const continue declare default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile enum eval extends final finally float for foreach from global goto if implements instanceof insteadof int integer interface isset iterable list match|0 mixed new object or private protected public real return string switch throw trait try unset use var void while xor yield",
 literal:"false null true",
-built_in:"Error|0 AppendIterator ArgumentCountError ArithmeticError ArrayIterator ArrayObject AssertionError BadFunctionCallException BadMethodCallException CachingIterator CallbackFilterIterator CompileError Countable DirectoryIterator DivisionByZeroError DomainException EmptyIterator ErrorException Exception FilesystemIterator FilterIterator GlobIterator InfiniteIterator InvalidArgumentException IteratorIterator LengthException LimitIterator LogicException MultipleIterator NoRewindIterator OutOfBoundsException OutOfRangeException OuterIterator OverflowException ParentIterator ParseError RangeException RecursiveArrayIterator RecursiveCachingIterator RecursiveCallbackFilterIterator RecursiveDirectoryIterator RecursiveFilterIterator RecursiveIterator RecursiveIteratorIterator RecursiveRegexIterator RecursiveTreeIterator RegexIterator RuntimeException SeekableIterator SplDoublyLinkedList SplFileInfo SplFileObject SplFixedArray SplHeap SplMaxHeap SplMinHeap SplObjectStorage SplObserver SplObserver SplPriorityQueue SplQueue SplStack SplSubject SplSubject SplTempFileObject TypeError UnderflowException UnexpectedValueException ArrayAccess Closure Generator Iterator IteratorAggregate Serializable Throwable Traversable WeakReference Directory __PHP_Incomplete_Class parent php_user_filter self static stdClass"
-};return{aliases:["php","php3","php4","php5","php6","php7","php8"],
-case_insensitive:!0,keywords:s,
+built_in:"Error|0 AppendIterator ArgumentCountError ArithmeticError ArrayIterator ArrayObject AssertionError BadFunctionCallException BadMethodCallException CachingIterator CallbackFilterIterator CompileError Countable DirectoryIterator DivisionByZeroError DomainException EmptyIterator ErrorException Exception FilesystemIterator FilterIterator GlobIterator InfiniteIterator InvalidArgumentException IteratorIterator LengthException LimitIterator LogicException MultipleIterator NoRewindIterator OutOfBoundsException OutOfRangeException OuterIterator OverflowException ParentIterator ParseError RangeException RecursiveArrayIterator RecursiveCachingIterator RecursiveCallbackFilterIterator RecursiveDirectoryIterator RecursiveFilterIterator RecursiveIterator RecursiveIteratorIterator RecursiveRegexIterator RecursiveTreeIterator RegexIterator RuntimeException SeekableIterator SplDoublyLinkedList SplFileInfo SplFileObject SplFixedArray SplHeap SplMaxHeap SplMinHeap SplObjectStorage SplObserver SplObserver SplPriorityQueue SplQueue SplStack SplSubject SplSubject SplTempFileObject TypeError UnderflowException UnexpectedValueException UnhandledMatchError ArrayAccess Closure Generator Iterator IteratorAggregate Serializable Stringable Throwable Traversable WeakReference WeakMap Directory __PHP_Incomplete_Class parent php_user_filter self static stdClass"
+};return{aliases:["php3","php4","php5","php6","php7","php8"],
+case_insensitive:!0,keywords:c,
 contains:[e.HASH_COMMENT_MODE,e.COMMENT("//","$",{contains:[t]
 }),e.COMMENT("/\\*","\\*/",{contains:[{className:"doctag",begin:"@[A-Za-z]+"}]
 }),e.COMMENT("__halt_compiler.+?;",!1,{endsWithParent:!0,
 keywords:"__halt_compiler"}),t,{className:"keyword",begin:/\$this\b/},r,{
 begin:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{className:"function",
 relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,
-illegal:"[$%\\[]",contains:[e.UNDERSCORE_TITLE_MODE,{begin:"=>"},{
-className:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,
-keywords:s,contains:["self",r,e.C_BLOCK_COMMENT_MODE,l,c]}]},{className:"class",
-beginKeywords:"class interface",relevance:0,end:/\{/,excludeEnd:!0,
-illegal:/[:($"]/,contains:[{beginKeywords:"extends implements"
-},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",
-illegal:/[.']/,contains:[e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"use",
-relevance:0,end:";",contains:[e.UNDERSCORE_TITLE_MODE]},l,c]}}})());
+illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{
+begin:"=>",endsParent:!0},{className:"params",begin:"\\(",end:"\\)",
+excludeBegin:!0,excludeEnd:!0,keywords:c,
+contains:["self",r,e.C_BLOCK_COMMENT_MODE,l,s]}]},{className:"class",variants:[{
+beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",
+illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{
+beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{
+beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,
+contains:[e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"use",relevance:0,end:";",
+contains:[e.UNDERSCORE_TITLE_MODE]},l,s]}}})());
 hljs.registerLanguage("php-template",(()=>{"use strict";return n=>({
 name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,
 subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',
@@ -2964,8 +2975,8 @@
 }]},s={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,i,{
 className:"variable",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]}]},t={
 className:"string",begin:/'/,end:/'/};return{name:"Microtik RouterOS script",
-aliases:["routeros","mikrotik"],case_insensitive:!0,keywords:{
-$pattern:/:?[\w-]+/,literal:n,
+aliases:["mikrotik"],case_insensitive:!0,keywords:{$pattern:/:?[\w-]+/,
+literal:n,
 keyword:r+" :"+r.split(" ").join(" :")+" :"+"global local beep delay put len typeof pick log time set find environment terminal error execute parse resolve toarray tobool toid toip toip6 tonum tostr totime".split(" ").join(" :")
 },contains:[{variants:[{begin:/\/\*/,end:/\*\//},{begin:/\/\//,end:/$/},{
 begin:/<\//,end:/>/}],illegal:/./},e.COMMENT("^#","$"),s,t,i,{
@@ -3018,7 +3029,7 @@
 contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{endsParent:!0})],illegal:"[\\w\\d]"
 },{begin:e.IDENT_RE+"::",keywords:{built_in:t}},{begin:"->"}]}}})());
 hljs.registerLanguage("sas",(()=>{"use strict";return e=>({name:"SAS",
-aliases:["sas","SAS"],case_insensitive:!0,keywords:{
+aliases:["SAS"],case_insensitive:!0,keywords:{
 literal:"null missing _all_ _automatic_ _character_ _infile_ _n_ _name_ _null_ _numeric_ _user_ _webout_",
 meta:"do if then else end until while abort array attrib by call cards cards4 catname continue datalines datalines4 delete delim delimiter display dm drop endsas error file filename footnote format goto in infile informat input keep label leave length libname link list lostcard merge missing modify options output out page put redirect remove rename replace retain return select set skip startsas stop title update waitsas where window x systask add and alter as cascade check create delete describe distinct drop foreign from group having index insert into in key like message modify msgtype not null on or order primary references reset restrict select set table unique update validate view where"
 },contains:[{className:"keyword",begin:/^\s*(proc [\w\d_]+|data|run|quit)[\s;]/
@@ -3110,10 +3121,10 @@
 subLanguage:"bash"}}]})})());
 hljs.registerLanguage("smali",(()=>{"use strict";return e=>{
 const n=["add","and","cmp","cmpg","cmpl","const","div","double","float","goto","if","int","long","move","mul","neg","new","nop","not","or","rem","return","shl","shr","sput","sub","throw","ushr","xor"]
-;return{name:"Smali",aliases:["smali"],contains:[{className:"string",begin:'"',
-end:'"',relevance:0},e.COMMENT("#","$",{relevance:0}),{className:"keyword",
-variants:[{begin:"\\s*\\.end\\s[a-zA-Z0-9]*"},{begin:"^[ ]*\\.[a-zA-Z]*",
-relevance:0},{begin:"\\s:[a-zA-Z_0-9]*",relevance:0},{
+;return{name:"Smali",contains:[{className:"string",begin:'"',end:'"',relevance:0
+},e.COMMENT("#","$",{relevance:0}),{className:"keyword",variants:[{
+begin:"\\s*\\.end\\s[a-zA-Z0-9]*"},{begin:"^[ ]*\\.[a-zA-Z]*",relevance:0},{
+begin:"\\s:[a-zA-Z_0-9]*",relevance:0},{
 begin:"\\s(transient|constructor|abstract|final|synthetic|public|private|protected|static|bridge|system)"
 }]},{className:"built_in",variants:[{begin:"\\s("+n.join("|")+")\\s"},{
 begin:"\\s("+n.join("|")+")((-|/)[a-zA-Z0-9]+)+\\s",relevance:10},{
@@ -3369,19 +3380,20 @@
 end:"\\.\\.\\.$",subLanguage:"yaml",relevance:0},{className:"number",
 begin:" (\\d+) "},{className:"symbol",variants:[{begin:"^ok"},{begin:"^not ok"}]
 }]})})());
-hljs.registerLanguage("tcl",(()=>{"use strict";return e=>({name:"Tcl",
+hljs.registerLanguage("tcl",(()=>{"use strict";function e(...e){
+return e.map((e=>{return(a=e)?"string"==typeof a?a:a.source:null;var a
+})).join("")}return a=>{const t=/[a-zA-Z_][a-zA-Z0-9_]*/,r={className:"number",
+variants:[a.BINARY_NUMBER_MODE,a.C_NUMBER_MODE]};return{name:"Tcl",
 aliases:["tk"],
 keywords:"after append apply array auto_execok auto_import auto_load auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror binary break catch cd chan clock close concat continue dde dict encoding eof error eval exec exit expr fblocked fconfigure fcopy file fileevent filename flush for foreach format gets glob global history http if incr info interp join lappend|10 lassign|10 lindex|10 linsert|10 list llength|10 load lrange|10 lrepeat|10 lreplace|10 lreverse|10 lsearch|10 lset|10 lsort|10 mathfunc mathop memory msgcat namespace open package parray pid pkg::create pkg_mkIndex platform platform::shell proc puts pwd read refchan regexp registry regsub|10 rename return safe scan seek set socket source split string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord tcl_startOfPreviousWord tcl_wordBreakAfter tcl_wordBreakBefore tcltest tclvars tell time tm trace unknown unload unset update uplevel upvar variable vwait while",
-contains:[e.COMMENT(";[ \\t]*#","$"),e.COMMENT("^[ \\t]*#","$"),{
+contains:[a.COMMENT(";[ \\t]*#","$"),a.COMMENT("^[ \\t]*#","$"),{
 beginKeywords:"proc",end:"[\\{]",excludeEnd:!0,contains:[{className:"title",
 begin:"[ \\t\\n\\r]+(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*",end:"[ \\t\\n\\r]",
-endsWithParent:!0,excludeEnd:!0}]},{excludeEnd:!0,variants:[{
-begin:"\\$(\\{)?(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*\\(([a-zA-Z0-9_])*\\)",
-end:"[^a-zA-Z0-9_\\}\\$]"},{begin:"\\$(\\{)?(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*",
-end:"(\\))?[^a-zA-Z0-9_\\}\\$]"}]},{className:"string",
-contains:[e.BACKSLASH_ESCAPE],variants:[e.inherit(e.QUOTE_STRING_MODE,{
-illegal:null})]},{className:"number",
-variants:[e.BINARY_NUMBER_MODE,e.C_NUMBER_MODE]}]})})());
+endsWithParent:!0,excludeEnd:!0}]},{className:"variable",variants:[{
+begin:e(/\$/,(n=/::/,e("(",n,")?")),t,"(::",t,")*")},{
+begin:"\\$\\{(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*",end:"\\}",contains:[r]}]},{
+className:"string",contains:[a.BACKSLASH_ESCAPE],
+variants:[a.inherit(a.QUOTE_STRING_MODE,{illegal:null})]},r]};var n}})());
 hljs.registerLanguage("thrift",(()=>{"use strict";return e=>{
 const t="bool byte i16 i32 i64 double string binary";return{name:"Thrift",
 keywords:{
@@ -3424,7 +3436,7 @@
 endsWithParent:!0,contains:[t,n],relevance:0}}]},{className:"template-variable",
 begin:/\{\{/,end:/\}\}/,contains:["self",t,n]}]}}})());
 hljs.registerLanguage("typescript",(()=>{"use strict"
-;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],a=["true","false","null","undefined","NaN","Infinity"],s=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
+;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],a=["true","false","null","undefined","NaN","Infinity"],s=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer","BigInt64Array","BigUint64Array","BigInt"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"])
 ;function t(e){return r("(?=",e,")")}function r(...e){return e.map((e=>{
 return(n=e)?"string"==typeof n?n:n.source:null;var n})).join("")}return i=>{
 const c={$pattern:e,
@@ -3450,27 +3462,27 @@
 end:"\\}",keywords:l,contains:[]},E={begin:"html`",end:"",starts:{end:"`",
 returnEnd:!1,contains:[i.BACKSLASH_ESCAPE,u],subLanguage:"xml"}},m={
 begin:"css`",end:"",starts:{end:"`",returnEnd:!1,
-contains:[i.BACKSLASH_ESCAPE,u],subLanguage:"css"}},_={className:"string",
-begin:"`",end:"`",contains:[i.BACKSLASH_ESCAPE,u]},y={className:"comment",
+contains:[i.BACKSLASH_ESCAPE,u],subLanguage:"css"}},y={className:"string",
+begin:"`",end:"`",contains:[i.BACKSLASH_ESCAPE,u]},_={className:"comment",
 variants:[i.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{
 className:"doctag",begin:"@[A-Za-z]+",contains:[{className:"type",begin:"\\{",
 end:"\\}",relevance:0},{className:"variable",begin:c+"(?=\\s*(-)|$)",
 endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]
 }),i.C_BLOCK_COMMENT_MODE,i.C_LINE_COMMENT_MODE]
-},p=[i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,E,m,_,g,i.REGEXP_MODE]
+},p=[i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,E,m,y,g,i.REGEXP_MODE]
 ;u.contains=p.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(p)
-});const N=[].concat(y,u.contains),f=N.concat([{begin:/\(/,end:/\)/,keywords:l,
+});const N=[].concat(_,u.contains),f=N.concat([{begin:/\(/,end:/\)/,keywords:l,
 contains:["self"].concat(N)}]),A={className:"params",begin:/\(/,end:/\)/,
 excludeBegin:!0,excludeEnd:!0,keywords:l,contains:f};return{name:"Javascript",
 aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:f},
 illegal:/#(?![$_A-z])/,contains:[i.SHEBANG({label:"shebang",binary:"node",
 relevance:5}),{label:"use_strict",className:"meta",relevance:10,
 begin:/^\s*['"]use (strict|asm)['"]/
-},i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,E,m,_,y,g,{
+},i.APOS_STRING_MODE,i.QUOTE_STRING_MODE,E,m,y,_,g,{
 begin:r(/[{,\n]\s*/,t(r(/(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,c+"\\s*:"))),
 relevance:0,contains:[{className:"attr",begin:c+t("\\s*:"),relevance:0}]},{
 begin:"("+i.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",
-keywords:"return throw case",contains:[y,i.REGEXP_MODE,{className:"function",
+keywords:"return throw case",contains:[_,i.REGEXP_MODE,{className:"function",
 begin:"(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+i.UNDERSCORE_IDENT_RE+")\\s*=>",
 returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{
 begin:i.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0
@@ -3497,7 +3509,7 @@
 }]),l(b,"shebang",i.SHEBANG()),l(b,"use_strict",{className:"meta",relevance:10,
 begin:/^\s*['"]use strict['"]/
 }),b.contains.find((e=>"function"===e.className)).relevance=0,Object.assign(b,{
-name:"TypeScript",aliases:["ts"]}),b}})());
+name:"TypeScript",aliases:["ts","tsx"]}),b}})());
 hljs.registerLanguage("vala",(()=>{"use strict";return e=>({name:"Vala",
 keywords:{
 keyword:"char uchar unichar int uint long ulong short ushort int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double bool struct enum string void weak unowned owned async signal static abstract interface override virtual delegate if while do for foreach else switch case break default return try catch public private protected internal using new this get set const stdout stdin stderr var",
diff --git a/polygerrit-ui/README.md b/polygerrit-ui/README.md
index 2fb9e5c..c6e6cd9 100644
--- a/polygerrit-ui/README.md
+++ b/polygerrit-ui/README.md
@@ -116,7 +116,7 @@
 the command line:
 
 ```sh
-./polygerrit-ui/run-server.sh --plugins=plugins/my_plugin/static/my_plugin.js,plugins/my_plugin/static/my_plugin.html
+./polygerrit-ui/run-server.sh --plugins=plugins/my_plugin/static/my_plugin.js
 ```
 
 If any issues occured, please refer to the Troubleshooting section at the bottom or contact the team!
diff --git a/polygerrit-ui/app/api/annotation.ts b/polygerrit-ui/app/api/annotation.ts
index e58bdd5..bd4f399 100644
--- a/polygerrit-ui/app/api/annotation.ts
+++ b/polygerrit-ui/app/api/annotation.ts
@@ -14,8 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {CoverageRange, GrDiffLine, Side} from './diff';
-import {StyleObject} from './styles';
+import {CoverageRange, Side} from './diff';
 
 /**
  * This is the callback object that Gerrit calls once for each diff. Gerrit
@@ -37,61 +36,8 @@
   change?: unknown
 ) => Promise<Array<CoverageRange>>;
 
-export type AnnotationCallback = (ctx: AnnotationContext) => void;
-
-/**
- * This object is passed to the plugin from Gerrit for each line of a diff that
- * is being rendered. The plugin can then call annotateRange() or
- * annotateLineNumber() to apply additional styles to the diff.
- */
-export interface AnnotationContext {
-  /** Set by Gerrit and consumed by the plugin provided AddLayerFunc. */
-  readonly changeNum: number;
-  /** Set by Gerrit and consumed by the plugin provided AddLayerFunc. */
-  readonly path: string;
-  /** Set by Gerrit and consumed by the plugin provided AddLayerFunc. */
-  readonly line: GrDiffLine;
-  /** Set by Gerrit and consumed by the plugin provided AddLayerFunc. */
-  readonly contentEl: HTMLElement;
-  /** Set by Gerrit and consumed by the plugin provided AddLayerFunc. */
-  readonly lineNumberEl: HTMLElement;
-
-  /**
-   * Can be called by the plugin to style a part of the given line of the
-   * context.
-   *
-   * @param offset The char offset where the update starts.
-   * @param length The number of chars that the update covers.
-   * @param styleObject The style object for the range.
-   * @param side The side of the update. ('left' or 'right')
-   */
-  annotateRange(
-    offset: number,
-    length: number,
-    styleObject: StyleObject,
-    side: string
-  ): void;
-
-  /**
-   * Can be called by the plugin to style a part of the given line of the
-   * context.
-   *
-   * @param styleObject The style object for the range.
-   * @param side The side of the update. ('left' or 'right')
-   */
-  annotateLineNumber(styleObject: StyleObject, side: string): void;
-}
-
 export interface AnnotationPluginApi {
   /**
-   * Registers a callback for applying annotations. Gerrit will call the
-   * callback for every line of every file that is rendered and pass the
-   * information about the file and line as an AnnotationContext, which also
-   * provides methods for the plugin to style the content.
-   */
-  setLayer(callback: AnnotationCallback): AnnotationPluginApi;
-
-  /**
    * The specified function will be called when a gr-diff component is built,
    * and feeds the returned coverage data into the diff. Optional.
    *
@@ -102,28 +48,6 @@
   setCoverageProvider(coverageProvider: CoverageProvider): AnnotationPluginApi;
 
   /**
-   * Returns a checkbox HTMLElement that can be used to toggle annotations
-   * on/off. The checkbox will be initially disabled. Plugins should enable it
-   * when data is ready and should add a click handler to toggle CSS on/off.
-   *
-   * Note1: Calling this method from multiple plugins will only work for the
-   * 1st call. It will print an error message for all subsequent calls
-   * and will not invoke their onAttached functions.
-   * Note2: This method will be deprecated and eventually removed when
-   * https://bugs.chromium.org/p/gerrit/issues/detail?id=8077 is
-   * implemented.
-   *
-   * @param checkboxLabel Will be used as the label for the checkbox.
-   * Optional. "Enable" is used if this is not specified.
-   * @param onAttached The function that will be called
-   * when the checkbox is attached to the page.
-   */
-  enableToggleCheckbox(
-    checkboxLabel: string,
-    onAttached: (checkboxEl: Element | null) => void
-  ): AnnotationPluginApi;
-
-  /**
    * For plugins notifying Gerrit about new annotations being ready to be
    * applied for a certain range. Gerrit will then re-render the relevant lines
    * of the diff and call back to the layer annotation function that was
diff --git a/polygerrit-ui/app/api/change-metadata.ts b/polygerrit-ui/app/api/change-metadata.ts
deleted file mode 100644
index effe661..0000000
--- a/polygerrit-ui/app/api/change-metadata.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export interface ChangeMetadataPluginApi {
-  onLabelsChanged(callback: (value: unknown) => void): ChangeMetadataPluginApi;
-}
diff --git a/polygerrit-ui/app/api/change-reply.ts b/polygerrit-ui/app/api/change-reply.ts
index 37c96ee..6016004 100644
--- a/polygerrit-ui/app/api/change-reply.ts
+++ b/polygerrit-ui/app/api/change-reply.ts
@@ -29,8 +29,6 @@
 
   setLabelValue(label: string, value: string): void;
 
-  send(includeComments?: boolean): void;
-
   addReplyTextChangedCallback(handler: ReplyChangedCallback): void;
 
   addLabelValuesChangedCallback(handler: LabelsChangedCallback): void;
diff --git a/polygerrit-ui/app/api/event-helper.ts b/polygerrit-ui/app/api/event-helper.ts
index c4a559b..16c327d 100644
--- a/polygerrit-ui/app/api/event-helper.ts
+++ b/polygerrit-ui/app/api/event-helper.ts
@@ -18,12 +18,6 @@
 
 export interface EventHelperPluginApi {
   /**
-   * Add a callback to arbitrary event.
-   * The callback may return false to prevent event bubbling.
-   */
-  on(event: string, callback: (event: Event) => boolean): UnsubscribeCallback;
-
-  /**
    * Alias for @see onClick
    */
   onTap(callback: (event: Event) => boolean): UnsubscribeCallback;
@@ -33,17 +27,4 @@
    * The callback may return false to prevent event bubbling.
    */
   onClick(callback: (event: Event) => boolean): UnsubscribeCallback;
-
-  /**
-   * Alias for @see captureClick
-   */
-  captureTap(callback: (event: Event) => boolean): UnsubscribeCallback;
-
-  /**
-   * Add a callback to element click or touch ahead of normal flow.
-   * Callback is installed on parent during capture phase.
-   * https://www.w3.org/TR/DOM-Level-3-Events/#event-flow
-   * The callback may return false to cancel regular event listeners.
-   */
-  captureClick(callback: (event: Event) => boolean): UnsubscribeCallback;
 }
diff --git a/polygerrit-ui/app/api/plugin.ts b/polygerrit-ui/app/api/plugin.ts
index cd742a2..0aadb38 100644
--- a/polygerrit-ui/app/api/plugin.ts
+++ b/polygerrit-ui/app/api/plugin.ts
@@ -17,16 +17,11 @@
 import {AdminPluginApi} from './admin';
 import {AnnotationPluginApi} from './annotation';
 import {AttributeHelperPluginApi} from './attribute-helper';
-import {ChangeMetadataPluginApi} from './change-metadata';
 import {ChangeReplyPluginApi} from './change-reply';
 import {ChecksPluginApi} from './checks';
 import {EventHelperPluginApi} from './event-helper';
 import {PopupPluginApi} from './popup';
-import {RepoPluginApi} from './repo';
 import {ReportingPluginApi} from './reporting';
-import {SettingsPluginApi} from './settings';
-import {StylesPluginApi} from './styles';
-import {ThemePluginApi} from './theme';
 import {ChangeActionsPluginApi} from './change-actions';
 import {RestPluginApi} from './rest';
 import {HookApi, RegisterOptions} from './hook';
@@ -59,7 +54,6 @@
   annotationApi(): AnnotationPluginApi;
   attributeHelper(element: Element): AttributeHelperPluginApi;
   changeActions(): ChangeActionsPluginApi;
-  changeMetadata(): ChangeMetadataPluginApi;
   changeReply(): ChangeReplyPluginApi;
   checks(): ChecksPluginApi;
   eventHelper(element: Node): EventHelperPluginApi;
@@ -70,7 +64,6 @@
   popup(): Promise<PopupPluginApi>;
   popup(moduleName: string): Promise<PopupPluginApi>;
   popup(moduleName?: string): Promise<PopupPluginApi | null>;
-  project(): RepoPluginApi;
   registerCustomComponent(
     endpointName: string,
     moduleName?: string,
@@ -86,7 +79,4 @@
   restApi(): RestPluginApi;
   // eslint-disable-next-line @typescript-eslint/no-explicit-any
   screen(screenName: string, moduleName?: string): any;
-  settings(): SettingsPluginApi;
-  styles(): StylesPluginApi;
-  theme(): ThemePluginApi;
 }
diff --git a/polygerrit-ui/app/api/repo.ts b/polygerrit-ui/app/api/repo.ts
deleted file mode 100644
index a626471..0000000
--- a/polygerrit-ui/app/api/repo.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-export type RepoCommandCallback = (
-  repo?: string,
-  /**
-   * This is a ConfigInfo object as defined here:
-   * https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#config-info
-   * We neither want to repeat it nor add a dependency on it here.
-   */
-  config?: unknown
-) => boolean;
-
-export interface RepoPluginApi {
-  createCommand(title: string, callback: RepoCommandCallback): RepoPluginApi;
-
-  onTap(callback: (event: Event) => boolean): RepoPluginApi;
-}
diff --git a/polygerrit-ui/app/api/settings.ts b/polygerrit-ui/app/api/settings.ts
deleted file mode 100644
index 03cf474..0000000
--- a/polygerrit-ui/app/api/settings.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {HookApi} from './hook';
-
-export interface SettingsPluginApi {
-  title(newTitle: string): SettingsPluginApi;
-
-  token(newToken: string): SettingsPluginApi;
-
-  module(newModuleName: string): SettingsPluginApi;
-
-  build(): HookApi;
-}
diff --git a/polygerrit-ui/app/api/styles.ts b/polygerrit-ui/app/api/styles.ts
deleted file mode 100644
index 233c3e2..0000000
--- a/polygerrit-ui/app/api/styles.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export interface StyleObject {
-  /**
-   * Creates a new unique CSS class and injects it in a root node of the element
-   * if it hasn't been added yet. A root node is an document or is the
-   * associated shadowRoot. This class can be added to any element with the same
-   * root node.
-   */
-  getClassName(element: Element): string;
-
-  /**
-   * Apply shared style to the element.
-   */
-  apply(element: Element): void;
-}
-
-export interface StylesPluginApi {
-  css(ruleStr: string): StyleObject;
-}
diff --git a/polygerrit-ui/app/api/theme.ts b/polygerrit-ui/app/api/theme.ts
deleted file mode 100644
index 70ffcb3..0000000
--- a/polygerrit-ui/app/api/theme.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export interface ThemePluginApi {
-  setHeaderLogoAndTitle(logoUrl: string, title: string): void;
-}
diff --git a/polygerrit-ui/app/constants/reporting.ts b/polygerrit-ui/app/constants/reporting.ts
index 34ae542..e5d39c9 100644
--- a/polygerrit-ui/app/constants/reporting.ts
+++ b/polygerrit-ui/app/constants/reporting.ts
@@ -23,4 +23,11 @@
   VISIBILILITY_VISIBLE = 'Visibility changed to visible',
   EXTENSION_DETECTED = 'Extension detected',
   PLUGINS_INSTALLED = 'Plugins installed',
+  USER_REFERRED_FROM = 'User referred from',
+}
+
+export enum Execution {
+  PLUGIN_API = 'plugin-api',
+  REACHABLE_CODE = 'reachable code',
+  METHOD_USED = 'method used',
 }
diff --git a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts
index 8c756cd..aa28f04 100644
--- a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts
+++ b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts
@@ -21,7 +21,6 @@
 import '../../shared/gr-icons/gr-icons';
 import '../gr-permission/gr-permission';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {htmlTemplate} from './gr-access-section_html';
 import {
   AccessPermissions,
@@ -70,7 +69,7 @@
 }
 
 @customElement('gr-access-section')
-export class GrAccessSection extends LegacyElementMixin(PolymerElement) {
+export class GrAccessSection extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -108,9 +107,8 @@
   @property({type: Array})
   _permissions?: PermissionArray<EditablePermissionInfo>;
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('access-saved', () => this._handleAccessSaved());
   }
 
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts
index 221ab54..37a2f3e 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts
@@ -21,7 +21,6 @@
 import '../../shared/gr-list-view/gr-list-view';
 import '../../shared/gr-overlay/gr-overlay';
 import '../gr-create-group-dialog/gr-create-group-dialog';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-admin-group-list_html';
 import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
@@ -48,9 +47,7 @@
 }
 
 @customElement('gr-admin-group-list')
-export class GrAdminGroupList extends ListViewMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrAdminGroupList extends ListViewMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -97,8 +94,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._getCreateGroupCapability();
     fireTitleChange(this, 'Groups');
     this._maybeOpenCreateOverlay(this.params);
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
index 31f87ce..f8ab519 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
@@ -31,7 +31,6 @@
 import '../gr-repo-dashboards/gr-repo-dashboards';
 import '../gr-repo-detail-list/gr-repo-detail-list';
 import '../gr-repo-list/gr-repo-list';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-admin-view_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -91,7 +90,7 @@
 }
 
 @customElement('gr-admin-view')
-export class GrAdminView extends LegacyElementMixin(PolymerElement) {
+export class GrAdminView extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -175,8 +174,8 @@
   private readonly jsAPI = appContext.jsApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.reload();
   }
 
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.js b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.js
index e813bec..69c218c 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.js
@@ -20,9 +20,8 @@
 import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
 import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {stubBaseUrl} from '../../../test/test-utils.js';
+import {stubBaseUrl, stubRestApi} from '../../../test/test-utils.js';
 import {GerritView} from '../../../services/router/router-model.js';
-import {stubRestApi} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-admin-view');
 
@@ -431,9 +430,7 @@
 
     suite('repos', () => {
       setup(() => {
-        stub('gr-repo-access', {
-          _repoChanged: () => {},
-        });
+        stub('gr-repo-access', '_repoChanged').callsFake(() => {});
       });
 
       test('repo list', () => {
@@ -500,12 +497,8 @@
     suite('groups', () => {
       let getGroupConfigStub;
       setup(() => {
-        stub('gr-group', {
-          _loadGroup: () => Promise.resolve({}),
-        });
-        stub('gr-group-members', {
-          _loadGroupDetails: () => {},
-        });
+        stub('gr-group', '_loadGroup').callsFake(() => Promise.resolve({}));
+        stub('gr-group-members', '_loadGroupDetails').callsFake(() => {});
 
         getGroupConfigStub = stubRestApi('getGroupConfig');
         getGroupConfigStub.returns(Promise.resolve({
diff --git a/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts b/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts
index 1e38aa9..d545b4c 100644
--- a/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts
@@ -16,7 +16,6 @@
  */
 import '../../shared/gr-dialog/gr-dialog';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-delete-item-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -35,9 +34,7 @@
 }
 
 @customElement('gr-confirm-delete-item-dialog')
-export class GrConfirmDeleteItemDialog extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrConfirmDeleteItemDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts
index a2b17ead5..f37e6a3 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts
@@ -20,7 +20,6 @@
 import '../../shared/gr-autocomplete/gr-autocomplete';
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-select/gr-select';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-create-change-dialog_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -49,7 +48,7 @@
   };
 }
 @customElement('gr-create-change-dialog')
-export class GrCreateChangeDialog extends LegacyElementMixin(PolymerElement) {
+export class GrCreateChangeDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -95,8 +94,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     if (!this.repoName) {
       return Promise.resolve();
     }
diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts
index 198794e..8a4cbbe 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import './gr-create-change-dialog.js';
+import '../../../test/common-test-setup-karma';
+import './gr-create-change-dialog';
 import {GrCreateChangeDialog} from './gr-create-change-dialog';
 import {BranchName, GitRef, RepoName} from '../../../types/common';
 import {InheritedBooleanInfoConfiguredValue} from '../../../constants/constants';
diff --git a/polygerrit-ui/app/elements/admin/gr-create-group-dialog/gr-create-group-dialog.ts b/polygerrit-ui/app/elements/admin/gr-create-group-dialog/gr-create-group-dialog.ts
index 39dbca8..b4f07cb 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-group-dialog/gr-create-group-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-group-dialog/gr-create-group-dialog.ts
@@ -17,7 +17,6 @@
 import '@polymer/iron-input/iron-input';
 import '../../../styles/gr-form-styles';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-create-group-dialog_html';
 import {encodeURL, getBaseUrl} from '../../../utils/url-util';
@@ -27,7 +26,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-create-group-dialog')
-export class GrCreateGroupDialog extends LegacyElementMixin(PolymerElement) {
+export class GrCreateGroupDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts
index afcb026..8875ad4 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts
@@ -19,7 +19,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-select/gr-select';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-create-pointer-dialog_html';
 import {encodeURL, getBaseUrl} from '../../../utils/url-util';
@@ -34,7 +33,7 @@
 }
 
 @customElement('gr-create-pointer-dialog')
-export class GrCreatePointerDialog extends LegacyElementMixin(PolymerElement) {
+export class GrCreatePointerDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.ts b/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.ts
index ec768ff..94a4b0a 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.ts
@@ -20,7 +20,6 @@
 import '../../shared/gr-autocomplete/gr-autocomplete';
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-select/gr-select';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-create-repo-dialog_html';
 import {encodeURL, getBaseUrl} from '../../../utils/url-util';
@@ -42,7 +41,7 @@
 }
 
 @customElement('gr-create-repo-dialog')
-export class GrCreateRepoDialog extends LegacyElementMixin(PolymerElement) {
+export class GrCreateRepoDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts
index 6338988..0bf292d 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts
@@ -19,7 +19,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-date-formatter/gr-date-formatter';
 import '../../shared/gr-account-link/gr-account-link';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-group-audit-log_html';
 import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
@@ -38,9 +37,7 @@
 const GROUP_EVENTS = ['ADD_GROUP', 'REMOVE_GROUP'];
 
 @customElement('gr-group-audit-log')
-export class GrGroupAuditLog extends ListViewMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrGroupAuditLog extends ListViewMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -57,8 +54,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     fireTitleChange(this, 'Audit Log');
   }
 
diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.js b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.js
index 268112e..fdd5d15 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.js
@@ -17,8 +17,7 @@
 
 import '../../../test/common-test-setup-karma.js';
 import './gr-group-audit-log.js';
-import {stubRestApi} from '../../../test/test-utils.js';
-import {addListenerForTest} from '../../../test/test-utils.js';
+import {stubRestApi, addListenerForTest} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-group-audit-log');
 
diff --git a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.ts b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.ts
index 79eee7d..bc793fa 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.ts
+++ b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.ts
@@ -24,7 +24,6 @@
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-overlay/gr-overlay';
 import '../gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-group-members_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -62,7 +61,7 @@
   };
 }
 @customElement('gr-group-members')
-export class GrGroupMembers extends LegacyElementMixin(PolymerElement) {
+export class GrGroupMembers extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -123,8 +122,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadGroupDetails();
 
     fireTitleChange(this, 'Members');
diff --git a/polygerrit-ui/app/elements/admin/gr-group/gr-group.ts b/polygerrit-ui/app/elements/admin/gr-group/gr-group.ts
index 8e49479..0bb13ba 100644
--- a/polygerrit-ui/app/elements/admin/gr-group/gr-group.ts
+++ b/polygerrit-ui/app/elements/admin/gr-group/gr-group.ts
@@ -22,7 +22,6 @@
 import '../../shared/gr-autocomplete/gr-autocomplete';
 import '../../shared/gr-copy-clipboard/gr-copy-clipboard';
 import '../../shared/gr-select/gr-select';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-group_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -70,7 +69,7 @@
 }
 
 @customElement('gr-group')
-export class GrGroup extends LegacyElementMixin(PolymerElement) {
+export class GrGroup extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -131,8 +130,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadGroup();
   }
 
diff --git a/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js b/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js
index 4c09e30..0668330 100644
--- a/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js
@@ -17,8 +17,7 @@
 
 import '../../../test/common-test-setup-karma.js';
 import './gr-group.js';
-import {stubRestApi} from '../../../test/test-utils.js';
-import {addListenerForTest} from '../../../test/test-utils.js';
+import {stubRestApi, addListenerForTest} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-group');
 
diff --git a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.ts b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.ts
index 6528d35..6f11a33 100644
--- a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.ts
+++ b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.ts
@@ -23,7 +23,6 @@
 import '../../shared/gr-button/gr-button';
 import '../gr-rule-editor/gr-rule-editor';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-permission_html';
 import {
@@ -93,7 +92,7 @@
  * @event added-permission-removed
  */
 @customElement('gr-permission')
-export class GrPermission extends LegacyElementMixin(PolymerElement) {
+export class GrPermission extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -142,11 +141,6 @@
   constructor() {
     super();
     this._query = () => this._getGroupSuggestions();
-  }
-
-  /** @override */
-  created() {
-    super.created();
     this.addEventListener('access-saved', () => this._handleAccessSaved());
   }
 
diff --git a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission_html.ts b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission_html.ts
index 6ae982b..3559194 100644
--- a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission_html.ts
+++ b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission_html.ts
@@ -93,7 +93,7 @@
               checked="{{permission.value.exclusive}}"
               on-change="_handleValueChange"
               disabled$="[[!editing]]"
-              on-tap="_onTapExclusiveToggle"
+              on-click="_onTapExclusiveToggle"
             ></paper-toggle-button
             >Exclusive
           </template>
diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts b/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts
index 7c7c948..248a0e3 100644
--- a/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts
+++ b/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts
@@ -20,7 +20,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-button/gr-button';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-plugin-config-array-editor_html';
 import {property, customElement} from '@polymer/decorators';
@@ -37,7 +36,7 @@
 }
 
 @customElement('gr-plugin-config-array-editor')
-class GrPluginConfigArrayEditor extends LegacyElementMixin(PolymerElement) {
+class GrPluginConfigArrayEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
index a6a1a42..96cae0e 100644
--- a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
@@ -17,7 +17,6 @@
 import '../../../styles/gr-table-styles';
 import '../../../styles/shared-styles';
 import '../../shared/gr-list-view/gr-list-view';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-plugin-list_html';
 import {
@@ -26,8 +25,7 @@
 } from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
 import {customElement, property} from '@polymer/decorators';
 import {PluginInfo} from '../../../types/common';
-import {firePageError} from '../../../utils/event-util';
-import {fireTitleChange} from '../../../utils/event-util';
+import {firePageError, fireTitleChange} from '../../../utils/event-util';
 import {appContext} from '../../../services/app-context';
 import {ErrorCallback} from '../../../api/rest';
 
@@ -35,9 +33,7 @@
   name: string;
 }
 @customElement('gr-plugin-list')
-export class GrPluginList extends ListViewMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrPluginList extends ListViewMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -79,8 +75,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     fireTitleChange(this, 'Plugins');
   }
 
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
index 17a9ee6..7b43dfc 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
@@ -19,7 +19,6 @@
 import '../../../styles/shared-styles';
 import '../gr-access-section/gr-access-section';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-access_html';
 import {encodeURL, getBaseUrl, singleDecodeURL} from '../../../utils/url-util';
@@ -62,7 +61,7 @@
  * @event show-alert
  */
 @customElement('gr-repo-access')
-export class GrRepoAccess extends LegacyElementMixin(PolymerElement) {
+export class GrRepoAccess extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -122,11 +121,6 @@
   constructor() {
     super();
     this._query = () => this._getInheritFromSuggestions();
-  }
-
-  /** @override */
-  created() {
-    super.created();
     this.addEventListener('access-modified', () =>
       this._handleAccessModified()
     );
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.ts b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.ts
index 5a6f0c5..df78df3 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands.ts
@@ -23,7 +23,6 @@
 import '../../shared/gr-dialog/gr-dialog';
 import '../../shared/gr-overlay/gr-overlay';
 import '../gr-create-change-dialog/gr-create-change-dialog';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-commands_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -60,7 +59,7 @@
 }
 
 @customElement('gr-repo-commands')
-export class GrRepoCommands extends LegacyElementMixin(PolymerElement) {
+export class GrRepoCommands extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -91,8 +90,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadRepo();
 
     fireTitleChange(this, 'Repo Commands');
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts
index a132f64..815e3ac 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts
@@ -17,7 +17,6 @@
 
 import '../../../styles/shared-styles';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-dashboards_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -33,7 +32,7 @@
 }
 
 @customElement('gr-repo-dashboards')
-export class GrRepoDashboards extends LegacyElementMixin(PolymerElement) {
+export class GrRepoDashboards extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
index 4cb325c..9e68a24 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
@@ -28,7 +28,6 @@
 import '../gr-create-pointer-dialog/gr-create-pointer-dialog';
 import '../gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-detail-list_html';
 import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
@@ -61,9 +60,7 @@
   };
 }
 @customElement('gr-repo-detail-list')
-export class GrRepoDetailList extends ListViewMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrRepoDetailList extends ListViewMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts
index e5225f0..bcf081f 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts
@@ -20,7 +20,6 @@
 import '../../shared/gr-list-view/gr-list-view';
 import '../../shared/gr-overlay/gr-overlay';
 import '../gr-create-repo-dialog/gr-create-repo-dialog';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-list_html';
 import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
@@ -48,9 +47,7 @@
 }
 
 @customElement('gr-repo-list')
-export class GrRepoList extends ListViewMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrRepoList extends ListViewMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -90,8 +87,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._getCreateRepoCapability();
     fireTitleChange(this, 'Repos');
     this._maybeOpenCreateOverlay(this.params);
@@ -147,7 +144,7 @@
         if (filter !== this._filter || !repos) {
           return;
         }
-        this._repos = repos;
+        this._repos = repos.filter(repo => repo.name.includes(filter));
         this._loading = false;
       });
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.js b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.js
index 4904bf4..c8e058e 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.js
@@ -27,6 +27,7 @@
 const repoGenerator = () => {
   return {
     id: `test${++counter}`,
+    name: `test`,
     state: 'ACTIVE',
     web_links: [
       {
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts
index 347a56b..66e4ed6 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts
@@ -24,7 +24,6 @@
 import '../../shared/gr-tooltip-content/gr-tooltip-content';
 import '../gr-plugin-config-array-editor/gr-plugin-config-array-editor';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-plugin-config_html';
 import {customElement, property} from '@polymer/decorators';
@@ -61,7 +60,7 @@
 }
 
 @customElement('gr-repo-plugin-config')
-class GrRepoPluginConfig extends LegacyElementMixin(PolymerElement) {
+class GrRepoPluginConfig extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config_html.ts b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config_html.ts
index 3045108..1a7c2a0 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config_html.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config_html.ts
@@ -63,7 +63,7 @@
                 on-change="_handleBooleanChange"
                 data-option-key$="[[option._key]]"
                 disabled$="[[_computeDisabled(option.info.editable)]]"
-                on-tap="_onTapPluginBoolean"
+                on-click="_onTapPluginBoolean"
               ></paper-toggle-button>
             </template>
             <template is="dom-if" if="[[_isList(option.info.type)]]">
diff --git a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.ts b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.ts
index 572612f..dc28bcb 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.ts
@@ -24,7 +24,6 @@
 import '../../../styles/gr-subpage-styles';
 import '../../../styles/shared-styles';
 import '../gr-repo-plugin-config/gr-repo-plugin-config';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -82,7 +81,7 @@
 };
 
 @customElement('gr-repo')
-export class GrRepo extends LegacyElementMixin(PolymerElement) {
+export class GrRepo extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -141,8 +140,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadRepo();
 
     fireTitleChange(this, `${this.repo}`);
diff --git a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts
index c3b35a9..37e0596 100644
--- a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts
+++ b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts
@@ -19,7 +19,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-select/gr-select';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-rule-editor_html';
 import {encodeURL, getBaseUrl} from '../../../utils/url-util';
@@ -101,7 +100,7 @@
 }
 
 @customElement('gr-rule-editor')
-export class GrRuleEditor extends LegacyElementMixin(PolymerElement) {
+export class GrRuleEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -137,9 +136,8 @@
   @property({type: Object})
   _originalRuleValues?: RuleValue;
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('access-saved', () => this._handleAccessSaved());
   }
 
@@ -155,8 +153,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     // Check needed for test purposes.
     if (!this._originalRuleValues && this.rule) {
       // Observer _handleValueChange is called after the ready()
diff --git a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js
index 9cc6357..9c3646a 100644
--- a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js
@@ -197,7 +197,7 @@
       element._setupValues(element.rule);
       flush();
       flush(() => {
-        element.attached();
+        element.connectedCallback();
         done();
       });
     });
@@ -306,7 +306,7 @@
       flush();
       element.rule.value.added = true;
       flush(() => {
-        element.attached();
+        element.connectedCallback();
         done();
       });
     });
@@ -371,7 +371,7 @@
       element._setupValues(element.rule);
       flush();
       flush(() => {
-        element.attached();
+        element.connectedCallback();
         done();
       });
     });
@@ -425,7 +425,7 @@
       flush();
       element.rule.value.added = true;
       flush(() => {
-        element.attached();
+        element.connectedCallback();
         done();
       });
     });
@@ -482,7 +482,7 @@
       element._setupValues(element.rule);
       flush();
       flush(() => {
-        element.attached();
+        element.connectedCallback();
         done();
       });
     });
@@ -524,7 +524,7 @@
       flush();
       element.rule.value.added = true;
       flush(() => {
-        element.attached();
+        element.connectedCallback();
         done();
       });
     });
@@ -571,7 +571,7 @@
       element._setupValues(element.rule);
       flush();
       flush(() => {
-        element.attached();
+        element.connectedCallback();
         done();
       });
     });
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
index 64e2810..20941a61e 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
@@ -26,7 +26,6 @@
 import '../../../styles/shared-styles';
 import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
 import '../../plugins/gr-endpoint-param/gr-endpoint-param';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-list-item_html';
 import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-table-mixin';
@@ -77,9 +76,7 @@
 const PRIMARY_REVIEWERS_COUNT = 2;
 
 @customElement('gr-change-list-item')
-export class GrChangeListItem extends ChangeTableMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrChangeListItem extends ChangeTableMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -125,8 +122,8 @@
   reporting: ReportingService = appContext.reportingService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     getPluginLoader()
       .awaitPluginsLoaded()
       .then(() => {
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.js b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.js
deleted file mode 100644
index 5570d26..0000000
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.js
+++ /dev/null
@@ -1,362 +0,0 @@
-/**
- * @license
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import './gr-change-list-item.js';
-import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
-import {LabelCategory} from './gr-change-list-item.js';
-import {stubRestApi} from '../../../test/test-utils.js';
-
-const basicFixture = fixtureFromElement('gr-change-list-item');
-
-suite('gr-change-list-item tests', () => {
-  let element;
-
-  setup(() => {
-    stubRestApi('getLoggedIn').returns(Promise.resolve(false));
-    element = basicFixture.instantiate();
-  });
-
-  test('_computeLabelCategory', () => {
-    assert.equal(element._computeLabelCategory({labels: {}}),
-        LabelCategory.NOT_APPLICABLE);
-    assert.equal(element._computeLabelCategory(
-        {labels: {}}, 'Verified'), LabelCategory.NOT_APPLICABLE);
-    assert.equal(element._computeLabelCategory(
-        {labels: {Verified: {approved: true, value: 1}}}, 'Verified'),
-    LabelCategory.APPROVED);
-    assert.equal(element._computeLabelCategory(
-        {labels: {Verified: {rejected: true, value: -1}}}, 'Verified'),
-    LabelCategory.REJECTED);
-    assert.equal(element._computeLabelCategory(
-        {
-          labels: {'Code-Review': {approved: true, value: 1}},
-          unresolved_comment_count: 1,
-        }, 'Code-Review'),
-    LabelCategory.UNRESOLVED_COMMENTS);
-    assert.equal(element._computeLabelCategory(
-        {labels: {'Code-Review': {value: 1}}}, 'Code-Review'),
-    LabelCategory.POSITIVE);
-    assert.equal(element._computeLabelCategory(
-        {labels: {'Code-Review': {value: -1}}}, 'Code-Review'),
-    LabelCategory.NEGATIVE);
-    assert.equal(element._computeLabelCategory(
-        {labels: {'Code-Review': {value: -1}}}, 'Verified'),
-    LabelCategory.NOT_APPLICABLE);
-  });
-
-  test('_computeLabelClass', () => {
-    assert.equal(element._computeLabelClass({labels: {}}),
-        'cell label u-gray-background');
-    assert.equal(element._computeLabelClass(
-        {labels: {}}, 'Verified'), 'cell label u-gray-background');
-    assert.equal(element._computeLabelClass(
-        {labels: {Verified: {approved: true, value: 1}}}, 'Verified'),
-    'cell label u-green');
-    assert.equal(element._computeLabelClass(
-        {labels: {Verified: {rejected: true, value: -1}}}, 'Verified'),
-    'cell label u-red');
-    assert.equal(element._computeLabelClass(
-        {labels: {'Code-Review': {value: 1}}}, 'Code-Review'),
-    'cell label u-green u-monospace');
-    assert.equal(element._computeLabelClass(
-        {labels: {'Code-Review': {value: -1}}}, 'Code-Review'),
-    'cell label u-monospace u-red');
-    assert.equal(element._computeLabelClass(
-        {labels: {'Code-Review': {value: -1}}}, 'Verified'),
-    'cell label u-gray-background');
-  });
-
-  test('_computeLabelTitle', () => {
-    assert.equal(element._computeLabelTitle({labels: {}}, 'Verified'),
-        'Label not applicable');
-    assert.equal(element._computeLabelTitle(
-        {labels: {Verified: {approved: {name: 'Diffy'}}}}, 'Verified'),
-    'Verified by Diffy');
-    assert.equal(element._computeLabelTitle(
-        {labels: {Verified: {approved: {name: 'Diffy'}}}}, 'Code-Review'),
-    'Label not applicable');
-    assert.equal(element._computeLabelTitle(
-        {labels: {Verified: {rejected: {name: 'Diffy'}}}}, 'Verified'),
-    'Verified by Diffy');
-    assert.equal(element._computeLabelTitle(
-        {labels: {'Code-Review': {disliked: {name: 'Diffy'}, value: -1}}},
-        'Code-Review'), 'Code-Review by Diffy');
-    assert.equal(element._computeLabelTitle(
-        {labels: {'Code-Review': {recommended: {name: 'Diffy'}, value: 1}}},
-        'Code-Review'), 'Code-Review by Diffy');
-    assert.equal(element._computeLabelTitle(
-        {labels: {'Code-Review': {recommended: {name: 'Diffy'},
-          rejected: {name: 'Admin'}}}}, 'Code-Review'),
-    'Code-Review by Admin');
-    assert.equal(element._computeLabelTitle(
-        {labels: {'Code-Review': {approved: {name: 'Diffy'},
-          rejected: {name: 'Admin'}}}}, 'Code-Review'),
-    'Code-Review by Admin');
-    assert.equal(element._computeLabelTitle(
-        {labels: {'Code-Review': {recommended: {name: 'Diffy'},
-          disliked: {name: 'Admin'}, value: -1}}}, 'Code-Review'),
-    'Code-Review by Admin');
-    assert.equal(element._computeLabelTitle(
-        {labels: {'Code-Review': {approved: {name: 'Diffy'},
-          disliked: {name: 'Admin'}, value: -1}}}, 'Code-Review'),
-    'Code-Review by Diffy');
-    assert.equal(element._computeLabelTitle(
-        {
-          labels: {'Code-Review': {approved: true, value: 1}},
-          unresolved_comment_count: 1,
-        }, 'Code-Review'),
-    '1 unresolved comment');
-    assert.equal(element._computeLabelTitle(
-        {
-          labels: {'Code-Review': {approved: {name: 'Diffy'}, value: 1}},
-          unresolved_comment_count: 1,
-        }, 'Code-Review'),
-    '1 unresolved comment,\nCode-Review by Diffy');
-    assert.equal(element._computeLabelTitle(
-        {
-          labels: {'Code-Review': {approved: true, value: 1}},
-          unresolved_comment_count: 2,
-        }, 'Code-Review'),
-    '2 unresolved comments');
-  });
-
-  test('_computeLabelIcon', () => {
-    assert.equal(element._computeLabelIcon({labels: {}}), '');
-    assert.equal(element._computeLabelIcon(
-        {labels: {Verified: {approved: true, value: 1}}}, 'Verified'),
-    'gr-icons:check');
-    assert.equal(element._computeLabelIcon(
-        {
-          labels: {'Code-Review': {approved: true, value: 1}},
-          unresolved_comment_count: 1,
-        }, 'Code-Review'),
-    'gr-icons:comment');
-  });
-
-  test('_computeLabelValue', () => {
-    assert.equal(element._computeLabelValue({labels: {}}), '');
-    assert.equal(element._computeLabelValue({labels: {}}, 'Verified'), '');
-    assert.equal(element._computeLabelValue(
-        {labels: {Verified: {approved: true, value: 1}}}, 'Verified'), '✓');
-    assert.equal(element._computeLabelValue(
-        {labels: {Verified: {value: 1}}}, 'Verified'), '+1');
-    assert.equal(element._computeLabelValue(
-        {labels: {Verified: {value: -1}}}, 'Verified'), '-1');
-    assert.equal(element._computeLabelValue(
-        {labels: {Verified: {approved: true}}}, 'Verified'), '✓');
-    assert.equal(element._computeLabelValue(
-        {labels: {Verified: {rejected: true}}}, 'Verified'), '✕');
-  });
-
-  test('no hidden columns', () => {
-    element.visibleChangeTableColumns = [
-      'Subject',
-      'Status',
-      'Owner',
-      'Assignee',
-      'Reviewers',
-      'Comments',
-      'Repo',
-      'Branch',
-      'Updated',
-      'Size',
-    ];
-
-    flush();
-
-    for (const column of element.columnNames) {
-      const elementClass = '.' + column.toLowerCase();
-      assert.isOk(element.shadowRoot
-          .querySelector(elementClass),
-      `Expect ${elementClass} element to be found`);
-      assert.isFalse(element.shadowRoot
-          .querySelector(elementClass).hidden);
-    }
-  });
-
-  test('repo column hidden', () => {
-    element.visibleChangeTableColumns = [
-      'Subject',
-      'Status',
-      'Owner',
-      'Assignee',
-      'Reviewers',
-      'Comments',
-      'Branch',
-      'Updated',
-      'Size',
-    ];
-
-    flush();
-
-    for (const column of element.columnNames) {
-      const elementClass = '.' + column.toLowerCase();
-      if (column === 'Repo') {
-        assert.isTrue(element.shadowRoot
-            .querySelector(elementClass).hidden);
-      } else {
-        assert.isFalse(element.shadowRoot
-            .querySelector(elementClass).hidden);
-      }
-    }
-  });
-
-  function checkComputeReviewers(
-      userId, reviewerIds, reviewerNames, attSetIds, expected) {
-    element.account = userId ? {_account_id: userId} : null;
-    element.change = {
-      owner: {
-        _account_id: 99,
-      },
-      reviewers: {
-        REVIEWER: [],
-      },
-      attention_set: {},
-    };
-    for (let i = 0; i < reviewerIds.length; i++) {
-      element.change.reviewers.REVIEWER.push({
-        _account_id: reviewerIds[i],
-        name: reviewerNames[i],
-      });
-    }
-    attSetIds.forEach(id => element.change.attention_set[id] = {});
-
-    const actual = element._computeReviewers(element.change)
-        .map(r => r._account_id);
-    assert.deepEqual(actual, expected);
-  }
-
-  test('compute reviewers', () => {
-    checkComputeReviewers(null, [], [], [], []);
-    checkComputeReviewers(1, [], [], [], []);
-    checkComputeReviewers(1, [2], ['a'], [], [2]);
-    checkComputeReviewers(1, [2, 3], [undefined, 'a'], [], [2, 3]);
-    checkComputeReviewers(1, [2, 3], ['a', undefined], [], [3, 2]);
-    checkComputeReviewers(1, [99], ['owner'], [], []);
-    checkComputeReviewers(
-        1, [2, 3, 4, 5], ['b', 'a', 'd', 'c'], [3, 4], [3, 4, 2, 5]);
-    checkComputeReviewers(
-        1, [2, 3, 1, 4, 5], ['b', 'a', 'x', 'd', 'c'], [3, 4], [1, 3, 4, 2, 5]);
-  });
-
-  test('random column does not exist', () => {
-    element.visibleChangeTableColumns = [
-      'Bad',
-    ];
-
-    flush();
-    const elementClass = '.bad';
-    assert.isNotOk(element.shadowRoot
-        .querySelector(elementClass));
-  });
-
-  test('assignee only displayed if there is one', () => {
-    element.change = {};
-    flush();
-    assert.isNotOk(element.shadowRoot
-        .querySelector('.assignee gr-account-link'));
-    assert.equal(element.shadowRoot
-        .querySelector('.assignee').textContent.trim(), '--');
-    element.change = {
-      assignee: {
-        name: 'test',
-        status: 'test',
-      },
-    };
-    flush();
-    assert.isOk(element.shadowRoot
-        .querySelector('.assignee gr-account-link'));
-  });
-
-  test('TShirt sizing tooltip', () => {
-    assert.equal(element._computeSizeTooltip({
-      insertions: 'foo',
-      deletions: 'bar',
-    }), 'Size unknown');
-    assert.equal(element._computeSizeTooltip({
-      insertions: 0,
-      deletions: 0,
-    }), 'Size unknown');
-    assert.equal(element._computeSizeTooltip({
-      insertions: 1,
-      deletions: 2,
-    }), 'added 1, removed 2 lines');
-  });
-
-  test('TShirt sizing', () => {
-    assert.equal(element._computeChangeSize({
-      insertions: 'foo',
-      deletions: 'bar',
-    }), null);
-    assert.equal(element._computeChangeSize({
-      insertions: 1,
-      deletions: 1,
-    }), 'XS');
-    assert.equal(element._computeChangeSize({
-      insertions: 9,
-      deletions: 1,
-    }), 'S');
-    assert.equal(element._computeChangeSize({
-      insertions: 10,
-      deletions: 200,
-    }), 'M');
-    assert.equal(element._computeChangeSize({
-      insertions: 99,
-      deletions: 900,
-    }), 'L');
-    assert.equal(element._computeChangeSize({
-      insertions: 99,
-      deletions: 999,
-    }), 'XL');
-  });
-
-  test('change params passed to gr-navigation', () => {
-    sinon.stub(GerritNav);
-    const change = {
-      internalHost: 'test-host',
-      project: 'test-repo',
-      topic: 'test-topic',
-      branch: 'test-branch',
-    };
-    element.change = change;
-    flush();
-
-    assert.deepEqual(GerritNav.getUrlForChange.lastCall.args, [change]);
-    assert.deepEqual(GerritNav.getUrlForProjectChanges.lastCall.args,
-        [change.project, true, change.internalHost]);
-    assert.deepEqual(GerritNav.getUrlForBranch.lastCall.args,
-        [change.branch, change.project, undefined, change.internalHost]);
-    assert.deepEqual(GerritNav.getUrlForTopic.lastCall.args,
-        [change.topic, change.internalHost]);
-  });
-
-  test('_computeRepoDisplay', () => {
-    const change = {
-      project: 'a/test/repo',
-      internalHost: 'host',
-    };
-    assert.equal(element._computeRepoDisplay(change), 'host/a/test/repo');
-    assert.equal(element._computeRepoDisplay(change, true),
-        'host/…/test/repo');
-    delete change.internalHost;
-    assert.equal(element._computeRepoDisplay(change), 'a/test/repo');
-    assert.equal(element._computeRepoDisplay(change, true),
-        '…/test/repo');
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.ts
new file mode 100644
index 0000000..ac0b929
--- /dev/null
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.ts
@@ -0,0 +1,577 @@
+/**
+ * @license
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import '../../../test/common-test-setup-karma';
+import {
+  createAccountWithId,
+  createChange,
+} from '../../../test/test-data-generators';
+import {query, queryAndAssert, stubRestApi} from '../../../test/test-utils';
+import {
+  AccountId,
+  BranchName,
+  ChangeInfo,
+  RepoName,
+  TopicName,
+} from '../../../types/common';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation';
+import './gr-change-list-item';
+import {GrChangeListItem, LabelCategory} from './gr-change-list-item';
+
+const basicFixture = fixtureFromElement('gr-change-list-item');
+
+suite('gr-change-list-item tests', () => {
+  const account = createAccountWithId();
+  const change: ChangeInfo = {
+    ...createChange(),
+    internalHost: 'host',
+    project: 'a/test/repo' as RepoName,
+    topic: 'test-topic' as TopicName,
+    branch: 'test-branch' as BranchName,
+  };
+
+  let element: GrChangeListItem;
+
+  setup(() => {
+    stubRestApi('getLoggedIn').returns(Promise.resolve(false));
+    element = basicFixture.instantiate();
+  });
+
+  test('_computeLabelCategory', () => {
+    assert.equal(
+      element._computeLabelCategory({...change, labels: {}}, 'Verified'),
+      LabelCategory.NOT_APPLICABLE
+    );
+    assert.equal(
+      element._computeLabelCategory(
+        {...change, labels: {Verified: {approved: account, value: 1}}},
+        'Verified'
+      ),
+      LabelCategory.APPROVED
+    );
+    assert.equal(
+      element._computeLabelCategory(
+        {...change, labels: {Verified: {rejected: account, value: -1}}},
+        'Verified'
+      ),
+      LabelCategory.REJECTED
+    );
+    assert.equal(
+      element._computeLabelCategory(
+        {
+          ...change,
+          labels: {'Code-Review': {approved: account, value: 1}},
+          unresolved_comment_count: 1,
+        },
+        'Code-Review'
+      ),
+      LabelCategory.UNRESOLVED_COMMENTS
+    );
+    assert.equal(
+      element._computeLabelCategory(
+        {...change, labels: {'Code-Review': {value: 1}}},
+        'Code-Review'
+      ),
+      LabelCategory.POSITIVE
+    );
+    assert.equal(
+      element._computeLabelCategory(
+        {...change, labels: {'Code-Review': {value: -1}}},
+        'Code-Review'
+      ),
+      LabelCategory.NEGATIVE
+    );
+    assert.equal(
+      element._computeLabelCategory(
+        {...change, labels: {'Code-Review': {value: -1}}},
+        'Verified'
+      ),
+      LabelCategory.NOT_APPLICABLE
+    );
+  });
+
+  test('_computeLabelClass', () => {
+    assert.equal(
+      element._computeLabelClass({...change, labels: {}}, 'Verified'),
+      'cell label u-gray-background'
+    );
+    assert.equal(
+      element._computeLabelClass(
+        {...change, labels: {Verified: {approved: account, value: 1}}},
+        'Verified'
+      ),
+      'cell label u-green'
+    );
+    assert.equal(
+      element._computeLabelClass(
+        {...change, labels: {Verified: {rejected: account, value: -1}}},
+        'Verified'
+      ),
+      'cell label u-red'
+    );
+    assert.equal(
+      element._computeLabelClass(
+        {...change, labels: {'Code-Review': {value: 1}}},
+        'Code-Review'
+      ),
+      'cell label u-green u-monospace'
+    );
+    assert.equal(
+      element._computeLabelClass(
+        {...change, labels: {'Code-Review': {value: -1}}},
+        'Code-Review'
+      ),
+      'cell label u-monospace u-red'
+    );
+    assert.equal(
+      element._computeLabelClass(
+        {...change, labels: {'Code-Review': {value: -1}}},
+        'Verified'
+      ),
+      'cell label u-gray-background'
+    );
+  });
+
+  test('_computeLabelTitle', () => {
+    assert.equal(
+      element._computeLabelTitle({...change, labels: {}}, 'Verified'),
+      'Label not applicable'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {...change, labels: {Verified: {approved: {name: 'Diffy'}}}},
+        'Verified'
+      ),
+      'Verified by Diffy'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {...change, labels: {Verified: {approved: {name: 'Diffy'}}}},
+        'Code-Review'
+      ),
+      'Label not applicable'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {...change, labels: {Verified: {rejected: {name: 'Diffy'}}}},
+        'Verified'
+      ),
+      'Verified by Diffy'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {'Code-Review': {disliked: {name: 'Diffy'}, value: -1}},
+        },
+        'Code-Review'
+      ),
+      'Code-Review by Diffy'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {'Code-Review': {recommended: {name: 'Diffy'}, value: 1}},
+        },
+        'Code-Review'
+      ),
+      'Code-Review by Diffy'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {
+            'Code-Review': {
+              recommended: {name: 'Diffy'},
+              rejected: {name: 'Admin'},
+            },
+          },
+        },
+        'Code-Review'
+      ),
+      'Code-Review by Admin'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {
+            'Code-Review': {
+              approved: {name: 'Diffy'},
+              rejected: {name: 'Admin'},
+            },
+          },
+        },
+        'Code-Review'
+      ),
+      'Code-Review by Admin'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {
+            'Code-Review': {
+              recommended: {name: 'Diffy'},
+              disliked: {name: 'Admin'},
+              value: -1,
+            },
+          },
+        },
+        'Code-Review'
+      ),
+      'Code-Review by Admin'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {
+            'Code-Review': {
+              approved: {name: 'Diffy'},
+              disliked: {name: 'Admin'},
+              value: -1,
+            },
+          },
+        },
+        'Code-Review'
+      ),
+      'Code-Review by Diffy'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {'Code-Review': {approved: account, value: 1}},
+          unresolved_comment_count: 1,
+        },
+        'Code-Review'
+      ),
+      '1 unresolved comment'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {'Code-Review': {approved: {name: 'Diffy'}, value: 1}},
+          unresolved_comment_count: 1,
+        },
+        'Code-Review'
+      ),
+      '1 unresolved comment,\nCode-Review by Diffy'
+    );
+    assert.equal(
+      element._computeLabelTitle(
+        {
+          ...change,
+          labels: {'Code-Review': {approved: account, value: 1}},
+          unresolved_comment_count: 2,
+        },
+        'Code-Review'
+      ),
+      '2 unresolved comments'
+    );
+  });
+
+  test('_computeLabelIcon', () => {
+    assert.equal(
+      element._computeLabelIcon({...change, labels: {}}, 'missingLabel'),
+      ''
+    );
+    assert.equal(
+      element._computeLabelIcon(
+        {...change, labels: {Verified: {approved: account, value: 1}}},
+        'Verified'
+      ),
+      'gr-icons:check'
+    );
+    assert.equal(
+      element._computeLabelIcon(
+        {
+          ...change,
+          labels: {'Code-Review': {approved: account, value: 1}},
+          unresolved_comment_count: 1,
+        },
+        'Code-Review'
+      ),
+      'gr-icons:comment'
+    );
+  });
+
+  test('_computeLabelValue', () => {
+    assert.equal(
+      element._computeLabelValue({...change, labels: {}}, 'Verified'),
+      ''
+    );
+    assert.equal(
+      element._computeLabelValue(
+        {...change, labels: {Verified: {approved: account, value: 1}}},
+        'Verified'
+      ),
+      '✓'
+    );
+    assert.equal(
+      element._computeLabelValue(
+        {...change, labels: {Verified: {value: 1}}},
+        'Verified'
+      ),
+      '+1'
+    );
+    assert.equal(
+      element._computeLabelValue(
+        {...change, labels: {Verified: {value: -1}}},
+        'Verified'
+      ),
+      '-1'
+    );
+    assert.equal(
+      element._computeLabelValue(
+        {...change, labels: {Verified: {approved: account}}},
+        'Verified'
+      ),
+      '✓'
+    );
+    assert.equal(
+      element._computeLabelValue(
+        {...change, labels: {Verified: {rejected: account}}},
+        'Verified'
+      ),
+      '✕'
+    );
+  });
+
+  test('no hidden columns', async () => {
+    element.visibleChangeTableColumns = [
+      'Subject',
+      'Status',
+      'Owner',
+      'Assignee',
+      'Reviewers',
+      'Comments',
+      'Repo',
+      'Branch',
+      'Updated',
+      'Size',
+    ];
+
+    await flush();
+
+    for (const column of element.columnNames) {
+      const elementClass = '.' + column.toLowerCase();
+      assert.isFalse(
+        queryAndAssert(element, elementClass).hasAttribute('hidden')
+      );
+    }
+  });
+
+  test('repo column hidden', async () => {
+    element.visibleChangeTableColumns = [
+      'Subject',
+      'Status',
+      'Owner',
+      'Assignee',
+      'Reviewers',
+      'Comments',
+      'Branch',
+      'Updated',
+      'Size',
+    ];
+
+    await flush();
+
+    for (const column of element.columnNames) {
+      const elementClass = '.' + column.toLowerCase();
+      if (column === 'Repo') {
+        assert.isTrue(
+          queryAndAssert(element, elementClass).hasAttribute('hidden')
+        );
+      } else {
+        assert.isFalse(
+          queryAndAssert(element, elementClass).hasAttribute('hidden')
+        );
+      }
+    }
+  });
+
+  function checkComputeReviewers(
+    userId: number | undefined,
+    reviewerIds: number[],
+    reviewerNames: (string | undefined)[],
+    attSetIds: number[],
+    expected: number[]
+  ) {
+    element.account = userId ? {_account_id: userId as AccountId} : null;
+    element.change = {
+      ...change,
+      owner: {
+        _account_id: 99 as AccountId,
+      },
+      reviewers: {
+        REVIEWER: [],
+      },
+      attention_set: {},
+    };
+    for (let i = 0; i < reviewerIds.length; i++) {
+      element.change!.reviewers.REVIEWER!.push({
+        _account_id: reviewerIds[i] as AccountId,
+        name: reviewerNames[i],
+      });
+    }
+    attSetIds.forEach(id => (element.change!.attention_set![id] = {account}));
+
+    const actual = element
+      ._computeReviewers(element.change)
+      .map(r => r._account_id);
+    assert.deepEqual(actual, expected as AccountId[]);
+  }
+
+  test('compute reviewers', () => {
+    checkComputeReviewers(undefined, [], [], [], []);
+    checkComputeReviewers(1, [], [], [], []);
+    checkComputeReviewers(1, [2], ['a'], [], [2]);
+    checkComputeReviewers(1, [2, 3], [undefined, 'a'], [], [2, 3]);
+    checkComputeReviewers(1, [2, 3], ['a', undefined], [], [3, 2]);
+    checkComputeReviewers(1, [99], ['owner'], [], []);
+    checkComputeReviewers(
+      1,
+      [2, 3, 4, 5],
+      ['b', 'a', 'd', 'c'],
+      [3, 4],
+      [3, 4, 2, 5]
+    );
+    checkComputeReviewers(
+      1,
+      [2, 3, 1, 4, 5],
+      ['b', 'a', 'x', 'd', 'c'],
+      [3, 4],
+      [1, 3, 4, 2, 5]
+    );
+  });
+
+  test('random column does not exist', async () => {
+    element.visibleChangeTableColumns = ['Bad'];
+
+    await flush();
+    const elementClass = '.bad';
+    assert.isNotOk(query(element, elementClass));
+  });
+
+  test('assignee only displayed if there is one', async () => {
+    element.change = change;
+    await flush();
+    assert.isNotOk(query(element, '.assignee gr-account-link'));
+    assert.equal(
+      queryAndAssert(element, '.assignee').textContent!.trim(),
+      '--'
+    );
+    element.change = {
+      ...change,
+      assignee: {
+        name: 'test',
+        status: 'test',
+      },
+    };
+    await flush();
+    queryAndAssert(element, '.assignee gr-account-link');
+  });
+
+  test('TShirt sizing tooltip', () => {
+    assert.equal(
+      element._computeSizeTooltip({
+        ...change,
+        insertions: NaN,
+        deletions: NaN,
+      }),
+      'Size unknown'
+    );
+    assert.equal(
+      element._computeSizeTooltip({...change, insertions: 0, deletions: 0}),
+      'Size unknown'
+    );
+    assert.equal(
+      element._computeSizeTooltip({...change, insertions: 1, deletions: 2}),
+      'added 1, removed 2 lines'
+    );
+  });
+
+  test('TShirt sizing', () => {
+    assert.equal(
+      element._computeChangeSize({
+        ...change,
+        insertions: NaN,
+        deletions: NaN,
+      }),
+      null
+    );
+    assert.equal(
+      element._computeChangeSize({...change, insertions: 1, deletions: 1}),
+      'XS'
+    );
+    assert.equal(
+      element._computeChangeSize({...change, insertions: 9, deletions: 1}),
+      'S'
+    );
+    assert.equal(
+      element._computeChangeSize({...change, insertions: 10, deletions: 200}),
+      'M'
+    );
+    assert.equal(
+      element._computeChangeSize({...change, insertions: 99, deletions: 900}),
+      'L'
+    );
+    assert.equal(
+      element._computeChangeSize({...change, insertions: 99, deletions: 999}),
+      'XL'
+    );
+  });
+
+  test('change params passed to gr-navigation', async () => {
+    const navStub = sinon.stub(GerritNav);
+    element.change = change;
+    await flush();
+
+    assert.deepEqual(navStub.getUrlForChange.lastCall.args, [change]);
+    assert.deepEqual(navStub.getUrlForProjectChanges.lastCall.args, [
+      change.project,
+      true,
+      change.internalHost,
+    ]);
+    assert.deepEqual(navStub.getUrlForBranch.lastCall.args, [
+      change.branch,
+      change.project,
+      undefined,
+      change.internalHost,
+    ]);
+    assert.deepEqual(navStub.getUrlForTopic.lastCall.args, [
+      change.topic,
+      change.internalHost,
+    ]);
+  });
+
+  test('_computeRepoDisplay', () => {
+    assert.equal(
+      element._computeRepoDisplay(change, false),
+      'host/a/test/repo'
+    );
+    assert.equal(element._computeRepoDisplay(change, true), 'host/…/test/repo');
+    delete change.internalHost;
+    assert.equal(element._computeRepoDisplay(change, false), 'a/test/repo');
+    assert.equal(element._computeRepoDisplay(change, true), '…/test/repo');
+  });
+});
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts
index 60fcd1f..8ce00f2 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts
@@ -20,7 +20,6 @@
 import '../gr-repo-header/gr-repo-header';
 import '../gr-user-header/gr-user-header';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-list-view_html';
 import {page} from '../../../utils/page-wrapper-utils';
@@ -61,7 +60,7 @@
 }
 
 @customElement('gr-change-list-view')
-export class GrChangeListView extends LegacyElementMixin(PolymerElement) {
+export class GrChangeListView extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -110,16 +109,15 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('next-page', () => this._handleNextPage());
     this.addEventListener('previous-page', () => this._handlePreviousPage());
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadPreferences();
   }
 
@@ -141,7 +139,7 @@
 
     // NOTE: This method may be called before attachment. Fire title-change
     // in an async so that attachment to the DOM can take place first.
-    this.async(() => fireTitleChange(this, this._query));
+    setTimeout(() => fireTitleChange(this, this._query));
 
     this.restApiService
       .getPreferences()
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
index c9b095c..e47bd1f 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
@@ -21,7 +21,6 @@
 import '../../../styles/shared-styles';
 import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
 import {afterNextRender} from '@polymer/polymer/lib/utils/render-status';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-list_html';
 import {appContext} from '../../../services/app-context';
@@ -55,6 +54,7 @@
 import {CustomKeyboardEvent} from '../../../types/events';
 import {fireEvent} from '../../../utils/event-util';
 import {windowLocationReload} from '../../../utils/dom-util';
+import {ScrollMode} from '../../../constants/constants';
 
 const NUMBER_FIXED_COLUMNS = 3;
 const CLOSED_STATUS = ['MERGED', 'ABANDONED'];
@@ -67,13 +67,11 @@
   results: ChangeInfo[];
 }
 export interface GrChangeList {
-  $: {
-    cursor: GrCursorManager;
-  };
+  $: {};
 }
 @customElement('gr-change-list')
 export class GrChangeList extends ChangeTableMixin(
-  KeyboardShortcutMixin(LegacyElementMixin(PolymerElement))
+  KeyboardShortcutMixin(PolymerElement)
 ) {
   static get template() {
     return htmlTemplate;
@@ -158,9 +156,11 @@
     };
   }
 
-  /** @override */
-  created() {
-    super.created();
+  private cursor = new GrCursorManager();
+
+  constructor() {
+    super();
+    this.cursor.scrollMode = ScrollMode.KEEP_VISIBLE;
     this.addEventListener('keydown', e => this._scopedKeydownHandler(e));
   }
 
@@ -173,8 +173,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     getPluginLoader()
       .awaitPluginsLoaded()
       .then(() => {
@@ -184,6 +184,12 @@
       });
   }
 
+  /** @override */
+  disconnectedCallback() {
+    this.cursor.unsetCursor();
+    super.disconnectedCallback();
+  }
+
   /**
    * Iron-a11y-keys-behavior catches keyboard events globally. Some keyboard
    * events must be scoped to a component level (e.g. `enter`) in order to not
@@ -392,8 +398,8 @@
     }
 
     e.preventDefault();
-    this.$.cursor.next();
-    this.selectedIndex = this.$.cursor.index;
+    this.cursor.next();
+    this.selectedIndex = this.cursor.index;
   }
 
   _prevChange(e: CustomKeyboardEvent) {
@@ -402,8 +408,8 @@
     }
 
     e.preventDefault();
-    this.$.cursor.previous();
-    this.selectedIndex = this.$.cursor.index;
+    this.cursor.previous();
+    this.selectedIndex = this.cursor.index;
   }
 
   _openChange(e: CustomKeyboardEvent) {
@@ -516,10 +522,9 @@
   _sectionsChanged() {
     // Flush DOM operations so that the list item elements will be loaded.
     afterNextRender(this, () => {
-      this.$.cursor.stops = this._getListItems();
-      this.$.cursor.moveToStart();
-      if (this.selectedIndex)
-        this.$.cursor.setCursorAtIndex(this.selectedIndex);
+      this.cursor.stops = this._getListItems();
+      this.cursor.moveToStart();
+      if (this.selectedIndex) this.cursor.setCursorAtIndex(this.selectedIndex);
     });
   }
 
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_html.ts b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_html.ts
index 0313e0b..b6b4160 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_html.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_html.ts
@@ -161,9 +161,4 @@
       </tbody>
     </template>
   </table>
-  <gr-cursor-manager
-    id="cursor"
-    scroll-mode="keep-visible"
-    focus-on-move=""
-  ></gr-cursor-manager>
 `;
diff --git a/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.ts b/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.ts
index a6f3d85..0e2668d 100644
--- a/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.ts
@@ -18,7 +18,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-icons/gr-icons';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement} from '@polymer/decorators';
 import {htmlTemplate} from './gr-create-change-help_html';
@@ -31,7 +30,7 @@
 }
 
 @customElement('gr-create-change-help')
-class GrCreateChangeHelp extends LegacyElementMixin(PolymerElement) {
+class GrCreateChangeHelp extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.ts b/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.ts
index ed4c968..f2f767a 100644
--- a/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.ts
@@ -19,7 +19,6 @@
 import '../../shared/gr-overlay/gr-overlay';
 import '../../shared/gr-shell-command/gr-shell-command';
 import {GrOverlay} from '../../shared/gr-overlay/gr-overlay';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement, property} from '@polymer/decorators';
 import {htmlTemplate} from './gr-create-commands-dialog_html';
@@ -43,7 +42,7 @@
 }
 
 @customElement('gr-create-commands-dialog')
-export class GrCreateCommandsDialog extends LegacyElementMixin(PolymerElement) {
+export class GrCreateCommandsDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change-list/gr-create-destination-dialog/gr-create-destination-dialog.ts b/polygerrit-ui/app/elements/change-list/gr-create-destination-dialog/gr-create-destination-dialog.ts
index 5c263bb..ff9666b 100644
--- a/polygerrit-ui/app/elements/change-list/gr-create-destination-dialog/gr-create-destination-dialog.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-create-destination-dialog/gr-create-destination-dialog.ts
@@ -18,7 +18,6 @@
 import '../../shared/gr-dialog/gr-dialog';
 import '../../shared/gr-overlay/gr-overlay';
 import '../../shared/gr-repo-branch-picker/gr-repo-branch-picker';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-create-destination-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -43,9 +42,7 @@
 }
 
 @customElement('gr-create-destination-dialog')
-export class GrCreateDestinationDialog extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrCreateDestinationDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
index d834b16..f9dee5f 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
@@ -23,7 +23,6 @@
 import '../gr-create-change-help/gr-create-change-help';
 import '../gr-create-destination-dialog/gr-create-destination-dialog';
 import '../gr-user-header/gr-user-header';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-dashboard-view_html';
 import {
@@ -78,7 +77,7 @@
 }
 
 @customElement('gr-dashboard-view')
-export class GrDashboardView extends LegacyElementMixin(PolymerElement) {
+export class GrDashboardView extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -127,8 +126,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadPreferences();
     this.addEventListener('reload', e => {
       e.stopPropagation();
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
index a5de72b..165306e 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
@@ -17,13 +17,12 @@
 
 import '../../../test/common-test-setup-karma.js';
 import './gr-dashboard-view.js';
-import {isHidden} from '../../../test/test-utils.js';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
 import {GerritView} from '../../../services/router/router-model.js';
 import {changeIsOpen} from '../../../utils/change-util.js';
 import {ChangeStatus} from '../../../constants/constants.js';
 import {createAccountWithId} from '../../../test/test-data-generators.js';
-import {addListenerForTest, stubRestApi} from '../../../test/test-utils.js';
+import {addListenerForTest, stubRestApi, isHidden} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-dashboard-view');
 
diff --git a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts
index ec24800..6fa28ae 100644
--- a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts
@@ -18,16 +18,14 @@
 import '../../../styles/dashboard-header-styles';
 import '../../../styles/shared-styles';
 import '../../shared/gr-date-formatter/gr-date-formatter';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-header_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
 import {customElement, property} from '@polymer/decorators';
 import {RepoName} from '../../../types/common';
 
-/** @extends PolymerElement */
 @customElement('gr-repo-header')
-class GrRepoHeader extends LegacyElementMixin(PolymerElement) {
+class GrRepoHeader extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts
index c4406cd..5e4c361 100644
--- a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts
@@ -21,7 +21,6 @@
 import '../../shared/gr-avatar/gr-avatar';
 import '../../shared/gr-date-formatter/gr-date-formatter';
 import '../../../styles/dashboard-header-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-user-header_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -31,7 +30,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-user-header')
-export class GrUserHeader extends LegacyElementMixin(PolymerElement) {
+export class GrUserHeader extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts
index 147ebc3..42876d9 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts
@@ -30,7 +30,6 @@
 import '../gr-confirm-submit-dialog/gr-confirm-submit-dialog';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-actions_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -337,7 +336,7 @@
 }
 
 @customElement('gr-change-actions')
-export class GrChangeActions extends LegacyElementMixin(PolymerElement)
+export class GrChangeActions extends PolymerElement
   implements GrChangeActionsElement {
   static get template() {
     return htmlTemplate;
@@ -553,9 +552,8 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('fullscreen-overlay-opened', () =>
       this._handleHideBackgroundContent()
     );
@@ -2081,7 +2079,7 @@
             }
 
             if (attemptsRemaining) {
-              this.async(check, AWAIT_CHANGE_TIMEOUT_MS);
+              setTimeout(check, AWAIT_CHANGE_TIMEOUT_MS);
             } else {
               resolve(false);
             }
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js
index fbb70b7..8324fdd 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js
@@ -1854,8 +1854,9 @@
       });
 
       suite('_waitForChangeReachable', () => {
+        let clock;
         setup(() => {
-          sinon.stub(element, 'async').callsFake( fn => fn());
+          clock = sinon.useFakeTimers();
         });
 
         const makeGetChange = numTries => () => {
@@ -1867,20 +1868,27 @@
           }
         };
 
-        test('succeed', () => {
-          stubRestApi('getChange')
-              .callsFake( makeGetChange(5));
-          return element._waitForChangeReachable(123).then(success => {
-            assert.isTrue(success);
-          });
+        const tickAndFlush = async repetitions => {
+          for (let i = 1; i <= repetitions; i++) {
+            clock.tick(1000);
+            await flush();
+          }
+        };
+
+        test('succeed', async () => {
+          stubRestApi('getChange').callsFake(makeGetChange(5));
+          const promise = element._waitForChangeReachable(123);
+          tickAndFlush(5);
+          const success = await promise;
+          assert.isTrue(success);
         });
 
-        test('fail', () => {
-          stubRestApi('getChange')
-              .callsFake( makeGetChange(6));
-          return element._waitForChangeReachable(123).then(success => {
-            assert.isFalse(success);
-          });
+        test('fail', async () => {
+          stubRestApi('getChange').callsFake(makeGetChange(6));
+          const promise = element._waitForChangeReachable(123);
+          tickAndFlush(6);
+          const success = await promise;
+          assert.isFalse(success);
         });
       });
     });
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata-it_test.js b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata-it_test.js
deleted file mode 100644
index d00f64d..0000000
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata-it_test.js
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-import './gr-change-metadata.js';
-import {resetPlugins} from '../../../test/test-utils.js';
-import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
-import {stubRestApi} from '../../../test/test-utils.js';
-
-const testHtmlPlugin = document.createElement('dom-module');
-testHtmlPlugin.innerHTML = `
-    <template>
-      <style>
-        html {
-          --change-metadata-assignee: {
-            display: none;
-          }
-          --change-metadata-label-status: {
-            display: none;
-          }
-          --change-metadata-strategy: {
-            display: none;
-          }
-          --change-metadata-topic: {
-            display: none;
-          }
-        }
-      </style>
-    </template>
-  `;
-testHtmlPlugin.register('my-plugin-style');
-
-const basicFixture = fixtureFromTemplate(
-    html`<gr-change-metadata mutable="true"></gr-change-metadata>`
-);
-
-const pluginApi = _testOnly_initGerritPluginApi();
-
-suite('gr-change-metadata integration tests', () => {
-  let element;
-
-  const sectionSelectors = [
-    'section.strategy',
-    'section.topic',
-  ];
-
-  const labels = {
-    CI: {
-      all: [
-        {value: 1, name: 'user 2', _account_id: 1},
-        {value: 2, name: 'user '},
-      ],
-      values: {
-        ' 0': 'Don\'t submit as-is',
-        '+1': 'No score',
-        '+2': 'Looks good to me',
-      },
-    },
-  };
-
-  const getStyle = function(selector, name) {
-    return window.getComputedStyle(
-        element.root.querySelector(selector))[name];
-  };
-
-  function createElement() {
-    const element = basicFixture.instantiate();
-    element.change = {labels, status: 'NEW'};
-    element.revision = {};
-    return element;
-  }
-
-  setup(() => {
-    stubRestApi('getLoggedIn').returns(Promise.resolve(false));
-    stubRestApi('deleteVote').returns(Promise.resolve({ok: true}));
-  });
-
-  teardown(() => {
-    resetPlugins();
-  });
-
-  suite('by default', () => {
-    setup(done => {
-      element = createElement();
-      flush(done);
-    });
-
-    for (const sectionSelector of sectionSelectors) {
-      test(sectionSelector + ' does not have display: none', () => {
-        assert.notEqual(getStyle(sectionSelector, 'display'), 'none');
-      });
-    }
-  });
-
-  suite('with plugin style', () => {
-    setup(done => {
-      resetPlugins();
-      pluginApi.install(plugin => {
-        plugin.registerStyleModule('change-metadata', 'my-plugin-style');
-      }, undefined, 'http://test.com/plugins/style.js');
-      element = createElement();
-      getPluginLoader().loadPlugins([]);
-      getPluginLoader().awaitPluginsLoaded()
-          .then(() => {
-            flush(done);
-          });
-    });
-
-    teardown(() => {
-      document.body.querySelectorAll('custom-style')
-          .forEach(style => style.remove());
-    });
-
-    for (const sectionSelector of sectionSelectors) {
-      test('section.strategy may have display: none', () => {
-        assert.equal(getStyle(sectionSelector, 'display'), 'none');
-      });
-    }
-  });
-
-  suite('label updates', () => {
-    let plugin;
-
-    setup(() => {
-      pluginApi.install(p => {
-        plugin = p;
-        plugin.registerStyleModule('change-metadata', 'my-plugin-style');
-      }, undefined, 'http://test.com/plugins/style.js');
-      sinon.stub(getPluginLoader(), 'arePluginsLoaded').returns(true);
-      getPluginLoader().loadPlugins([]);
-      element = createElement();
-    });
-
-    teardown(() => {
-      document.body.querySelectorAll('custom-style')
-          .forEach(style => style.remove());
-    });
-
-    test('labels changed callback', done => {
-      let callCount = 0;
-      const labelChangeSpy = sinon.spy(arg => {
-        callCount++;
-        if (callCount === 1) {
-          assert.deepEqual(arg, labels);
-          assert.equal(arg.CI.all.length, 2);
-          element.set(['change', 'labels'], {
-            CI: {
-              all: [
-                {value: 1, name: 'user 2', _account_id: 1},
-              ],
-              values: {
-                ' 0': 'Don\'t submit as-is',
-                '+1': 'No score',
-                '+2': 'Looks good to me',
-              },
-            },
-          });
-        } else if (callCount === 2) {
-          assert.equal(arg.CI.all.length, 1);
-          done();
-        }
-      });
-
-      plugin.changeMetadata().onLabelsChanged(labelChangeSpy);
-    });
-  });
-});
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
index 44974ce..c19519d 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
@@ -33,7 +33,6 @@
 import '../gr-reviewer-list/gr-reviewer-list';
 import '../../shared/gr-account-list/gr-account-list';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-metadata_html';
 import {
@@ -125,7 +124,7 @@
 }
 
 @customElement('gr-change-metadata')
-export class GrChangeMetadata extends LegacyElementMixin(PolymerElement) {
+export class GrChangeMetadata extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
index 59287b2..6bfa240 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
@@ -63,7 +63,7 @@
 import {GrEditableLabel} from '../../shared/gr-editable-label/gr-editable-label';
 import {PluginApi} from '../../../api/plugin';
 import {GrEndpointDecorator} from '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
-import {stubRestApi} from '../../../test/test-utils.js';
+import {stubRestApi} from '../../../test/test-utils';
 import {ParsedChangeInfo} from '../../../types/types';
 
 const basicFixture = fixtureFromElement('gr-change-metadata');
@@ -938,7 +938,7 @@
             .then(el => (hookEl = el as MetadataGrEndpointDecorator));
         },
         '0.1',
-        'http://some/plugins/url.html'
+        'http://some/plugins/url.js'
       );
       getPluginLoader().loadPlugins([]);
       flush(() => {
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
index 0b65f53..56174e5 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
@@ -20,7 +20,6 @@
 import '../../shared/gr-label/gr-label';
 import '../../shared/gr-label-info/gr-label-info';
 import '../../shared/gr-limited-text/gr-limited-text';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-requirements_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -57,7 +56,7 @@
 }
 
 @customElement('gr-change-requirements')
-class GrChangeRequirements extends LegacyElementMixin(PolymerElement) {
+class GrChangeRequirements extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
index a502949..678fa5c 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
@@ -84,6 +84,11 @@
     .show-all-button {
       float: right;
     }
+    .show-all-button iron-icon {
+      color: inherit;
+      --iron-icon-height: 18px;
+      --iron-icon-width: 18px;
+    }
     .spacer {
       height: var(--spacing-m);
     }
diff --git a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
index f782bbf..6e20f03 100644
--- a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
@@ -432,7 +432,7 @@
                 !!draftCount ||
                 !!countUnresolvedComments}
               >
-                No Comments</span
+                No comments</span
               ><gr-summary-chip
                 styleType=${SummaryChipStyles.WARNING}
                 category=${CommentTabState.DRAFTS}
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 885bfff..9b306a0 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -45,7 +45,6 @@
 import '../gr-upload-help-dialog/gr-upload-help-dialog';
 import '../../checks/gr-checks-tab';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-view_html';
 import {
@@ -76,7 +75,7 @@
   hasEditPatchsetLoaded,
   PatchSet,
 } from '../../../utils/patch-set-util';
-import {changeStatuses, changeStatusString} from '../../../utils/change-util';
+import {changeStatuses} from '../../../utils/change-util';
 import {EventType as PluginEventType} from '../../../api/plugin';
 import {customElement, property, observe} from '@polymer/decorators';
 import {GrApplyFixDialog} from '../../diff/gr-apply-fix-dialog/gr-apply-fix-dialog';
@@ -156,24 +155,25 @@
   SwitchTabEvent,
   ThreadListModifiedEvent,
   TabState,
+  EventType,
 } from '../../../types/events';
 import {GrButton} from '../../shared/gr-button/gr-button';
 import {GrMessagesList} from '../gr-messages-list/gr-messages-list';
 import {GrThreadList} from '../gr-thread-list/gr-thread-list';
 import {
-  EventType,
   fireAlert,
   fireEvent,
   firePageError,
   fireDialogChange,
+  fireTitleChange,
 } from '../../../utils/event-util';
 import {KnownExperimentId} from '../../../services/flags/flags';
-import {fireTitleChange} from '../../../utils/event-util';
 import {GerritView} from '../../../services/router/router-model';
 import {takeUntil} from 'rxjs/operators';
 import {aPluginHasRegistered$} from '../../../services/checks/checks-model';
 import {Subject} from 'rxjs';
 import {GrRelatedChangesListExperimental} from '../gr-related-changes-list-experimental/gr-related-changes-list-experimental';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 
 const CHANGE_ID_ERROR = {
   MISMATCH: 'mismatch',
@@ -244,14 +244,8 @@
 
 export type ChangeViewPatchRange = Partial<PatchRange>;
 
-const DEBOUNCER_REPLY_OVERLAY_REFIT = 'reply-overlay-refit';
-
-const DEBOUNCER_SCROLL = 'scroll';
-
 @customElement('gr-change-view')
-export class GrChangeView extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrChangeView extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -459,9 +453,6 @@
   @property({type: Boolean})
   _replyDisabled = true;
 
-  @property({type: String, computed: '_changeStatusString(_change)'})
-  _changeStatus?: string;
-
   @property({
     type: String,
     computed: '_computeChangeStatusChips(_change, _mergeable, _submitEnabled)',
@@ -593,6 +584,10 @@
 
   disconnected$ = new Subject();
 
+  private replyRefitTask?: DelayedTask;
+
+  private scrollTask?: DelayedTask;
+
   /** @override */
   ready() {
     super.ready();
@@ -604,26 +599,9 @@
     );
   }
 
-  /** @override */
-  connectedCallback() {
-    super.connectedCallback();
-    this._throttledToggleChangeStar = this._throttleWrap(e =>
-      this._handleToggleChangeStar(e as CustomKeyboardEvent)
-    );
-  }
-
-  /** @override */
-  disconnectedCallback() {
-    this.disconnected$.next();
-    super.disconnectedCallback();
-  }
-
-  /** @override */
-  created() {
-    super.created();
-
+  constructor() {
+    super();
     this.addEventListener('topic-changed', () => this._handleTopicChanged());
-
     this.addEventListener(
       // When an overlay is opened in a mobile viewport, the overlay has a full
       // screen view. When it has a full screen view, we do not want the
@@ -651,8 +629,11 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
+    this._throttledToggleChangeStar = this._throttleWrap(e =>
+      this._handleToggleChangeStar(e as CustomKeyboardEvent)
+    );
     this._getServerConfig().then(config => {
       this._serverConfig = config;
       this._replyDisabled = false;
@@ -700,8 +681,8 @@
     );
     this.addEventListener('open-fix-preview', e => this._onOpenFixPreview(e));
     this.addEventListener('close-fix-preview', () => this._onCloseFixPreview());
-    this.listen(window, 'scroll', '_handleScroll');
-    this.listen(document, 'visibilitychange', '_handleVisibilityChange');
+    window.addEventListener('scroll', this.handleScroll);
+    document.addEventListener('visibilitychange', this.handleVisibilityChange);
 
     this.addEventListener(EventType.SHOW_PRIMARY_TAB, e =>
       this._setActivePrimaryTab(e)
@@ -719,16 +700,20 @@
   }
 
   /** @override */
-  detached() {
-    super.detached();
-    this.unlisten(window, 'scroll', '_handleScroll');
-    this.unlisten(document, 'visibilitychange', '_handleVisibilityChange');
-    this.cancelDebouncer(DEBOUNCER_REPLY_OVERLAY_REFIT);
-    this.cancelDebouncer(DEBOUNCER_SCROLL);
+  disconnectedCallback() {
+    this.disconnected$.next();
+    window.removeEventListener('scroll', this.handleScroll);
+    document.removeEventListener(
+      'visibilitychange',
+      this.handleVisibilityChange
+    );
+    this.replyRefitTask?.cancel();
+    this.scrollTask?.cancel();
 
     if (this._updateCheckTimerHandle) {
       this._cancelUpdateCheckTimer();
     }
+    super.disconnectedCallback();
   }
 
   get messagesList(): GrMessagesList | null {
@@ -739,10 +724,6 @@
     return this.shadowRoot!.querySelector<GrThreadList>('gr-thread-list');
   }
 
-  _changeStatusString(change: ChangeInfo) {
-    return changeStatusString(change);
-  }
-
   _setDiffViewMode(opt_reset?: boolean) {
     if (!opt_reset && this.viewState.diffViewMode) {
       return;
@@ -1248,11 +1229,9 @@
 
   _handleReplyAutogrow() {
     // If the textarea resizes, we need to re-fit the overlay.
-    this.debounce(
-      DEBOUNCER_REPLY_OVERLAY_REFIT,
-      () => {
-        this.$.replyOverlay.refit();
-      },
+    this.replyRefitTask = debounce(
+      this.replyRefitTask,
+      () => this.$.replyOverlay.refit(),
       REPLY_REFIT_DEBOUNCE_INTERVAL_MS
     );
   }
@@ -1265,15 +1244,13 @@
     this._openReplyDialog(target);
   }
 
-  _handleScroll() {
-    this.debounce(
-      DEBOUNCER_SCROLL,
-      () => {
-        this.viewState.scrollTop = document.body.scrollTop;
-      },
+  readonly handleScroll = () => {
+    this.scrollTask = debounce(
+      this.scrollTask,
+      () => (this.viewState.scrollTop = document.body.scrollTop),
       150
     );
-  }
+  };
 
   _setShownFiles(e: CustomEvent<{length: number}>) {
     this._shownFileCount = e.detail.length;
@@ -1386,7 +1363,7 @@
 
     this._sendShowChangeEvent();
 
-    this.async(() => {
+    setTimeout(() => {
       if (this.viewState.scrollTop) {
         document.documentElement.scrollTop = document.body.scrollTop = this.viewState.scrollTop;
       } else {
@@ -1498,10 +1475,10 @@
       if (this.viewState.showReplyDialog) {
         this._openReplyDialog(this.$.replyDialog.FocusTarget.ANY);
         // TODO(kaspern@): Find a better signal for when to call center.
-        this.async(() => {
+        setTimeout(() => {
           this.$.replyOverlay.center();
         }, 100);
-        this.async(() => {
+        setTimeout(() => {
           this.$.replyOverlay.center();
         }, 1000);
         this.set('viewState.showReplyDialog', false);
@@ -1586,8 +1563,15 @@
     return GerritNav.getUrlForChange(change);
   }
 
-  _computeShowCommitInfo(changeStatus: string, current_revision: RevisionInfo) {
-    return changeStatus === 'Merged' && current_revision;
+  _computeShowCommitInfo(
+    changeStatuses: string[],
+    current_revision: RevisionInfo
+  ) {
+    return (
+      changeStatuses.length === 1 &&
+      changeStatuses[0] === 'Merged' &&
+      current_revision
+    );
   }
 
   _computeMergedCommitInfo(
@@ -2466,7 +2450,7 @@
       return false;
     }
     const MIN_LINES = this._isNewChangeSummaryUiEnabled
-      ? 15
+      ? 17
       : MIN_LINES_FOR_COMMIT_COLLAPSE;
     return commitMessage.split('\n').length >= MIN_LINES;
   }
@@ -2599,7 +2583,7 @@
       return;
     }
 
-    this._updateCheckTimerHandle = this.async(() => {
+    this._updateCheckTimerHandle = window.setTimeout(() => {
       assertIsDefined(this._change, '_change');
       const change = this._change;
       fetchChangeUpdates(change, this.restApiService).then(result => {
@@ -2655,18 +2639,18 @@
 
   _cancelUpdateCheckTimer() {
     if (this._updateCheckTimerHandle) {
-      this.cancelAsync(this._updateCheckTimerHandle);
+      window.clearTimeout(this._updateCheckTimerHandle);
     }
     this._updateCheckTimerHandle = null;
   }
 
-  _handleVisibilityChange() {
+  private readonly handleVisibilityChange = () => {
     if (document.hidden && this._updateCheckTimerHandle) {
       this._cancelUpdateCheckTimer();
     } else if (!this._updateCheckTimerHandle) {
       this._startUpdateCheckTimer();
     }
-  }
+  };
 
   _handleTopicChanged() {
     this.getRelatedChangesList()?.reload();
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
index feb61cf..993970a 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
@@ -376,7 +376,7 @@
           <div class="statusText">
             <template
               is="dom-if"
-              if="[[_computeShowCommitInfo(_changeStatus, _change.current_revision)]]"
+              if="[[_computeShowCommitInfo(_changeStatuses, _change.current_revision)]]"
             >
               <span class="text"> as </span>
               <gr-commit-info
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
index 058c241..927d391 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
@@ -79,6 +79,7 @@
   PatchRange,
   PatchSetNum,
   RevisionInfo,
+  RevisionPatchSetNum,
   RobotId,
   Timestamp,
   UrlEncodedCommentId,
@@ -98,7 +99,6 @@
   UIDraft,
   UIRobot,
 } from '../../../utils/comment-util';
-import 'lodash/lodash';
 import {ChangeComments} from '../../diff/gr-comment-api/gr-comment-api';
 import {GerritView} from '../../../services/router/router-model';
 import {ParsedChangeInfo} from '../../../types/types';
@@ -183,7 +183,7 @@
           patch_set: 2 as PatchSetNum,
         },
       ],
-      patchNum: 4 as PatchSetNum,
+      patchNum: 4 as RevisionPatchSetNum,
       path: '/COMMIT_MSG',
       line: 5,
       rootId: 'ecf0b9fa_fe1a5f62' as UrlEncodedCommentId,
@@ -243,7 +243,7 @@
           unresolved: true,
         },
       ],
-      patchNum: 2 as PatchSetNum,
+      patchNum: 2 as RevisionPatchSetNum,
       path: '/COMMIT_MSG',
       line: 4,
       rootId: '8caddf38_44770ec1' as UrlEncodedCommentId,
@@ -266,7 +266,7 @@
           unresolved: true,
         },
       ],
-      patchNum: 2 as PatchSetNum,
+      patchNum: 2 as RevisionPatchSetNum,
       path: '/COMMIT_MSG',
       line: 4,
       rootId: 'scaddf38_44770ec1' as UrlEncodedCommentId,
@@ -287,7 +287,7 @@
           patch_set: 2 as PatchSetNum,
         },
       ],
-      patchNum: 4 as PatchSetNum,
+      patchNum: 4 as RevisionPatchSetNum,
       path: '/COMMIT_MSG',
       line: 6,
       rootId: 'zcf0b9fa_fe1a5f62' as UrlEncodedCommentId,
@@ -311,7 +311,7 @@
           robot_id: 'rc1' as RobotId,
         },
       ],
-      patchNum: 4 as PatchSetNum,
+      patchNum: 4 as RevisionPatchSetNum,
       path: '/COMMIT_MSG',
       line: 5,
       rootId: 'rc1' as UrlEncodedCommentId,
@@ -349,7 +349,7 @@
           unresolved: true,
         },
       ],
-      patchNum: 4 as PatchSetNum,
+      patchNum: 4 as RevisionPatchSetNum,
       path: '/COMMIT_MSG',
       line: 5,
       rootId: 'rc2' as UrlEncodedCommentId,
@@ -391,7 +391,7 @@
         );
       },
       '0.1',
-      'http://some/plugins/url.html'
+      'http://some/plugins/url.js'
     );
   });
 
@@ -408,7 +408,7 @@
     element._changeNum = 1 as NumericChangeId;
     element._patchRange = {
       basePatchNum: ParentPatchSetNum,
-      patchNum: 1 as PatchSetNum,
+      patchNum: 1 as RevisionPatchSetNum,
     };
     element._change = createChange();
     const getUrlStub = sinon.stub(GerritNav, 'getUrlForChange');
@@ -427,7 +427,7 @@
       revisions: createRevisions(10),
     };
     element._patchRange = {
-      patchNum: 3 as PatchSetNum,
+      patchNum: 3 as RevisionPatchSetNum,
       basePatchNum: 1 as BasePatchSetNum,
     };
     sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
@@ -445,7 +445,7 @@
     };
     element._patchRange = {
       basePatchNum: 1 as BasePatchSetNum,
-      patchNum: 3 as PatchSetNum,
+      patchNum: 3 as RevisionPatchSetNum,
     };
     sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
     element._handleDiffAgainstLatest(
@@ -464,7 +464,7 @@
       revisions: createRevisions(10),
     };
     element._patchRange = {
-      patchNum: 3 as PatchSetNum,
+      patchNum: 3 as RevisionPatchSetNum,
       basePatchNum: 1 as BasePatchSetNum,
     };
     sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
@@ -484,7 +484,7 @@
     };
     element._patchRange = {
       basePatchNum: 1 as BasePatchSetNum,
-      patchNum: 3 as PatchSetNum,
+      patchNum: 3 as RevisionPatchSetNum,
     };
     sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
     element._handleDiffRightAgainstLatest(
@@ -503,7 +503,7 @@
     };
     element._patchRange = {
       basePatchNum: 1 as BasePatchSetNum,
-      patchNum: 3 as PatchSetNum,
+      patchNum: 3 as RevisionPatchSetNum,
     };
     sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
     element._handleDiffBaseAgainstLatest(
@@ -834,7 +834,7 @@
       element._changeNum = TEST_NUMERIC_CHANGE_ID;
       element._patchRange = {
         basePatchNum: ParentPatchSetNum,
-        patchNum: 1 as PatchSetNum,
+        patchNum: 1 as RevisionPatchSetNum,
       };
       element._change = {
         ...createChange(),
@@ -1077,7 +1077,7 @@
       element._changeNum = TEST_NUMERIC_CHANGE_ID;
       element._patchRange = {
         basePatchNum: ParentPatchSetNum,
-        patchNum: 1 as PatchSetNum,
+        patchNum: 1 as RevisionPatchSetNum,
       };
       element._change = {
         ...createChange(),
@@ -1258,7 +1258,6 @@
     element._mergeable = true;
     const expectedStatuses = ['Merged', 'WIP'];
     assert.deepEqual(element._changeStatuses, expectedStatuses);
-    assert.equal(element._changeStatus, expectedStatuses.join(', '));
     flush();
     const statusChips = element.shadowRoot!.querySelectorAll(
       'gr-change-status'
@@ -1307,7 +1306,7 @@
     element._changeNum = TEST_NUMERIC_CHANGE_ID;
     element._patchRange = {
       basePatchNum: ParentPatchSetNum,
-      patchNum: 1 as PatchSetNum,
+      patchNum: 1 as RevisionPatchSetNum,
     };
     const change = {
       ...createChange(),
@@ -1369,7 +1368,7 @@
   test('comment events properly update diff drafts', () => {
     element._patchRange = {
       basePatchNum: ParentPatchSetNum,
-      patchNum: 2 as PatchSetNum,
+      patchNum: 2 as RevisionPatchSetNum,
     };
     const draft: DraftInfo = {
       __draft: true,
@@ -1417,7 +1416,7 @@
     element._changeNum = undefined;
     element._patchRange = {
       basePatchNum: ParentPatchSetNum,
-      patchNum: 2 as PatchSetNum,
+      patchNum: 2 as RevisionPatchSetNum,
     };
     element._change = change;
     element.viewState.changeNum = null;
@@ -1519,7 +1518,7 @@
     const value: AppElementChangeViewParams = {
       ...createAppElementChangeViewParams(),
       view: GerritView.CHANGE,
-      patchNum: 1 as PatchSetNum,
+      patchNum: 1 as RevisionPatchSetNum,
     };
     element._paramsChanged(value);
     assert.isTrue(reloadStub.calledOnce);
@@ -1528,7 +1527,7 @@
     element._initialLoadComplete = true;
 
     value.basePatchNum = 1 as BasePatchSetNum;
-    value.patchNum = 2 as PatchSetNum;
+    value.patchNum = 2 as RevisionPatchSetNum;
     element._paramsChanged(value);
     assert.isFalse(reloadStub.calledTwice);
     assert.isTrue(reloadPatchDependentStub.calledOnce);
@@ -1554,14 +1553,14 @@
     const value: AppElementChangeViewParams = {
       ...createAppElementChangeViewParams(),
       view: GerritView.CHANGE,
-      patchNum: 1 as PatchSetNum,
+      patchNum: 1 as RevisionPatchSetNum,
     };
     element._paramsChanged(value);
 
     element._initialLoadComplete = true;
 
     value.basePatchNum = 1 as BasePatchSetNum;
-    value.patchNum = 2 as PatchSetNum;
+    value.patchNum = 2 as RevisionPatchSetNum;
     element._paramsChanged(value);
     assert.isTrue(reloadPortedCommentsStub.calledOnce);
   });
@@ -1901,7 +1900,7 @@
     };
     assert.equal(element._getBasePatchNum(_change2, _patchRange), -1);
 
-    _patchRange.patchNum = 1 as PatchSetNum;
+    _patchRange.patchNum = 1 as RevisionPatchSetNum;
     assert.equal(element._getBasePatchNum(_change2, _patchRange), 'PARENT');
   });
 
@@ -1990,7 +1989,7 @@
 
     element._patchRange = {
       basePatchNum: ParentPatchSetNum,
-      patchNum: 2 as PatchSetNum,
+      patchNum: 2 as RevisionPatchSetNum,
     };
     element._change = {
       ...createChange(),
@@ -2018,14 +2017,14 @@
   suite('scroll related tests', () => {
     test('document scrolling calls function to set scroll height', done => {
       const originalHeight = document.body.scrollHeight;
-      const scrollStub = sinon.stub(element, '_handleScroll').callsFake(() => {
+      const scrollStub = sinon.stub(element, 'handleScroll').callsFake(() => {
         assert.isTrue(scrollStub.called);
         document.body.style.height = `${originalHeight}px`;
         scrollStub.restore();
         done();
       });
       document.body.style.height = '10000px';
-      element._handleScroll();
+      element.handleScroll();
     });
 
     test('scrollTop is set correctly', () => {
@@ -2326,18 +2325,11 @@
     });
 
     suite('update checks', () => {
+      let clock: SinonFakeTimers;
       let startUpdateCheckTimerSpy: SinonSpyMember<typeof element._startUpdateCheckTimer>;
-      let asyncStub: SinonStubbedMember<typeof element.async>;
       setup(() => {
+        clock = sinon.useFakeTimers();
         startUpdateCheckTimerSpy = sinon.spy(element, '_startUpdateCheckTimer');
-        asyncStub = sinon.stub(element, 'async').callsFake(f => {
-          // Only fire the async callback one time.
-          if (asyncStub.callCount > 1) {
-            return 1;
-          }
-          f.call(element);
-          return 1;
-        });
         element._change = {
           ...createChange(),
           revisions: createRevisions(1),
@@ -2381,14 +2373,14 @@
           ...createServerInfo(),
           change: {...createChangeConfig(), update_delay: 12345},
         };
+        clock.tick(12345 * 1000);
         await flush();
 
         assert.equal(startUpdateCheckTimerSpy.callCount, 2);
         assert.isTrue(getChangeDetailStub.called);
-        assert.equal(asyncStub.lastCall.args[1], 12345 * 1000);
       });
 
-      test('_startUpdateCheckTimer out-of-date shows an alert', done => {
+      test('_startUpdateCheckTimer out-of-date shows an alert', async () => {
         stubRestApi('getChangeDetail').callsFake(() =>
           Promise.resolve({
             ...createChange(),
@@ -2399,15 +2391,18 @@
           })
         );
 
+        let alertMessage = 'alert not fired';
         element.addEventListener('show-alert', e => {
-          assert.equal(e.detail.message, 'A newer patch set has been uploaded');
-          done();
+          alertMessage = e.detail.message;
         });
         element._serverConfig = {
           ...createServerInfo(),
           change: {...createChangeConfig(), update_delay: 12345},
         };
+        clock.tick(12345 * 1000);
+        await flush();
 
+        assert.equal(alertMessage, 'A newer patch set has been uploaded');
         assert.equal(startUpdateCheckTimerSpy.callCount, 1);
       });
 
@@ -2427,13 +2422,14 @@
           ...createServerInfo(),
           change: {...createChangeConfig(), update_delay: 12345},
         };
+        clock.tick(12345 * 1000 * 2);
         await flush();
 
         // No toast, instead a second call to _startUpdateCheckTimer().
         assert.equal(startUpdateCheckTimerSpy.callCount, 2);
       });
 
-      test('_startUpdateCheckTimer new status shows an alert', done => {
+      test('_startUpdateCheckTimer new status shows an alert', async () => {
         stubRestApi('getChangeDetail').callsFake(() =>
           Promise.resolve({
             ...createChange(),
@@ -2445,17 +2441,21 @@
           })
         );
 
+        let alertMessage = 'alert not fired';
         element.addEventListener('show-alert', e => {
-          assert.equal(e.detail.message, 'This change has been merged');
-          done();
+          alertMessage = e.detail.message;
         });
         element._serverConfig = {
           ...createServerInfo(),
           change: {...createChangeConfig(), update_delay: 12345},
         };
+        clock.tick(12345 * 1000);
+        await flush();
+
+        assert.equal(alertMessage, 'This change has been merged');
       });
 
-      test('_startUpdateCheckTimer new messages shows an alert', done => {
+      test('_startUpdateCheckTimer new messages shows an alert', async () => {
         stubRestApi('getChangeDetail').callsFake(() =>
           Promise.resolve({
             ...createChange(),
@@ -2465,17 +2465,19 @@
             current_revision: 'rev1' as CommitId,
           })
         );
+
+        let alertMessage = 'alert not fired';
         element.addEventListener('show-alert', e => {
-          assert.equal(
-            e.detail.message,
-            'There are new messages on this change'
-          );
-          done();
+          alertMessage = e.detail.message;
         });
         element._serverConfig = {
           ...createServerInfo(),
           change: {...createChangeConfig(), update_delay: 12345},
         };
+        clock.tick(12345 * 1000);
+        await flush();
+
+        assert.equal(alertMessage, 'There are new messages on this change');
       });
     });
 
@@ -2544,13 +2546,13 @@
       );
     assert.isTrue(
       callCompute(
-        {basePatchNum: ParentPatchSetNum, patchNum: 1 as PatchSetNum},
+        {basePatchNum: ParentPatchSetNum, patchNum: 1 as RevisionPatchSetNum},
         {...createAppElementChangeViewParams(), edit: true}
       )
     );
     assert.isFalse(
       callCompute(
-        {basePatchNum: ParentPatchSetNum, patchNum: 1 as PatchSetNum},
+        {basePatchNum: ParentPatchSetNum, patchNum: 1 as RevisionPatchSetNum},
         createAppElementChangeViewParams()
       )
     );
@@ -2607,17 +2609,17 @@
     );
 
     // If _patchRange.patchNum is defined, do not load edit.
-    element._patchRange.patchNum = 5 as PatchSetNum;
+    element._patchRange.patchNum = 5 as RevisionPatchSetNum;
     change.current_revision = 'baz' as CommitId;
     element._processEdit((mockChange = _.cloneDeep(change)), edit);
-    assert.equal(element._patchRange.patchNum, 5 as PatchSetNum);
+    assert.equal(element._patchRange.patchNum, 5 as RevisionPatchSetNum);
     assert.notOk(mockChange.revisions.bar.actions);
   });
 
   test('file-action-tap handling', () => {
     element._patchRange = {
       basePatchNum: ParentPatchSetNum,
-      patchNum: 1 as PatchSetNum,
+      patchNum: 1 as RevisionPatchSetNum,
     };
     element._change = {
       ...createChange(),
@@ -2712,7 +2714,7 @@
     sinon
       .stub(element, '_getPreferences')
       .returns(Promise.resolve(createPreferences()));
-    element._patchRange = {patchNum: 2 as PatchSetNum};
+    element._patchRange = {patchNum: 2 as RevisionPatchSetNum};
     return element._getChangeDetail().then(() => {
       assert.strictEqual(element._selectedRevision, revision2);
 
@@ -2751,7 +2753,7 @@
   test('_sendShowChangeEvent', () => {
     const change = {...createChange(), labels: {}};
     element._change = {...change};
-    element._patchRange = {patchNum: 4 as PatchSetNum};
+    element._patchRange = {patchNum: 4 as RevisionPatchSetNum};
     element._mergeable = true;
     const showStub = sinon.stub(appContext.jsApiService, 'handleEvent');
     element._sendShowChangeEvent();
@@ -2803,7 +2805,7 @@
       });
 
       element.set('_change.revisions.rev2', {_number: 2});
-      element._patchRange = {patchNum: 1 as PatchSetNum};
+      element._patchRange = {patchNum: 1 as RevisionPatchSetNum};
       flush();
 
       fireEdit();
@@ -2819,7 +2821,7 @@
       });
 
       element.set('_change.revisions.rev2', {_number: 2});
-      element._patchRange = {patchNum: 2 as PatchSetNum};
+      element._patchRange = {patchNum: 2 as RevisionPatchSetNum};
       flush();
 
       fireEdit();
@@ -2838,7 +2840,7 @@
       done();
     });
 
-    element._patchRange = {patchNum: 1 as PatchSetNum};
+    element._patchRange = {patchNum: 1 as RevisionPatchSetNum};
     element.$.actions.dispatchEvent(
       new CustomEvent('stop-edit-tap', {bubbles: false})
     );
@@ -2859,7 +2861,7 @@
             .then(el => (hookEl = el));
         },
         '0.1',
-        'http://some/plugins/url.html'
+        'http://some/plugins/url.js'
       );
       flush(() => {
         assert.strictEqual((hookEl as any).plugin, plugin);
@@ -2941,7 +2943,7 @@
     setup(() => {
       element._patchRange = {
         basePatchNum: ParentPatchSetNum,
-        patchNum: 1 as PatchSetNum,
+        patchNum: 1 as RevisionPatchSetNum,
       };
       sinon.stub(element, '_getChangeDetail').returns(Promise.resolve(false));
       sinon.stub(element, '_getProjectConfig').returns(Promise.resolve());
diff --git a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
index 0b148b7..3ba12b43 100644
--- a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
+++ b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
@@ -16,7 +16,6 @@
  */
 import '../../../styles/shared-styles';
 import '../../shared/gr-copy-clipboard/gr-copy-clipboard';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-commit-info_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -30,7 +29,7 @@
 }
 
 @customElement('gr-commit-info')
-export class GrCommitInfo extends LegacyElementMixin(PolymerElement) {
+export class GrCommitInfo extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts
index df99471..0954b7f 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts
@@ -17,7 +17,6 @@
 import '@polymer/iron-autogrow-textarea/iron-autogrow-textarea';
 import '../../shared/gr-dialog/gr-dialog';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-abandon-dialog_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -36,12 +35,9 @@
   }
 }
 
-/**
- * @extends PolymerElement
- */
 @customElement('gr-confirm-abandon-dialog')
 export class GrConfirmAbandonDialog extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
+  PolymerElement
 ) {
   static get template() {
     return htmlTemplate;
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.ts
index 5aa5e8b..75b6053 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.ts
@@ -16,7 +16,6 @@
  */
 import '../../../styles/shared-styles';
 import '../../shared/gr-dialog/gr-dialog';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-cherrypick-conflict-dialog_html';
 import {customElement} from '@polymer/decorators';
@@ -28,9 +27,7 @@
 }
 
 @customElement('gr-confirm-cherrypick-conflict-dialog')
-export class GrConfirmCherrypickConflictDialog extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrConfirmCherrypickConflictDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts
index 3475e45..af565cb 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts
@@ -19,7 +19,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-autocomplete/gr-autocomplete';
 import '../../shared/gr-dialog/gr-dialog';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-cherrypick-dialog_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -74,9 +73,7 @@
 }
 
 @customElement('gr-confirm-cherrypick-dialog')
-export class GrConfirmCherrypickDialog extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrConfirmCherrypickDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
index 9da7ea2..ce5b246 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
@@ -17,7 +17,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-autocomplete/gr-autocomplete';
 import '../../shared/gr-dialog/gr-dialog';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-move-dialog_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -29,9 +28,7 @@
 const SUGGESTIONS_LIMIT = 15;
 
 @customElement('gr-confirm-move-dialog')
-export class GrConfirmMoveDialog extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrConfirmMoveDialog extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.ts
index aa8745a..4e6c963 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.ts
@@ -17,7 +17,6 @@
 import '../../shared/gr-autocomplete/gr-autocomplete';
 import '../../shared/gr-dialog/gr-dialog';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-rebase-dialog_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -48,7 +47,7 @@
 }
 
 @customElement('gr-confirm-rebase-dialog')
-export class GrConfirmRebaseDialog extends LegacyElementMixin(PolymerElement) {
+export class GrConfirmRebaseDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.ts
index a785afd..450551b 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.ts
@@ -17,7 +17,6 @@
 import '../../shared/gr-dialog/gr-dialog';
 import '../../../styles/shared-styles';
 import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-revert-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -40,7 +39,7 @@
 }
 
 @customElement('gr-confirm-revert-dialog')
-export class GrConfirmRevertDialog extends LegacyElementMixin(PolymerElement) {
+export class GrConfirmRevertDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.ts
index 609947d..bd268fd 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.ts
@@ -16,7 +16,6 @@
  */
 import '../../shared/gr-dialog/gr-dialog';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-revert-submission-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -28,9 +27,7 @@
 const CHANGE_SUBJECT_LIMIT = 50;
 
 @customElement('gr-confirm-revert-submission-dialog')
-export class GrConfirmRevertSubmissionDialog extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrConfirmRevertSubmissionDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts
index 7130907..33f7304 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts
@@ -21,7 +21,6 @@
 import '../../plugins/gr-endpoint-param/gr-endpoint-param';
 import '../../../styles/shared-styles';
 import '../gr-thread-list/gr-thread-list';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-submit-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -36,7 +35,7 @@
   };
 }
 @customElement('gr-confirm-submit-dialog')
-export class GrConfirmSubmitDialog extends LegacyElementMixin(PolymerElement) {
+export class GrConfirmSubmitDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog_test.js b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog_test.js
deleted file mode 100644
index e175fda..0000000
--- a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog_test.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @license
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import './gr-confirm-submit-dialog.js';
-
-const basicFixture = fixtureFromElement('gr-confirm-submit-dialog');
-
-suite('gr-file-list-header tests', () => {
-  let element;
-
-  setup(() => {
-    element = basicFixture.instantiate();
-    element._initialised = true;
-  });
-
-  test('display', () => {
-    element.action = {label: 'my-label'};
-    element.change = {
-      subject: 'my-subject',
-      revisions: {},
-    };
-    flush();
-    const header = element.shadowRoot
-        .querySelector('.header');
-    assert.equal(header.textContent.trim(), 'my-label');
-
-    const message = element.shadowRoot
-        .querySelector('.main p');
-    assert.notEqual(message.textContent.length, 0);
-    assert.notEqual(message.textContent.indexOf('my-subject'), -1);
-  });
-
-  test('_computeUnresolvedCommentsWarning', () => {
-    const change = {unresolved_comment_count: 1};
-    assert.equal(element._computeUnresolvedCommentsWarning(change),
-        'Heads Up! 1 unresolved comment.');
-
-    const change2 = {unresolved_comment_count: 2};
-    assert.equal(element._computeUnresolvedCommentsWarning(change2),
-        'Heads Up! 2 unresolved comments.');
-  });
-
-  test('_computeHasChangeEdit', () => {
-    const change = {
-      revisions: {
-        d442ff05d6c4f2a3af0eeca1f67374b39f9dc3d8: {
-          _number: 'edit',
-        },
-      },
-      unresolved_comment_count: 0,
-    };
-
-    assert.equal(element._computeHasChangeEdit(change), true);
-
-    const change2 = {
-      revisions: {
-        d442ff05d6c4f2a3af0eeca1f67374b39f9dc3d8: {
-          _number: 2,
-        },
-      },
-    };
-    assert.equal(element._computeHasChangeEdit(change2), false);
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog_test.ts b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog_test.ts
new file mode 100644
index 0000000..e9f3019
--- /dev/null
+++ b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog_test.ts
@@ -0,0 +1,89 @@
+/**
+ * @license
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import '../../../test/common-test-setup-karma';
+import {createChange, createRevision} from '../../../test/test-data-generators';
+import {queryAndAssert} from '../../../test/test-utils';
+import {PatchSetNum} from '../../../types/common';
+import {GrConfirmSubmitDialog} from './gr-confirm-submit-dialog';
+
+const basicFixture = fixtureFromElement('gr-confirm-submit-dialog');
+
+suite('gr-confirm-submit-dialog tests', () => {
+  let element: GrConfirmSubmitDialog;
+
+  setup(() => {
+    element = basicFixture.instantiate();
+    element._initialised = true;
+  });
+
+  test('display', () => {
+    element.action = {label: 'my-label'};
+    element.change = {
+      ...createChange(),
+      subject: 'my-subject',
+      revisions: {},
+    };
+    flush();
+    const header = queryAndAssert(element, '.header');
+    assert.equal(header.textContent!.trim(), 'my-label');
+
+    const message = queryAndAssert(element, '.main p');
+    assert.isNotEmpty(message.textContent);
+    assert.notEqual(message.textContent!.indexOf('my-subject'), -1);
+  });
+
+  test('_computeUnresolvedCommentsWarning', () => {
+    const change = {...createChange(), unresolved_comment_count: 1};
+    assert.equal(
+      element._computeUnresolvedCommentsWarning(change),
+      'Heads Up! 1 unresolved comment.'
+    );
+
+    const change2 = {...createChange(), unresolved_comment_count: 2};
+    assert.equal(
+      element._computeUnresolvedCommentsWarning(change2),
+      'Heads Up! 2 unresolved comments.'
+    );
+  });
+
+  test('_computeHasChangeEdit', () => {
+    const change = {
+      ...createChange(),
+      revisions: {
+        d442ff05d6c4f2a3af0eeca1f67374b39f9dc3d8: {
+          ...createRevision(),
+          _number: 'edit' as PatchSetNum,
+        },
+      },
+      unresolved_comment_count: 0,
+    };
+
+    assert.isTrue(element._computeHasChangeEdit(change));
+
+    const change2 = {
+      ...createChange(),
+      revisions: {
+        d442ff05d6c4f2a3af0eeca1f67374b39f9dc3d8: {
+          ...createRevision(),
+          _number: 2 as PatchSetNum,
+        },
+      },
+    };
+    assert.isFalse(element._computeHasChangeEdit(change2));
+  });
+});
diff --git a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts
index 0aae46c..fe1b618 100644
--- a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.ts
@@ -16,7 +16,6 @@
  */
 import '../../../styles/shared-styles';
 import '../../shared/gr-download-commands/gr-download-commands';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-download-dialog_html';
 import {changeBaseURL, getRevisionKey} from '../../../utils/change-util';
@@ -37,7 +36,7 @@
 }
 
 @customElement('gr-download-dialog')
-export class GrDownloadDialog extends LegacyElementMixin(PolymerElement) {
+export class GrDownloadDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
index 6726055..a0bea33 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
@@ -25,7 +25,6 @@
 import '../../shared/gr-icons/gr-icons';
 import '../gr-commit-info/gr-commit-info';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-file-list-header_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -74,9 +73,7 @@
 }
 
 @customElement('gr-file-list-header')
-export class GrFileListHeader extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrFileListHeader extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
index bd49b0c..02443bb 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
@@ -28,10 +28,9 @@
 import '../../shared/gr-copy-clipboard/gr-copy-clipboard';
 import '../../shared/gr-file-status-chip/gr-file-status-chip';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-file-list_html';
-import {asyncForeach} from '../../../utils/async-util';
+import {asyncForeach, debounce, DelayedTask} from '../../../utils/async-util';
 import {
   KeyboardShortcutMixin,
   Modifier,
@@ -43,8 +42,12 @@
 import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
 import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader';
 import {appContext} from '../../../services/app-context';
-import {DiffViewMode, SpecialFilePath} from '../../../constants/constants';
-import {descendedFromClass} from '../../../utils/dom-util';
+import {
+  DiffViewMode,
+  ScrollMode,
+  SpecialFilePath,
+} from '../../../constants/constants';
+import {descendedFromClass, toggleClass} from '../../../utils/dom-util';
 import {
   addUnmodifiedFiles,
   computeDisplayPath,
@@ -93,7 +96,6 @@
   $: {
     diffPreferencesDialog: GrDiffPreferencesDialog;
     diffCursor: GrDiffCursor;
-    fileCursor: GrCursorManager;
   };
 }
 
@@ -151,8 +153,6 @@
 
 export type FileNameToReviewedFileInfoMap = {[name: string]: ReviewedFileInfo};
 
-const DEBOUNCER_LOADING_CHANGE = 'loading-change';
-
 /**
  * Type for FileInfo
  *
@@ -169,9 +169,7 @@
  */
 
 @customElement('gr-file-list')
-export class GrFileList extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrFileList extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -280,6 +278,8 @@
 
   private _cancelForEachDiff?: () => void;
 
+  loadingTask?: DelayedTask;
+
   @property({
     type: Boolean,
     computed:
@@ -348,15 +348,18 @@
     };
   }
 
-  /** @override */
-  created() {
-    super.created();
+  private fileCursor = new GrCursorManager();
+
+  constructor() {
+    super();
+    this.fileCursor.scrollMode = ScrollMode.KEEP_VISIBLE;
+    this.fileCursor.cursorTargetClass = 'selected';
     this.addEventListener('keydown', e => this._scopedKeydownHandler(e));
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     getPluginLoader()
       .awaitPluginsLoaded()
       .then(() => {
@@ -404,10 +407,11 @@
   }
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
+    this.fileCursor.unsetCursor();
     this._cancelDiffs();
-    this.cancelDebouncer(DEBOUNCER_LOADING_CHANGE);
+    this.loadingTask?.cancel();
+    super.disconnectedCallback();
   }
 
   /**
@@ -788,7 +792,7 @@
       e.preventDefault();
       // Prevent _handleFileListClick handler call
       e.stopPropagation();
-      this.$.fileCursor.setCursor(fileRow.element);
+      this.fileCursor.setCursor(fileRow.element);
       fileAction(fileRow.file);
     }
   }
@@ -828,7 +832,7 @@
     }
 
     e.preventDefault();
-    this.$.fileCursor.setCursor(fileRow.element);
+    this.fileCursor.setCursor(fileRow.element);
     this._toggleFileExpanded(file);
   }
 
@@ -885,13 +889,13 @@
     if (
       this.shouldSuppressKeyboardShortcut(e) ||
       this.modifierPressed(e) ||
-      this.$.fileCursor.index === -1
+      this.fileCursor.index === -1
     ) {
       return;
     }
 
     e.preventDefault();
-    this._toggleFileExpandedByIndex(this.$.fileCursor.index);
+    this._toggleFileExpandedByIndex(this.fileCursor.index);
   }
 
   _handleToggleAllInlineDiffs(e: CustomKeyboardEvent) {
@@ -909,7 +913,7 @@
     }
 
     e.preventDefault();
-    this.toggleClass('hideComments');
+    toggleClass(this, 'hideComments');
   }
 
   _handleCursorNext(e: CustomKeyboardEvent) {
@@ -927,8 +931,8 @@
         return;
       }
       e.preventDefault();
-      this.$.fileCursor.next();
-      this.selectedIndex = this.$.fileCursor.index;
+      this.fileCursor.next();
+      this.selectedIndex = this.fileCursor.index;
     }
   }
 
@@ -947,8 +951,8 @@
         return;
       }
       e.preventDefault();
-      this.$.fileCursor.previous();
-      this.selectedIndex = this.$.fileCursor.index;
+      this.fileCursor.previous();
+      this.selectedIndex = this.fileCursor.index;
     }
   }
 
@@ -1043,10 +1047,10 @@
     }
 
     e.preventDefault();
-    if (!this._files[this.$.fileCursor.index]) {
+    if (!this._files[this.fileCursor.index]) {
       return;
     }
-    this._reviewFile(this._files[this.$.fileCursor.index].__path);
+    this._reviewFile(this._files[this.fileCursor.index].__path);
   }
 
   _handleToggleLeftPane(e: CustomKeyboardEvent) {
@@ -1083,9 +1087,9 @@
 
   _openSelectedFile(index?: number) {
     if (index !== undefined) {
-      this.$.fileCursor.setCursorAtIndex(index);
+      this.fileCursor.setCursorAtIndex(index);
     }
-    if (!this._files[this.$.fileCursor.index]) {
+    if (!this._files[this.fileCursor.index]) {
       return;
     }
     if (!this.change || !this.patchRange) {
@@ -1093,7 +1097,7 @@
     }
     GerritNav.navigateToDiff(
       this.change,
-      this._files[this.$.fileCursor.index].__path,
+      this._files[this.fileCursor.index].__path,
       this.patchRange.patchNum,
       this.patchRange.basePatchNum
     );
@@ -1295,10 +1299,10 @@
   _filesChanged() {
     if (this._files && this._files.length > 0) {
       flush();
-      this.$.fileCursor.stops = Array.from(
+      this.fileCursor.stops = Array.from(
         this.root!.querySelectorAll(`.${FILE_ROW_CLASS}`)
       );
-      this.$.fileCursor.setCursorAtIndex(this.selectedIndex, true);
+      this.fileCursor.setCursorAtIndex(this.selectedIndex, true);
     }
   }
 
@@ -1594,8 +1598,8 @@
    * are reasonably fast.
    */
   _loadingChanged(loading?: boolean) {
-    this.debounce(
-      DEBOUNCER_LOADING_CHANGE,
+    this.loadingTask = debounce(
+      this.loadingTask,
       () => {
         // Only show set the loading if there have been files loaded to show. In
         // this way, the gray loading style is not shown on initial loads.
@@ -1777,7 +1781,7 @@
    */
   _reportRenderedRow(index: number) {
     if (index === this._shownFiles.length - 1) {
-      this.async(() => {
+      setTimeout(() => {
         this.reporting.timeEndWithAverage(
           RENDER_TIMING_LABEL,
           RENDER_AVG_TIMING_LABEL,
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
index 2078d1a..89983ad 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
@@ -737,10 +737,4 @@
   >
   </gr-diff-preferences-dialog>
   <gr-diff-cursor id="diffCursor"></gr-diff-cursor>
-  <gr-cursor-manager
-    id="fileCursor"
-    scroll-mode="keep-visible"
-    focus-on-move=""
-    cursor-target-class="selected"
-  ></gr-cursor-manager>
 `;
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
index 32b3035..b8ba86c 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
@@ -16,7 +16,6 @@
  */
 
 import '../../../test/common-test-setup-karma.js';
-import {listenOnce} from '../../../test/test-utils.js';
 import '../../diff/gr-comment-api/gr-comment-api.js';
 import {getMockDiffResponse} from '../../../test/mocks/diff-response.js';
 import './gr-file-list.js';
@@ -26,7 +25,7 @@
 import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
 import {runA11yAudit} from '../../../test/a11y-test-utils.js';
 import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-import {TestKeyboardShortcutBinder, stubRestApi, spyRestApi} from '../../../test/test-utils.js';
+import {TestKeyboardShortcutBinder, stubRestApi, spyRestApi, listenOnce} from '../../../test/test-utils.js';
 import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
 import {createCommentThreads} from '../../../utils/comment-util.js';
 import {createChangeComments} from '../../../test/test-data-generators.js';
@@ -85,13 +84,11 @@
       stubRestApi('getDiffRobotComments').returns(Promise.resolve({}));
       stubRestApi('getDiffDrafts').returns(Promise.resolve({}));
       stubRestApi('getAccountCapabilities').returns(Promise.resolve({}));
-      stub('gr-date-formatter', {
-        _loadTimeFormat() { return Promise.resolve(''); },
-      });
-      stub('gr-diff-host', {
-        reload() { return Promise.resolve(); },
-        prefetchDiff() {},
-      });
+      stub('gr-date-formatter', '_loadTimeFormat').callsFake(() =>
+        Promise.resolve('')
+      );
+      stub('gr-diff-host', 'reload').callsFake(() => Promise.resolve());
+      stub('gr-diff-host', 'prefetchDiff').callsFake(() => {});
 
       // Element must be wrapped in an element with direct access to the
       // comment API.
@@ -483,7 +480,7 @@
           patchNum: 2,
         };
         element.change = {_number: 42};
-        element.$.fileCursor.setCursorAtIndex(0);
+        element.fileCursor.setCursorAtIndex(0);
       });
 
       test('toggle left diff via shortcut', () => {
@@ -501,38 +498,38 @@
         flush();
 
         const items = [...element.root.querySelectorAll('.file-row')];
-        element.$.fileCursor.stops = items;
-        element.$.fileCursor.setCursorAtIndex(0);
+        element.fileCursor.stops = items;
+        element.fileCursor.setCursorAtIndex(0);
         assert.equal(items.length, 3);
         assert.isTrue(items[0].classList.contains('selected'));
         assert.isFalse(items[1].classList.contains('selected'));
         assert.isFalse(items[2].classList.contains('selected'));
         // j with a modifier should not move the cursor.
         MockInteractions.pressAndReleaseKeyOn(element, 74, 'shift', 'j');
-        assert.equal(element.$.fileCursor.index, 0);
+        assert.equal(element.fileCursor.index, 0);
         // down should not move the cursor.
         MockInteractions.pressAndReleaseKeyOn(element, 40, null, 'down');
-        assert.equal(element.$.fileCursor.index, 0);
+        assert.equal(element.fileCursor.index, 0);
 
         MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
-        assert.equal(element.$.fileCursor.index, 1);
+        assert.equal(element.fileCursor.index, 1);
         assert.equal(element.selectedIndex, 1);
         MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
 
         const navStub = sinon.stub(GerritNav, 'navigateToDiff');
-        assert.equal(element.$.fileCursor.index, 2);
+        assert.equal(element.fileCursor.index, 2);
         assert.equal(element.selectedIndex, 2);
 
         // k with a modifier should not move the cursor.
         MockInteractions.pressAndReleaseKeyOn(element, 75, 'shift', 'k');
-        assert.equal(element.$.fileCursor.index, 2);
+        assert.equal(element.fileCursor.index, 2);
 
         // up should not move the cursor.
         MockInteractions.pressAndReleaseKeyOn(element, 38, null, 'down');
-        assert.equal(element.$.fileCursor.index, 2);
+        assert.equal(element.fileCursor.index, 2);
 
         MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
-        assert.equal(element.$.fileCursor.index, 1);
+        assert.equal(element.fileCursor.index, 1);
         assert.equal(element.selectedIndex, 1);
         MockInteractions.pressAndReleaseKeyOn(element, 79, null, 'o');
 
@@ -543,7 +540,7 @@
         MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
         MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
         MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
-        assert.equal(element.$.fileCursor.index, 0);
+        assert.equal(element.fileCursor.index, 0);
         assert.equal(element.selectedIndex, 0);
 
         const createCommentInPlaceStub = sinon.stub(element.$.diffCursor,
@@ -557,8 +554,8 @@
         sinon.stub(element, '_expandedFilesChanged');
         flush();
         const files = [...element.root.querySelectorAll('.file-row')];
-        element.$.fileCursor.stops = files;
-        element.$.fileCursor.setCursorAtIndex(0);
+        element.fileCursor.stops = files;
+        element.fileCursor.setCursorAtIndex(0);
         assert.equal(element.diffs.length, 0);
         assert.equal(element._expandedFiles.length, 0);
 
@@ -574,7 +571,7 @@
         assert.equal(element.diffs.length, 0);
         assert.equal(element._expandedFiles.length, 0);
 
-        element.$.fileCursor.setCursorAtIndex(1);
+        element.fileCursor.setCursorAtIndex(1);
         MockInteractions.keyUpOn(element, 73, null, 'i');
         flush();
         assert.equal(element.diffs.length, 1);
@@ -701,7 +698,7 @@
         basePatchNum: 'PARENT',
         patchNum: 2,
       };
-      element.$.fileCursor.setCursorAtIndex(0);
+      element.fileCursor.setCursorAtIndex(0);
       const reviewSpy = sinon.spy(element, '_reviewFile');
       const toggleExpandSpy = sinon.spy(element, '_toggleFileExpanded');
 
@@ -807,7 +804,7 @@
         basePatchNum: 'PARENT',
         patchNum: 2,
       };
-      element.$.fileCursor.setCursorAtIndex(0);
+      element.fileCursor.setCursorAtIndex(0);
       sinon.stub(element, '_expandedFilesChanged');
       flush();
       const fileRows =
@@ -835,7 +832,7 @@
         patchNum: 2,
       };
       sinon.spy(element, '_updateDiffPreferences');
-      element.$.fileCursor.setCursorAtIndex(0);
+      element.fileCursor.setCursorAtIndex(0);
       flush();
 
       // Tap on a file to generate the diff.
@@ -1104,13 +1101,13 @@
 
       element.reload().then(() => {
         assert.isFalse(element._loading);
-        element.flushDebouncer('loading-change');
+        element.loadingTask.flush();
         assert.isFalse(element.classList.contains('loading'));
         done();
       });
       assert.isTrue(element._loading);
       assert.isFalse(element.classList.contains('loading'));
-      element.flushDebouncer('loading-change');
+      element.loadingTask.flush();
       assert.isTrue(element.classList.contains('loading'));
     });
 
@@ -1120,7 +1117,7 @@
       element.patchRange = {patchNum: 12};
       element.reload();
       assert.isTrue(element._loading);
-      element.flushDebouncer('loading-change');
+      element.loadingTask.flush();
       assert.isFalse(element.classList.contains('loading'));
     });
   });
@@ -1410,13 +1407,11 @@
       stubRestApi('getDiffComments').returns(Promise.resolve({}));
       stubRestApi('getDiffRobotComments').returns(Promise.resolve({}));
       stubRestApi('getDiffDrafts').returns(Promise.resolve({}));
-      stub('gr-date-formatter', {
-        _loadTimeFormat() { return Promise.resolve(''); },
-      });
-      stub('gr-diff-host', {
-        reload() { return Promise.resolve(); },
-        prefetchDiff() {},
-      });
+      stub('gr-date-formatter', '_loadTimeFormat').callsFake(() =>
+        Promise.resolve('')
+      );
+      stub('gr-diff-host', 'reload').callsFake(() => Promise.resolve());
+      stub('gr-diff-host', 'prefetchDiff').callsFake(() => {});
 
       // Element must be wrapped in an element with direct access to the
       // comment API.
@@ -1488,7 +1483,7 @@
       assert.isFalse(diffStops[11].classList.contains('target-row'));
 
       // The file cursor is now at 1.
-      assert.equal(element.$.fileCursor.index, 1);
+      assert.equal(element.fileCursor.index, 1);
       MockInteractions.keyUpOn(element, 73, null, 'i');
       flush();
 
@@ -1530,7 +1525,7 @@
       assert.isTrue(diffStops[11].classList.contains('target-row'));
 
       // The file cursor is still at 0.
-      assert.equal(element.$.fileCursor.index, 0);
+      assert.equal(element.fileCursor.index, 0);
     });
 
     suite('n key presses', () => {
diff --git a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.ts b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.ts
index 55c505a..c11e484 100644
--- a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.ts
@@ -17,7 +17,6 @@
 import '@polymer/iron-input/iron-input';
 import '../../../styles/shared-styles';
 import '../../shared/gr-button/gr-button';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-included-in-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -30,7 +29,7 @@
 }
 
 @customElement('gr-included-in-dialog')
-export class GrIncludedInDialog extends LegacyElementMixin(PolymerElement) {
+export class GrIncludedInDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.ts b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.ts
index 7ea2075..b4fa4a8 100644
--- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.ts
+++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.ts
@@ -18,7 +18,6 @@
 import '../../shared/gr-button/gr-button';
 import '../../../styles/gr-voting-styles';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-label-score-row_html';
 import {customElement, property} from '@polymer/decorators';
@@ -55,7 +54,7 @@
 }
 
 @customElement('gr-label-score-row')
-export class GrLabelScoreRow extends LegacyElementMixin(PolymerElement) {
+export class GrLabelScoreRow extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
index 526d01e..4147cc0 100644
--- a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
+++ b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-label-score-row/gr-label-score-row';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-label-scores_html';
 import {customElement, property} from '@polymer/decorators';
@@ -37,9 +36,10 @@
 import {PolymerDeepPropertyChange} from '@polymer/polymer/interfaces';
 import {appContext} from '../../../services/app-context';
 import {labelCompare} from '../../../utils/label-util';
+import {Execution} from '../../../constants/reporting';
 
 @customElement('gr-label-scores')
-export class GrLabelScores extends LegacyElementMixin(PolymerElement) {
+export class GrLabelScores extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -101,7 +101,10 @@
       }
     }
     const stringVal = `${numberValue}`;
-    this.reporting.reportExecution('label-value-not-found', {value: stringVal});
+    this.reporting.reportExecution(Execution.REACHABLE_CODE, {
+      value: stringVal,
+      id: 'label-value-not-found',
+    });
     return stringVal;
   }
 
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
index dc3f01a..3ea9f68 100644
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
@@ -23,7 +23,6 @@
 import '../../shared/gr-formatted-text/gr-formatted-text';
 import '../../../styles/shared-styles';
 import '../../../styles/gr-voting-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-message_html';
 import {MessageTag, SpecialFilePath} from '../../../constants/constants';
@@ -69,7 +68,7 @@
   id: ChangeMessageId;
 }
 
-interface ChangeMessage extends ChangeMessageInfo {
+export interface ChangeMessage extends ChangeMessageInfo {
   // TODO(TS): maybe should be an enum instead
   type: string;
   expanded: boolean;
@@ -84,7 +83,7 @@
 }
 
 @customElement('gr-message')
-export class GrMessage extends LegacyElementMixin(PolymerElement) {
+export class GrMessage extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -197,13 +196,13 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('click', e => this._handleClick(e));
   }
 
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.restApiService.getConfig().then(config => {
       this.config = config;
     });
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message_test.js b/polygerrit-ui/app/elements/change/gr-message/gr-message_test.js
deleted file mode 100644
index d8f9aa5..0000000
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message_test.js
+++ /dev/null
@@ -1,572 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import './gr-message.js';
-import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
-import {createChange, createRevisions} from '../../../test/test-data-generators.js';
-import {stubRestApi} from '../../../test/test-utils.js';
-
-const basicFixture = fixtureFromElement('gr-message');
-
-suite('gr-message tests', () => {
-  let element;
-
-  suite('when admin and logged in', () => {
-    setup(done => {
-      stubRestApi('getPreferences').returns(Promise.resolve({}));
-      stubRestApi('getIsAdmin').returns(Promise.resolve(true));
-      stubRestApi('deleteChangeCommitMessage').returns(Promise.resolve({}));
-      element = basicFixture.instantiate();
-      flush(done);
-    });
-
-    test('reply event', done => {
-      element.message = {
-        id: '47c43261_55aa2c41',
-        author: {
-          _account_id: 1115495,
-          name: 'Andrew Bonventre',
-          email: 'andybons@chromium.org',
-        },
-        date: '2016-01-12 20:24:49.448000000',
-        message: 'Uploaded patch set 1.',
-        _revision_number: 1,
-        expanded: true,
-      };
-
-      element.addEventListener('reply', e => {
-        assert.deepEqual(e.detail.message, element.message);
-        done();
-      });
-      flush();
-      assert.isFalse(
-          element.shadowRoot.querySelector('.replyActionContainer').hidden
-      );
-      MockInteractions.tap(element.shadowRoot.querySelector('.replyBtn'));
-    });
-
-    test('can see delete button', () => {
-      element.message = {
-        id: '47c43261_55aa2c41',
-        author: {
-          _account_id: 1115495,
-          name: 'Andrew Bonventre',
-          email: 'andybons@chromium.org',
-        },
-        date: '2016-01-12 20:24:49.448000000',
-        message: 'Uploaded patch set 1.',
-        _revision_number: 1,
-        expanded: true,
-      };
-
-      flush();
-      assert.isFalse(element.shadowRoot.querySelector('.deleteBtn').hidden);
-    });
-
-    test('delete change message', done => {
-      element.changeNum = 314159;
-      element.message = {
-        id: '47c43261_55aa2c41',
-        author: {
-          _account_id: 1115495,
-          name: 'Andrew Bonventre',
-          email: 'andybons@chromium.org',
-        },
-        date: '2016-01-12 20:24:49.448000000',
-        message: 'Uploaded patch set 1.',
-        _revision_number: 1,
-        expanded: true,
-      };
-
-      element.addEventListener('change-message-deleted', e => {
-        assert.deepEqual(e.detail.message, element.message);
-        assert.isFalse(element.shadowRoot.querySelector('.deleteBtn').disabled);
-        done();
-      });
-      flush();
-      MockInteractions.tap(element.shadowRoot.querySelector('.deleteBtn'));
-      assert.isTrue(element.shadowRoot.querySelector('.deleteBtn').disabled);
-    });
-
-    test('autogenerated prefix hiding', () => {
-      element.message = {
-        tag: 'autogenerated:gerrit:test',
-        updated: '2016-01-12 20:24:49.448000000',
-        expanded: false,
-      };
-
-      assert.isTrue(element.isAutomated);
-      assert.isFalse(element.hidden);
-
-      element.hideAutomated = true;
-
-      assert.isTrue(element.hidden);
-    });
-
-    test('reviewer message treated as autogenerated', () => {
-      element.message = {
-        tag: 'autogenerated:gerrit:test',
-        updated: '2016-01-12 20:24:49.448000000',
-        reviewer: {},
-        expanded: false,
-      };
-
-      assert.isTrue(element.isAutomated);
-      assert.isFalse(element.hidden);
-
-      element.hideAutomated = true;
-
-      assert.isTrue(element.hidden);
-    });
-
-    test('batch reviewer message treated as autogenerated', () => {
-      element.message = {
-        type: 'REVIEWER_UPDATE',
-        updated: '2016-01-12 20:24:49.448000000',
-        reviewer: {},
-        expanded: false,
-      };
-
-      assert.isTrue(element.isAutomated);
-      assert.isFalse(element.hidden);
-
-      element.hideAutomated = true;
-
-      assert.isTrue(element.hidden);
-    });
-
-    test('tag that is not autogenerated prefix does not hide', () => {
-      element.message = {
-        tag: 'something',
-        updated: '2016-01-12 20:24:49.448000000',
-        expanded: false,
-      };
-
-      assert.isFalse(element.isAutomated);
-      assert.isFalse(element.hidden);
-
-      element.hideAutomated = true;
-
-      assert.isFalse(element.hidden);
-    });
-
-    test('reply button hidden unless logged in', () => {
-      const message = {
-        message: 'Uploaded patch set 1.',
-        expanded: false,
-      };
-      assert.isFalse(element._computeShowReplyButton(message, false));
-      assert.isTrue(element._computeShowReplyButton(message, true));
-    });
-
-    test('_computeShowOnBehalfOf', () => {
-      const message = {
-        message: '...',
-        expanded: false,
-      };
-      assert.isNotOk(element._computeShowOnBehalfOf(message));
-      message.author = {_account_id: 1115495};
-      assert.isNotOk(element._computeShowOnBehalfOf(message));
-      message.real_author = {_account_id: 1115495};
-      assert.isNotOk(element._computeShowOnBehalfOf(message));
-      message.real_author._account_id = 123456;
-      assert.isOk(element._computeShowOnBehalfOf(message));
-      message.updated_by = message.author;
-      delete message.author;
-      assert.isOk(element._computeShowOnBehalfOf(message));
-      delete message.updated_by;
-      assert.isNotOk(element._computeShowOnBehalfOf(message));
-    });
-
-    ['Trybot-Ready', 'Tryjob-Request', 'Commit-Queue'].forEach(label => {
-      test(`${label} ignored for color voting`, () => {
-        element.message = {
-          author: {},
-          expanded: false,
-          message: `Patch Set 1: ${label}+1`,
-        };
-        assert.isNotOk(
-            element.root.querySelector('.negativeVote'));
-        assert.isNotOk(
-            element.root.querySelector('.positiveVote'));
-      });
-    });
-
-    test('clicking on date link fires event', () => {
-      element.message = {
-        type: 'REVIEWER_UPDATE',
-        updated: '2016-01-12 20:24:49.448000000',
-        reviewer: {},
-        id: '47c43261_55aa2c41',
-        expanded: false,
-      };
-      flush();
-      const stub = sinon.stub();
-      element.addEventListener('message-anchor-tap', stub);
-      const dateEl = element.shadowRoot
-          .querySelector('.date');
-      assert.ok(dateEl);
-      MockInteractions.tap(dateEl);
-
-      assert.isTrue(stub.called);
-      assert.deepEqual(stub.lastCall.args[0].detail, {id: element.message.id});
-    });
-
-    suite('uploaded patchset X message navigates to X - 1 vs  X', () => {
-      let navStub;
-      setup(() => {
-        element.change = {...createChange(), revisions: createRevisions(4)};
-        navStub = sinon.stub(GerritNav, 'navigateToChange');
-      });
-
-      test('Patchset 1 navigates to Base', () => {
-        element.message = {
-          message: 'Uploaded patch set 1.',
-        };
-        element._handleViewPatchsetDiff(new MouseEvent('click'));
-        assert.isTrue(navStub.calledWithExactly(element.change, 1,
-            'PARENT'));
-      });
-
-      test('Patchset X navigates to X vs X - 1', () => {
-        element.message = {
-          message: 'Uploaded patch set 2.',
-        };
-        element._handleViewPatchsetDiff(new MouseEvent('click'));
-        assert.isTrue(navStub.calledWithExactly(element.change, 2, 1));
-
-        element.message = {
-          message: 'Uploaded patch set 200.',
-        };
-        element._handleViewPatchsetDiff(new MouseEvent('click'));
-        assert.isTrue(navStub.calledWithExactly(element.change, 200, 199));
-      });
-
-      test('Commit message updated', () => {
-        element.message = {
-          message: 'Commit message updated.',
-        };
-        element._handleViewPatchsetDiff(new MouseEvent('click'));
-        assert.isTrue(navStub.calledWithExactly(element.change, 4, 3));
-      });
-
-      test('Merged patchset change message', () => {
-        element.message = {
-          message: 'abcd↵3 is the latest approved patch-set.↵abc',
-        };
-        element._handleViewPatchsetDiff(new MouseEvent('click'));
-        assert.isTrue(navStub.calledWithExactly(element.change, 4, 3));
-      });
-    });
-
-    suite('compute messages', () => {
-      test('empty', () => {
-        assert.equal(element._computeMessageContent(true, '', ''), '');
-        assert.equal(element._computeMessageContent(false, '', ''), '');
-      });
-
-      test('new patchset', () => {
-        const original = 'Uploaded patch set 1.';
-        const tag = 'autogenerated:gerrit:newPatchSet';
-        let actual = element._computeMessageContent(true, original, tag);
-        assert.equal(actual, element._computeMessageContentCollapsed(
-            original, tag, []));
-        assert.equal(actual, original);
-        actual = element._computeMessageContent(false, original, tag);
-        assert.equal(actual, original);
-      });
-
-      test('new patchset rebased', () => {
-        const original = 'Patch Set 27: Patch Set 26 was rebased';
-        const tag = 'autogenerated:gerrit:newPatchSet';
-        const expected = 'Patch Set 26 was rebased';
-        let actual = element._computeMessageContent(true, original, tag);
-        assert.equal(actual, expected);
-        assert.equal(actual, element._computeMessageContentCollapsed(
-            original, tag, []));
-        actual = element._computeMessageContent(false, original, tag);
-        assert.equal(actual, expected);
-      });
-
-      test('ready for review', () => {
-        const original = 'Patch Set 1:\n\nThis change is ready for review.';
-        const tag = undefined;
-        const expected = 'This change is ready for review.';
-        let actual = element._computeMessageContent(true, original, tag);
-        assert.equal(actual, expected);
-        assert.equal(actual, element._computeMessageContentCollapsed(
-            original, tag, []));
-        actual = element._computeMessageContent(false, original, tag);
-        assert.equal(actual, expected);
-      });
-
-      test('vote', () => {
-        const original = 'Patch Set 1: Code-Style+1';
-        const tag = undefined;
-        const expected = '';
-        let actual = element._computeMessageContent(true, original, tag);
-        assert.equal(actual, expected);
-        actual = element._computeMessageContent(false, original, tag);
-        assert.equal(actual, expected);
-      });
-
-      test('comments', () => {
-        const original = 'Patch Set 1:\n\n(3 comments)';
-        const tag = undefined;
-        const expected = '';
-        let actual = element._computeMessageContent(true, original, tag);
-        assert.equal(actual, expected);
-        actual = element._computeMessageContent(false, original, tag);
-        assert.equal(actual, expected);
-      });
-    });
-
-    test('votes', () => {
-      element.message = {
-        author: {},
-        expanded: false,
-        message: 'Patch Set 1: Verified+1 Code-Review-2 Trybot-Label3+1 Blub+1',
-      };
-      element.labelExtremes = {
-        'Verified': {max: 1, min: -1},
-        'Code-Review': {max: 2, min: -2},
-        'Trybot-Label3': {max: 3, min: 0},
-      };
-      flush();
-      const scoreChips = element.root.querySelectorAll('.score');
-      assert.equal(scoreChips.length, 3);
-
-      assert.isTrue(scoreChips[0].classList.contains('positive'));
-      assert.isTrue(scoreChips[0].classList.contains('max'));
-
-      assert.isTrue(scoreChips[1].classList.contains('negative'));
-      assert.isTrue(scoreChips[1].classList.contains('min'));
-
-      assert.isTrue(scoreChips[2].classList.contains('positive'));
-      assert.isFalse(scoreChips[2].classList.contains('min'));
-    });
-
-    test('Uploaded patch set X', () => {
-      element.message = {
-        author: {},
-        expanded: false,
-        message: 'Uploaded patch set 1:' +
-         'Verified+1 Code-Review-2 Trybot-Label3+1 Blub+1',
-      };
-      element.labelExtremes = {
-        'Verified': {max: 1, min: -1},
-        'Code-Review': {max: 2, min: -2},
-        'Trybot-Label3': {max: 3, min: 0},
-      };
-      flush();
-      const scoreChips = element.root.querySelectorAll('.score');
-      assert.equal(scoreChips.length, 3);
-
-      assert.isTrue(scoreChips[0].classList.contains('positive'));
-      assert.isTrue(scoreChips[0].classList.contains('max'));
-
-      assert.isTrue(scoreChips[1].classList.contains('negative'));
-      assert.isTrue(scoreChips[1].classList.contains('min'));
-
-      assert.isTrue(scoreChips[2].classList.contains('positive'));
-      assert.isFalse(scoreChips[2].classList.contains('min'));
-    });
-
-    test('removed votes', () => {
-      element.message = {
-        author: {},
-        expanded: false,
-        message: 'Patch Set 1: Verified+1 -Code-Review -Commit-Queue',
-      };
-      element.labelExtremes = {
-        'Verified': {max: 1, min: -1},
-        'Code-Review': {max: 2, min: -2},
-        'Commit-Queue': {max: 3, min: 0},
-      };
-      flush();
-      const scoreChips = element.root.querySelectorAll('.score');
-      assert.equal(scoreChips.length, 3);
-
-      assert.isTrue(scoreChips[1].classList.contains('removed'));
-      assert.isTrue(scoreChips[2].classList.contains('removed'));
-    });
-
-    test('false negative vote', () => {
-      element.message = {
-        author: {},
-        expanded: false,
-        message: 'Patch Set 1: Cherry Picked from branch stable-2.14.',
-      };
-      element.labelExtremes = {};
-      const scoreChips = element.root.querySelectorAll('.score');
-      assert.equal(scoreChips.length, 0);
-    });
-  });
-
-  suite('when not logged in', () => {
-    setup(done => {
-      stubRestApi('getLoggedIn').returns(Promise.resolve(false));
-      stubRestApi('getPreferences').returns(Promise.resolve({}));
-      stubRestApi('getIsAdmin').returns(Promise.resolve(false));
-      stubRestApi('deleteChangeCommitMessage').returns(Promise.resolve({}));
-      element = basicFixture.instantiate();
-      flush(done);
-    });
-
-    test('reply and delete button should be hidden', () => {
-      element.message = {
-        id: '47c43261_55aa2c41',
-        author: {
-          _account_id: 1115495,
-          name: 'Andrew Bonventre',
-          email: 'andybons@chromium.org',
-        },
-        date: '2016-01-12 20:24:49.448000000',
-        message: 'Uploaded patch set 1.',
-        _revision_number: 1,
-        expanded: true,
-      };
-
-      flush();
-      assert.isTrue(
-          element.shadowRoot.querySelector('.replyActionContainer').hidden
-      );
-      assert.isTrue(
-          element.shadowRoot.querySelector('.deleteBtn').hidden
-      );
-    });
-  });
-
-  suite('patchset comment summary', () => {
-    setup(() => {
-      element = basicFixture.instantiate();
-      element.message = {id: '6a07f64a82f96e7337ca5f7f84cfc73abf8ac2a3'};
-    });
-
-    test('single patchset comment posted', () => {
-      const threads = [{
-        comments: [{
-          change_message_id: '6a07f64a82f96e7337ca5f7f84cfc73abf8ac2a3',
-          patch_set: 1,
-          id: 'e365b138_bed65caa',
-          updated: '2020-05-15 13:35:56.000000000',
-          message: 'testing the load',
-          unresolved: false,
-          path: '/PATCHSET_LEVEL',
-          collapsed: false,
-        }],
-        patchNum: 1,
-        path: '/PATCHSET_LEVEL',
-        rootId: 'e365b138_bed65caa',
-      }];
-      assert.equal(element._computeMessageContentCollapsed(
-          '', undefined, threads), 'testing the load');
-      assert.equal(element._computeMessageContent(false, '', undefined), '');
-    });
-
-    test('single patchset comment with reply', () => {
-      const threads = [{
-        comments: [{
-          patch_set: 1,
-          id: 'e365b138_bed65caa',
-          updated: '2020-05-15 13:35:56.000000000',
-          message: 'testing the load',
-          unresolved: false,
-          path: '/PATCHSET_LEVEL',
-          collapsed: false,
-        }, {
-          change_message_id: '6a07f64a82f96e7337ca5f7f84cfc73abf8ac2a3',
-          patch_set: 1,
-          id: 'd6efcc85_4cbbb6f4',
-          in_reply_to: 'e365b138_bed65caa',
-          updated: '2020-05-15 16:55:28.000000000',
-          message: 'n',
-          unresolved: false,
-          path: '/PATCHSET_LEVEL',
-          __draft: true,
-          collapsed: true,
-        }],
-        patchNum: 1,
-        path: '/PATCHSET_LEVEL',
-        rootId: 'e365b138_bed65caa',
-      }];
-      assert.equal(element._computeMessageContentCollapsed(
-          '', undefined, threads), 'n');
-      assert.equal(element._computeMessageContent(false, '', undefined), '');
-    });
-  });
-
-  suite('when logged in but not admin', () => {
-    setup(async () => {
-      stubRestApi('getIsAdmin').returns(Promise.resolve(false));
-      stubRestApi('deleteChangeCommitMessage').returns(Promise.resolve({}));
-      element = basicFixture.instantiate();
-      await flush();
-    });
-
-    test('can see reply but not delete button', () => {
-      element.message = {
-        id: '47c43261_55aa2c41',
-        author: {
-          _account_id: 1115495,
-          name: 'Andrew Bonventre',
-          email: 'andybons@chromium.org',
-        },
-        date: '2016-01-12 20:24:49.448000000',
-        message: 'Uploaded patch set 1.',
-        _revision_number: 1,
-        expanded: true,
-      };
-
-      flush();
-      assert.isFalse(
-          element.shadowRoot.querySelector('.replyActionContainer').hidden
-      );
-      assert.isTrue(
-          element.shadowRoot.querySelector('.deleteBtn').hidden
-      );
-    });
-
-    test('reply button shown when message is updated', () => {
-      element.message = undefined;
-      flush();
-      let replyEl = element.shadowRoot.querySelector('.replyActionContainer');
-      // We don't even expect the button to show up in the DOM when the message
-      // is undefined.
-      assert.isNotOk(replyEl);
-
-      element.message = {
-        id: '47c43261_55aa2c41',
-        author: {
-          _account_id: 1115495,
-          name: 'Andrew Bonventre',
-          email: 'andybons@chromium.org',
-        },
-        date: '2016-01-12 20:24:49.448000000',
-        message: 'not empty',
-        _revision_number: 1,
-        expanded: true,
-      };
-      flush();
-      replyEl = element.shadowRoot.querySelector('.replyActionContainer');
-      assert.isOk(replyEl);
-      assert.isFalse(replyEl.hidden);
-    });
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message_test.ts b/polygerrit-ui/app/elements/change/gr-message/gr-message_test.ts
new file mode 100644
index 0000000..b8f3c73
--- /dev/null
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message_test.ts
@@ -0,0 +1,676 @@
+/**
+ * @license
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import '../../../test/common-test-setup-karma';
+import './gr-message';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation';
+import {
+  createChange,
+  createChangeMessage,
+  createComment,
+  createRevisions,
+} from '../../../test/test-data-generators';
+import {
+  query,
+  queryAll,
+  queryAndAssert,
+  stubRestApi,
+} from '../../../test/test-utils';
+import {GrMessage} from './gr-message';
+import {
+  AccountId,
+  BasePatchSetNum,
+  ChangeMessageId,
+  EmailAddress,
+  NumericChangeId,
+  PatchSetNum,
+  ReviewInputTag,
+  Timestamp,
+  UrlEncodedCommentId,
+} from '../../../types/common';
+import {tap} from '@polymer/iron-test-helpers/mock-interactions';
+import {
+  ChangeMessageDeletedEventDetail,
+  ReplyEventDetail,
+} from '../../../types/events';
+import {GrButton} from '../../shared/gr-button/gr-button';
+import {CommentSide} from '../../../constants/constants';
+import {SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+
+const basicFixture = fixtureFromElement('gr-message');
+
+suite('gr-message tests', () => {
+  let element: GrMessage;
+
+  suite('when admin and logged in', () => {
+    setup(done => {
+      stubRestApi('getIsAdmin').returns(Promise.resolve(true));
+      element = basicFixture.instantiate();
+      flush(done);
+    });
+
+    test('reply event', done => {
+      element.message = {
+        ...createChangeMessage(),
+        id: '47c43261_55aa2c41' as ChangeMessageId,
+        author: {
+          _account_id: 1115495 as AccountId,
+          name: 'Andrew Bonventre',
+          email: 'andybons@chromium.org' as EmailAddress,
+        },
+        date: '2016-01-12 20:24:49.448000000' as Timestamp,
+        message: 'Uploaded patch set 1.',
+        _revision_number: 1 as PatchSetNum,
+        expanded: true,
+      };
+
+      element.addEventListener('reply', (e: CustomEvent<ReplyEventDetail>) => {
+        assert.deepEqual(e.detail.message, element.message);
+        done();
+      });
+      flush();
+      assert.isFalse(
+        queryAndAssert<HTMLElement>(element, '.replyActionContainer').hidden
+      );
+      tap(queryAndAssert(element, '.replyBtn'));
+    });
+
+    test('can see delete button', () => {
+      element.message = {
+        ...createChangeMessage(),
+        id: '47c43261_55aa2c41' as ChangeMessageId,
+        author: {
+          _account_id: 1115495 as AccountId,
+          name: 'Andrew Bonventre',
+          email: 'andybons@chromium.org' as EmailAddress,
+        },
+        date: '2016-01-12 20:24:49.448000000' as Timestamp,
+        message: 'Uploaded patch set 1.',
+        _revision_number: 1 as PatchSetNum,
+        expanded: true,
+      };
+
+      flush();
+      assert.isFalse(queryAndAssert<HTMLElement>(element, '.deleteBtn').hidden);
+    });
+
+    test('delete change message', done => {
+      element.changeNum = 314159 as NumericChangeId;
+      element.message = {
+        ...createChangeMessage(),
+        id: '47c43261_55aa2c41' as ChangeMessageId,
+        author: {
+          _account_id: 1115495 as AccountId,
+          name: 'Andrew Bonventre',
+          email: 'andybons@chromium.org' as EmailAddress,
+        },
+        date: '2016-01-12 20:24:49.448000000' as Timestamp,
+        message: 'Uploaded patch set 1.',
+        _revision_number: 1 as PatchSetNum,
+        expanded: true,
+      };
+
+      element.addEventListener(
+        'change-message-deleted',
+        (e: CustomEvent<ChangeMessageDeletedEventDetail>) => {
+          assert.deepEqual(e.detail.message, element.message);
+          assert.isFalse(
+            (queryAndAssert(element, '.deleteBtn') as GrButton).disabled
+          );
+          done();
+        }
+      );
+      flush();
+      tap(queryAndAssert(element, '.deleteBtn'));
+      assert.isTrue(
+        (queryAndAssert(element, '.deleteBtn') as GrButton).disabled
+      );
+    });
+
+    test('autogenerated prefix hiding', () => {
+      element.message = {
+        ...createChangeMessage(),
+        tag: 'autogenerated:gerrit:test' as ReviewInputTag,
+        expanded: false,
+      };
+
+      assert.isTrue(element.isAutomated);
+      assert.isFalse(element.hidden);
+
+      element.hideAutomated = true;
+
+      assert.isTrue(element.hidden);
+    });
+
+    test('reviewer message treated as autogenerated', () => {
+      element.message = {
+        ...createChangeMessage(),
+        tag: 'autogenerated:gerrit:test' as ReviewInputTag,
+        reviewer: {},
+        expanded: false,
+      };
+
+      assert.isTrue(element.isAutomated);
+      assert.isFalse(element.hidden);
+
+      element.hideAutomated = true;
+
+      assert.isTrue(element.hidden);
+    });
+
+    test('batch reviewer message treated as autogenerated', () => {
+      element.message = {
+        ...createChangeMessage(),
+        type: 'REVIEWER_UPDATE',
+        reviewer: {},
+        expanded: false,
+      };
+
+      assert.isTrue(element.isAutomated);
+      assert.isFalse(element.hidden);
+
+      element.hideAutomated = true;
+
+      assert.isTrue(element.hidden);
+    });
+
+    test('tag that is not autogenerated prefix does not hide', () => {
+      element.message = {
+        ...createChangeMessage(),
+        tag: 'something' as ReviewInputTag,
+        expanded: false,
+      };
+
+      assert.isFalse(element.isAutomated);
+      assert.isFalse(element.hidden);
+
+      element.hideAutomated = true;
+
+      assert.isFalse(element.hidden);
+    });
+
+    test('reply button hidden unless logged in', () => {
+      const message = {
+        ...createChangeMessage(),
+        message: 'Uploaded patch set 1.',
+        expanded: false,
+      };
+      assert.isFalse(element._computeShowReplyButton(message, false));
+      assert.isTrue(element._computeShowReplyButton(message, true));
+    });
+
+    test('_computeShowOnBehalfOf', () => {
+      const message = {
+        ...createChangeMessage(),
+        message: '...',
+        expanded: false,
+      };
+      assert.isNotOk(element._computeShowOnBehalfOf(message));
+      message.author = {_account_id: 1115495 as AccountId};
+      assert.isNotOk(element._computeShowOnBehalfOf(message));
+      message.real_author = {_account_id: 1115495 as AccountId};
+      assert.isNotOk(element._computeShowOnBehalfOf(message));
+      message.real_author._account_id = 123456 as AccountId;
+      assert.isOk(element._computeShowOnBehalfOf(message));
+      message.updated_by = message.author;
+      delete message.author;
+      assert.isOk(element._computeShowOnBehalfOf(message));
+      delete message.updated_by;
+      assert.isNotOk(element._computeShowOnBehalfOf(message));
+    });
+
+    ['Trybot-Ready', 'Tryjob-Request', 'Commit-Queue'].forEach(label => {
+      test(`${label} ignored for color voting`, () => {
+        element.message = {
+          ...createChangeMessage(),
+          author: {},
+          expanded: false,
+          message: `Patch Set 1: ${label}+1`,
+        };
+        assert.isNotOk(query(element, '.negativeVote'));
+        assert.isNotOk(query(element, '.positiveVote'));
+      });
+    });
+
+    test('clicking on date link fires event', () => {
+      element.message = {
+        ...createChangeMessage(),
+        type: 'REVIEWER_UPDATE',
+        reviewer: {},
+        id: '47c43261_55aa2c41' as ChangeMessageId,
+        expanded: false,
+      };
+      flush();
+      const stub = sinon.stub();
+      element.addEventListener('message-anchor-tap', stub);
+      const dateEl = queryAndAssert(element, '.date');
+      assert.ok(dateEl);
+      tap(dateEl);
+
+      assert.isTrue(stub.called);
+      assert.deepEqual(stub.lastCall.args[0].detail, {id: element.message.id});
+    });
+
+    suite('uploaded patchset X message navigates to X - 1 vs  X', () => {
+      let navStub: SinonStubbedMember<typeof GerritNav.navigateToChange>;
+      setup(() => {
+        element.change = {...createChange(), revisions: createRevisions(4)};
+        navStub = sinon.stub(GerritNav, 'navigateToChange');
+      });
+
+      test('Patchset 1 navigates to Base', () => {
+        element.message = {
+          ...createChangeMessage(),
+          message: 'Uploaded patch set 1.',
+        };
+        element._handleViewPatchsetDiff(new MouseEvent('click'));
+        assert.isTrue(
+          navStub.calledWithExactly(
+            element.change!,
+            1 as PatchSetNum,
+            'PARENT' as BasePatchSetNum
+          )
+        );
+      });
+
+      test('Patchset X navigates to X vs X - 1', () => {
+        element.message = {
+          ...createChangeMessage(),
+          message: 'Uploaded patch set 2.',
+        };
+        element._handleViewPatchsetDiff(new MouseEvent('click'));
+        assert.isTrue(
+          navStub.calledWithExactly(
+            element.change!,
+            2 as PatchSetNum,
+            1 as BasePatchSetNum
+          )
+        );
+
+        element.message = {
+          ...createChangeMessage(),
+          message: 'Uploaded patch set 200.',
+        };
+        element._handleViewPatchsetDiff(new MouseEvent('click'));
+        assert.isTrue(
+          navStub.calledWithExactly(
+            element.change!,
+            200 as PatchSetNum,
+            199 as BasePatchSetNum
+          )
+        );
+      });
+
+      test('Commit message updated', () => {
+        element.message = {
+          ...createChangeMessage(),
+          message: 'Commit message updated.',
+        };
+        element._handleViewPatchsetDiff(new MouseEvent('click'));
+        assert.isTrue(
+          navStub.calledWithExactly(
+            element.change!,
+            4 as PatchSetNum,
+            3 as BasePatchSetNum
+          )
+        );
+      });
+
+      test('Merged patchset change message', () => {
+        element.message = {
+          ...createChangeMessage(),
+          message: 'abcd↵3 is the latest approved patch-set.↵abc',
+        };
+        element._handleViewPatchsetDiff(new MouseEvent('click'));
+        assert.isTrue(
+          navStub.calledWithExactly(
+            element.change!,
+            4 as PatchSetNum,
+            3 as BasePatchSetNum
+          )
+        );
+      });
+    });
+
+    suite('compute messages', () => {
+      test('empty', () => {
+        assert.equal(
+          element._computeMessageContent(true, '', '' as ReviewInputTag),
+          ''
+        );
+        assert.equal(
+          element._computeMessageContent(false, '', '' as ReviewInputTag),
+          ''
+        );
+      });
+
+      test('new patchset', () => {
+        const original = 'Uploaded patch set 1.';
+        const tag = 'autogenerated:gerrit:newPatchSet' as ReviewInputTag;
+        let actual = element._computeMessageContent(true, original, tag);
+        assert.equal(
+          actual,
+          element._computeMessageContentCollapsed(original, tag, [])
+        );
+        assert.equal(actual, original);
+        actual = element._computeMessageContent(false, original, tag);
+        assert.equal(actual, original);
+      });
+
+      test('new patchset rebased', () => {
+        const original = 'Patch Set 27: Patch Set 26 was rebased';
+        const tag = 'autogenerated:gerrit:newPatchSet' as ReviewInputTag;
+        const expected = 'Patch Set 26 was rebased';
+        let actual = element._computeMessageContent(true, original, tag);
+        assert.equal(actual, expected);
+        assert.equal(
+          actual,
+          element._computeMessageContentCollapsed(original, tag, [])
+        );
+        actual = element._computeMessageContent(false, original, tag);
+        assert.equal(actual, expected);
+      });
+
+      test('ready for review', () => {
+        const original = 'Patch Set 1:\n\nThis change is ready for review.';
+        const tag = undefined;
+        const expected = 'This change is ready for review.';
+        let actual = element._computeMessageContent(true, original, tag);
+        assert.equal(actual, expected);
+        assert.equal(
+          actual,
+          element._computeMessageContentCollapsed(original, tag, [])
+        );
+        actual = element._computeMessageContent(false, original, tag);
+        assert.equal(actual, expected);
+      });
+
+      test('vote', () => {
+        const original = 'Patch Set 1: Code-Style+1';
+        const tag = undefined;
+        const expected = '';
+        let actual = element._computeMessageContent(true, original, tag);
+        assert.equal(actual, expected);
+        actual = element._computeMessageContent(false, original, tag);
+        assert.equal(actual, expected);
+      });
+
+      test('comments', () => {
+        const original = 'Patch Set 1:\n\n(3 comments)';
+        const tag = undefined;
+        const expected = '';
+        let actual = element._computeMessageContent(true, original, tag);
+        assert.equal(actual, expected);
+        actual = element._computeMessageContent(false, original, tag);
+        assert.equal(actual, expected);
+      });
+    });
+
+    test('votes', () => {
+      element.message = {
+        ...createChangeMessage(),
+        author: {},
+        expanded: false,
+        message: 'Patch Set 1: Verified+1 Code-Review-2 Trybot-Label3+1 Blub+1',
+      };
+      element.labelExtremes = {
+        Verified: {max: 1, min: -1},
+        'Code-Review': {max: 2, min: -2},
+        'Trybot-Label3': {max: 3, min: 0},
+      };
+      flush();
+      const scoreChips = queryAll(element, '.score');
+      assert.equal(scoreChips.length, 3);
+
+      assert.isTrue(scoreChips[0].classList.contains('positive'));
+      assert.isTrue(scoreChips[0].classList.contains('max'));
+
+      assert.isTrue(scoreChips[1].classList.contains('negative'));
+      assert.isTrue(scoreChips[1].classList.contains('min'));
+
+      assert.isTrue(scoreChips[2].classList.contains('positive'));
+      assert.isFalse(scoreChips[2].classList.contains('min'));
+    });
+
+    test('Uploaded patch set X', () => {
+      element.message = {
+        ...createChangeMessage(),
+        author: {},
+        expanded: false,
+        message:
+          'Uploaded patch set 1:' +
+          'Verified+1 Code-Review-2 Trybot-Label3+1 Blub+1',
+      };
+      element.labelExtremes = {
+        Verified: {max: 1, min: -1},
+        'Code-Review': {max: 2, min: -2},
+        'Trybot-Label3': {max: 3, min: 0},
+      };
+      flush();
+      const scoreChips = queryAll(element, '.score');
+      assert.equal(scoreChips.length, 3);
+
+      assert.isTrue(scoreChips[0].classList.contains('positive'));
+      assert.isTrue(scoreChips[0].classList.contains('max'));
+
+      assert.isTrue(scoreChips[1].classList.contains('negative'));
+      assert.isTrue(scoreChips[1].classList.contains('min'));
+
+      assert.isTrue(scoreChips[2].classList.contains('positive'));
+      assert.isFalse(scoreChips[2].classList.contains('min'));
+    });
+
+    test('removed votes', () => {
+      element.message = {
+        ...createChangeMessage(),
+        author: {},
+        expanded: false,
+        message: 'Patch Set 1: Verified+1 -Code-Review -Commit-Queue',
+      };
+      element.labelExtremes = {
+        Verified: {max: 1, min: -1},
+        'Code-Review': {max: 2, min: -2},
+        'Commit-Queue': {max: 3, min: 0},
+      };
+      flush();
+      const scoreChips = queryAll(element, '.score');
+      assert.equal(scoreChips.length, 3);
+
+      assert.isTrue(scoreChips[1].classList.contains('removed'));
+      assert.isTrue(scoreChips[2].classList.contains('removed'));
+    });
+
+    test('false negative vote', () => {
+      element.message = {
+        ...createChangeMessage(),
+        author: {},
+        expanded: false,
+        message: 'Patch Set 1: Cherry Picked from branch stable-2.14.',
+      };
+      element.labelExtremes = {};
+      const scoreChips = element.root!.querySelectorAll('.score');
+      assert.equal(scoreChips.length, 0);
+    });
+  });
+
+  suite('when not logged in', () => {
+    setup(done => {
+      stubRestApi('getLoggedIn').returns(Promise.resolve(false));
+      stubRestApi('getIsAdmin').returns(Promise.resolve(false));
+      element = basicFixture.instantiate();
+      flush(done);
+    });
+
+    test('reply and delete button should be hidden', () => {
+      element.message = {
+        ...createChangeMessage(),
+        id: '47c43261_55aa2c41' as ChangeMessageId,
+        author: {
+          _account_id: 1115495 as AccountId,
+          name: 'Andrew Bonventre',
+          email: 'andybons@chromium.org' as EmailAddress,
+        },
+        date: '2016-01-12 20:24:49.448000000' as Timestamp,
+        message: 'Uploaded patch set 1.',
+        _revision_number: 1 as PatchSetNum,
+        expanded: true,
+      };
+
+      flush();
+      assert.isTrue(
+        queryAndAssert<HTMLElement>(element, '.replyActionContainer').hidden
+      );
+      assert.isTrue(queryAndAssert<HTMLElement>(element, '.deleteBtn').hidden);
+    });
+  });
+
+  suite('patchset comment summary', () => {
+    setup(() => {
+      element = basicFixture.instantiate();
+      element.message = {
+        ...createChangeMessage(),
+        id: '6a07f64a82f96e7337ca5f7f84cfc73abf8ac2a3' as ChangeMessageId,
+      };
+    });
+
+    test('single patchset comment posted', () => {
+      const threads = [
+        {
+          comments: [
+            {
+              ...createComment(),
+              change_message_id: '6a07f64a82f96e7337ca5f7f84cfc73abf8ac2a3' as ChangeMessageId,
+              patch_set: 1 as PatchSetNum,
+              id: 'e365b138_bed65caa' as UrlEncodedCommentId,
+              updated: '2020-05-15 13:35:56.000000000' as Timestamp,
+              message: 'testing the load',
+              unresolved: false,
+              path: '/PATCHSET_LEVEL',
+              collapsed: false,
+            },
+          ],
+          patchNum: 1 as PatchSetNum,
+          path: '/PATCHSET_LEVEL',
+          rootId: 'e365b138_bed65caa' as UrlEncodedCommentId,
+          commentSide: CommentSide.REVISION,
+        },
+      ];
+      assert.equal(
+        element._computeMessageContentCollapsed('', undefined, threads),
+        'testing the load'
+      );
+      assert.equal(element._computeMessageContent(false, '', undefined), '');
+    });
+
+    test('single patchset comment with reply', () => {
+      const threads = [
+        {
+          comments: [
+            {
+              ...createComment(),
+              patch_set: 1 as PatchSetNum,
+              id: 'e365b138_bed65caa' as UrlEncodedCommentId,
+              updated: '2020-05-15 13:35:56.000000000' as Timestamp,
+              message: 'testing the load',
+              unresolved: false,
+              path: '/PATCHSET_LEVEL',
+              collapsed: false,
+            },
+            {
+              change_message_id: '6a07f64a82f96e7337ca5f7f84cfc73abf8ac2a3',
+              patch_set: 1 as PatchSetNum,
+              id: 'd6efcc85_4cbbb6f4' as UrlEncodedCommentId,
+              in_reply_to: 'e365b138_bed65caa' as UrlEncodedCommentId,
+              updated: '2020-05-15 16:55:28.000000000' as Timestamp,
+              message: 'n',
+              unresolved: false,
+              path: '/PATCHSET_LEVEL',
+              __draft: true,
+              collapsed: true,
+            },
+          ],
+          patchNum: 1 as PatchSetNum,
+          path: '/PATCHSET_LEVEL',
+          rootId: 'e365b138_bed65caa' as UrlEncodedCommentId,
+          commentSide: CommentSide.REVISION,
+        },
+      ];
+      assert.equal(
+        element._computeMessageContentCollapsed('', undefined, threads),
+        'n'
+      );
+      assert.equal(element._computeMessageContent(false, '', undefined), '');
+    });
+  });
+
+  suite('when logged in but not admin', () => {
+    setup(async () => {
+      stubRestApi('getIsAdmin').returns(Promise.resolve(false));
+      element = basicFixture.instantiate();
+      await flush();
+    });
+
+    test('can see reply but not delete button', () => {
+      element.message = {
+        ...createChangeMessage(),
+        id: '47c43261_55aa2c41' as ChangeMessageId,
+        author: {
+          _account_id: 1115495 as AccountId,
+          name: 'Andrew Bonventre',
+          email: 'andybons@chromium.org' as EmailAddress,
+        },
+        date: '2016-01-12 20:24:49.448000000' as Timestamp,
+        message: 'Uploaded patch set 1.',
+        _revision_number: 1 as PatchSetNum,
+        expanded: true,
+      };
+
+      flush();
+      assert.isFalse(
+        queryAndAssert<HTMLElement>(element, '.replyActionContainer').hidden
+      );
+      assert.isTrue(queryAndAssert<HTMLElement>(element, '.deleteBtn').hidden);
+    });
+
+    test('reply button shown when message is updated', () => {
+      element.message = undefined;
+      flush();
+      let replyEl = query(element, '.replyActionContainer');
+      // We don't even expect the button to show up in the DOM when the message
+      // is undefined.
+      assert.isNotOk(replyEl);
+
+      element.message = {
+        ...createChangeMessage(),
+        id: '47c43261_55aa2c41' as ChangeMessageId,
+        author: {
+          _account_id: 1115495 as AccountId,
+          name: 'Andrew Bonventre',
+          email: 'andybons@chromium.org' as EmailAddress,
+        },
+        date: '2016-01-12 20:24:49.448000000' as Timestamp,
+        message: 'not empty',
+        _revision_number: 1 as PatchSetNum,
+        expanded: true,
+      };
+      flush();
+      replyEl = queryAndAssert(element, '.replyActionContainer');
+      assert.isOk(replyEl);
+      assert.isFalse((replyEl as HTMLElement).hidden);
+    });
+  });
+});
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
index 16d9d39..6be0c07 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
@@ -19,7 +19,6 @@
 import '../../shared/gr-icons/gr-icons';
 import '../gr-message/gr-message';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-messages-list_html';
 import {
@@ -212,9 +211,7 @@
 }
 
 @customElement('gr-messages-list')
-export class GrMessagesList extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrMessagesList extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts
index 6c786ef..8fa8eab 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts
@@ -62,7 +62,7 @@
           checked="{{_showAllActivity}}"
           aria-labelledby="showAllEntriesLabel"
           role="switch"
-          on-tap="_onTapShowAllActivityToggle"
+          on-click="_onTapShowAllActivityToggle"
         ></paper-toggle-button>
         <div id="showAllEntriesLabel" aria-hidden="true">
           <span>Show all entries</span>
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts
index abac54c..659ef4f 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts
@@ -105,7 +105,7 @@
           margin-left: 1.2em;
         }
         section {
-          margin-bottom: var(--spacing-m);
+          margin-bottom: var(--spacing-l);
         }
         gr-related-change {
           display: flex;
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
index 788a42d..927f3c9 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
@@ -19,7 +19,6 @@
 import '../../plugins/gr-endpoint-param/gr-endpoint-param';
 import '../../plugins/gr-endpoint-slot/gr-endpoint-slot';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-related-changes-list_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -52,7 +51,7 @@
 }
 
 @customElement('gr-related-changes-list')
-export class GrRelatedChangesList extends LegacyElementMixin(PolymerElement) {
+export class GrRelatedChangesList extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -300,8 +299,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     // We listen to `new-section-loaded` events to allow plugins to trigger
     // visibility computations, if their content or visibility changed.
     this.addEventListener('new-section-loaded', () =>
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.js b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.js
deleted file mode 100644
index f54b819..0000000
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.js
+++ /dev/null
@@ -1,631 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import './gr-related-changes-list.js';
-import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
-import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
-import {resetPlugins} from '../../../test/test-utils.js';
-import {stubRestApi} from '../../../test/test-utils.js';
-
-const pluginApi = _testOnly_initGerritPluginApi();
-
-const basicFixture = fixtureFromElement('gr-related-changes-list');
-
-suite('gr-related-changes-list tests', () => {
-  let element;
-
-  setup(() => {
-    element = basicFixture.instantiate();
-  });
-
-  test('connected revisions', () => {
-    const change = {
-      revisions: {
-        'e3c6d60783bfdec9ebae7dcfec4662360433449e': {
-          _number: 1,
-        },
-        '26e5e4c9c7ae31cbd876271cca281ce22b413997': {
-          _number: 2,
-        },
-        'bf7884d695296ca0c91702ba3e2bc8df0f69a907': {
-          _number: 7,
-        },
-        'b5fc49f2e67d1889d5275cac04ad3648f2ec7fe3': {
-          _number: 5,
-        },
-        'd6bcee67570859ccb684873a85cf50b1f0e96fda': {
-          _number: 6,
-        },
-        'cc960918a7f90388f4a9e05753d0f7b90ad44546': {
-          _number: 3,
-        },
-        '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6': {
-          _number: 4,
-        },
-      },
-    };
-    let patchNum = 7;
-    let relatedChanges = [
-      {
-        commit: {
-          commit: '2cebeedfb1e80f4b872d0a13ade529e70652c0c8',
-          parents: [
-            {
-              commit: '87ed20b241576b620bbaa3dfd47715ce6782b7dd',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: '87ed20b241576b620bbaa3dfd47715ce6782b7dd',
-          parents: [
-            {
-              commit: '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb',
-          parents: [
-            {
-              commit: 'b0ccb183494a8e340b8725a2dc553967d61e6dae',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: 'b0ccb183494a8e340b8725a2dc553967d61e6dae',
-          parents: [
-            {
-              commit: 'bf7884d695296ca0c91702ba3e2bc8df0f69a907',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: 'bf7884d695296ca0c91702ba3e2bc8df0f69a907',
-          parents: [
-            {
-              commit: '613bc4f81741a559c6667ac08d71dcc3348f73ce',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: '613bc4f81741a559c6667ac08d71dcc3348f73ce',
-          parents: [
-            {
-              commit: '455ed9cd27a16bf6991f04dcc57ef575dc4d5e75',
-            },
-          ],
-        },
-      },
-    ];
-
-    let connectedChanges =
-        element._computeConnectedRevisions(change, patchNum, relatedChanges);
-    assert.deepEqual(connectedChanges, [
-      '613bc4f81741a559c6667ac08d71dcc3348f73ce',
-      'bf7884d695296ca0c91702ba3e2bc8df0f69a907',
-      'bf7884d695296ca0c91702ba3e2bc8df0f69a907',
-      'b0ccb183494a8e340b8725a2dc553967d61e6dae',
-      '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb',
-      '87ed20b241576b620bbaa3dfd47715ce6782b7dd',
-      '2cebeedfb1e80f4b872d0a13ade529e70652c0c8',
-    ]);
-
-    patchNum = 4;
-    relatedChanges = [
-      {
-        commit: {
-          commit: '2cebeedfb1e80f4b872d0a13ade529e70652c0c8',
-          parents: [
-            {
-              commit: '87ed20b241576b620bbaa3dfd47715ce6782b7dd',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: '87ed20b241576b620bbaa3dfd47715ce6782b7dd',
-          parents: [
-            {
-              commit: '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb',
-          parents: [
-            {
-              commit: 'b0ccb183494a8e340b8725a2dc553967d61e6dae',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: 'a3e5d9d4902b915a39e2efba5577211b9b3ebe7b',
-          parents: [
-            {
-              commit: '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6',
-          parents: [
-            {
-              commit: 'af815dac54318826b7f1fa468acc76349ffc588e',
-            },
-          ],
-        },
-      },
-      {
-        commit: {
-          commit: 'af815dac54318826b7f1fa468acc76349ffc588e',
-          parents: [
-            {
-              commit: '58f76e406e24cb8b0f5d64c7f5ac1e8616d0a22c',
-            },
-          ],
-        },
-      },
-    ];
-
-    connectedChanges =
-        element._computeConnectedRevisions(change, patchNum, relatedChanges);
-    assert.deepEqual(connectedChanges, [
-      'af815dac54318826b7f1fa468acc76349ffc588e',
-      '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6',
-      '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6',
-      'a3e5d9d4902b915a39e2efba5577211b9b3ebe7b',
-    ]);
-  });
-
-  test('_changesEqual', () => {
-    const change1 = {change_id: 123, _number: 0};
-    const change2 = {change_id: 456, _number: 1};
-    const change3 = {change_id: 123, _number: 2};
-    const change4 = {change_id: 123, _change_number: 1};
-
-    assert.isTrue(element._changesEqual(change1, change1));
-    assert.isFalse(element._changesEqual(change1, change2));
-    assert.isFalse(element._changesEqual(change1, change3));
-    assert.isTrue(element._changesEqual(change2, change4));
-  });
-
-  test('_getChangeNumber', () => {
-    const change1 = {change_id: 123, _number: 0};
-    const change2 = {change_id: 456, _change_number: 1};
-    assert.equal(element._getChangeNumber(change1), 0);
-    assert.equal(element._getChangeNumber(change2), 1);
-  });
-
-  test('event for section loaded fires for each section ', () => {
-    const loadedStub = sinon.stub();
-    element.patchNum = 7;
-    element.change = {
-      change_id: 123,
-      status: 'NEW',
-    };
-    element.mergeable = true;
-    element.addEventListener('new-section-loaded', loadedStub);
-    stubRestApi('getRelatedChanges').returns(Promise.resolve({changes: []}));
-    stubRestApi('getChangesSubmittedTogether').returns(Promise.resolve());
-    stubRestApi('getChangeCherryPicks').returns(Promise.resolve());
-    stubRestApi('getChangeConflicts').returns(Promise.resolve());
-
-    return element.reload().then(() => {
-      assert.equal(loadedStub.callCount, 4);
-    });
-  });
-
-  suite('getChangeConflicts resolves undefined', () => {
-    let element;
-
-    setup(() => {
-      element = basicFixture.instantiate();
-
-      stubRestApi('getRelatedChanges').returns(Promise.resolve({changes: []}));
-      stubRestApi('getChangesSubmittedTogether').returns(Promise.resolve());
-      stubRestApi('getChangeCherryPicks').returns(Promise.resolve());
-      stubRestApi('getChangeConflicts').returns(Promise.resolve());
-    });
-
-    test('_conflicts are an empty array', () => {
-      element.patchNum = 7;
-      element.change = {
-        change_id: 123,
-        status: 'NEW',
-      };
-      element.mergeable = true;
-      element.reload();
-      assert.equal(element._conflicts.length, 0);
-    });
-  });
-
-  suite('get conflicts tests', () => {
-    let element;
-    let conflictsStub;
-
-    setup(() => {
-      element = basicFixture.instantiate();
-
-      stubRestApi('getRelatedChanges').returns(Promise.resolve({changes: []}));
-      stubRestApi('getChangesSubmittedTogether').returns(Promise.resolve());
-      stubRestApi('getChangeCherryPicks').returns(Promise.resolve());
-      conflictsStub = stubRestApi('getChangeConflicts').returns(
-          Promise.resolve());
-    });
-
-    test('request conflicts if open and mergeable', () => {
-      element.patchNum = 7;
-      element.change = {
-        change_id: 123,
-        status: 'NEW',
-      };
-      element.mergeable = true;
-      element.reload();
-      assert.isTrue(conflictsStub.called);
-    });
-
-    test('does not request conflicts if closed and mergeable', () => {
-      element.patchNum = 7;
-      element.change = {
-        change_id: 123,
-        status: 'MERGED',
-      };
-      element.reload();
-      assert.isFalse(conflictsStub.called);
-    });
-
-    test('does not request conflicts if open and not mergeable', () => {
-      element.patchNum = 7;
-      element.change = {
-        change_id: 123,
-        status: 'NEW',
-      };
-      element.mergeable = false;
-      element.reload();
-      assert.isFalse(conflictsStub.called);
-    });
-
-    test('doesnt request conflicts if closed and not mergeable', () => {
-      element.patchNum = 7;
-      element.change = {
-        change_id: 123,
-        status: 'MERGED',
-      };
-      element.mergeable = false;
-      element.reload();
-      assert.isFalse(conflictsStub.called);
-    });
-  });
-
-  test('_calculateHasParent', () => {
-    const changeId = 123;
-    const relatedChanges = [];
-
-    assert.equal(element._calculateHasParent(changeId, relatedChanges),
-        false);
-
-    relatedChanges.push({change_id: 123});
-    assert.equal(element._calculateHasParent(changeId, relatedChanges),
-        false);
-
-    relatedChanges.push({change_id: 234});
-    assert.equal(element._calculateHasParent(changeId, relatedChanges),
-        true);
-  });
-
-  suite('hidden attribute and update event', () => {
-    const changes = [{
-      project: 'foo/bar',
-      change_id: 'Ideadbeef',
-      commit: {
-        commit: 'deadbeef',
-        parents: [{commit: 'abc123'}],
-        author: {},
-        subject: 'do that thing',
-      },
-      _change_number: 12345,
-      _revision_number: 1,
-      _current_revision_number: 1,
-      status: 'NEW',
-    }];
-
-    test('clear and empties', () => {
-      element._relatedResponse = {changes};
-      element._submittedTogether = {changes};
-      element._conflicts = changes;
-      element._cherryPicks = changes;
-      element._sameTopic = changes;
-
-      element.hidden = false;
-      element.clear();
-      assert.isTrue(element.hidden);
-      assert.equal(element._relatedResponse.changes.length, 0);
-      assert.equal(element._submittedTogether.changes.length, 0);
-      assert.equal(element._conflicts.length, 0);
-      assert.equal(element._cherryPicks.length, 0);
-      assert.equal(element._sameTopic.length, 0);
-    });
-
-    test('update fires', () => {
-      const updateHandler = sinon.stub();
-      element.addEventListener('update', updateHandler);
-
-      element._resultsChanged({}, {}, [], [], []);
-      assert.isTrue(element.hidden);
-      assert.isFalse(updateHandler.called);
-
-      element._resultsChanged({}, {}, [], [], ['test']);
-      assert.isFalse(element.hidden);
-      assert.isTrue(updateHandler.called);
-      updateHandler.reset();
-
-      element._resultsChanged(
-          {}, {changes: [], non_visible_changes: 0}, [], [], []);
-      assert.isTrue(element.hidden);
-      assert.isFalse(updateHandler.called);
-
-      element._resultsChanged(
-          {}, {changes: ['test'], non_visible_changes: 0}, [], [], []);
-      assert.isFalse(element.hidden);
-      assert.isTrue(updateHandler.called);
-      updateHandler.reset();
-
-      element._resultsChanged(
-          {}, {changes: [], non_visible_changes: 1}, [], [], []);
-      assert.isFalse(element.hidden);
-      assert.isTrue(updateHandler.called);
-    });
-
-    suite('hiding and unhiding', () => {
-      test('related response', () => {
-        assert.isTrue(element.hidden);
-        element._resultsChanged({changes}, {}, [], [], []);
-        assert.isFalse(element.hidden);
-      });
-
-      test('submitted together', () => {
-        assert.isTrue(element.hidden);
-        element._resultsChanged({}, {changes}, [], [], []);
-        assert.isFalse(element.hidden);
-      });
-
-      test('conflicts', () => {
-        assert.isTrue(element.hidden);
-        element._resultsChanged({}, {}, changes, [], []);
-        assert.isFalse(element.hidden);
-      });
-
-      test('cherrypicks', () => {
-        assert.isTrue(element.hidden);
-        element._resultsChanged({}, {}, [], changes, []);
-        assert.isFalse(element.hidden);
-      });
-
-      test('same topic', () => {
-        assert.isTrue(element.hidden);
-        element._resultsChanged({}, {}, [], [], changes);
-        assert.isFalse(element.hidden);
-      });
-    });
-  });
-
-  test('_computeChangeURL uses GerritNav', () => {
-    const getUrlStub = sinon.stub(GerritNav, 'getUrlForChangeById');
-    element._computeChangeURL(123, 'abc/def', 12);
-    assert.isTrue(getUrlStub.called);
-  });
-
-  suite('submitted together changes', () => {
-    const change = {
-      project: 'foo/bar',
-      change_id: 'Ideadbeef',
-      commit: {
-        commit: 'deadbeef',
-        parents: [{commit: 'abc123'}],
-        author: {},
-        subject: 'do that thing',
-      },
-      _change_number: 12345,
-      _revision_number: 1,
-      _current_revision_number: 1,
-      status: 'NEW',
-    };
-
-    test('_computeSubmittedTogetherClass', () => {
-      assert.strictEqual(
-          element._computeSubmittedTogetherClass(undefined),
-          'hidden');
-      assert.strictEqual(
-          element._computeSubmittedTogetherClass({changes: []}),
-          'hidden');
-      assert.strictEqual(
-          element._computeSubmittedTogetherClass({changes: [{}]}),
-          '');
-      assert.strictEqual(
-          element._computeSubmittedTogetherClass({
-            changes: [],
-            non_visible_changes: 0,
-          }),
-          'hidden');
-      assert.strictEqual(
-          element._computeSubmittedTogetherClass({
-            changes: [],
-            non_visible_changes: 1,
-          }),
-          '');
-      assert.strictEqual(
-          element._computeSubmittedTogetherClass({
-            changes: [{}],
-            non_visible_changes: 1,
-          }),
-          '');
-    });
-
-    test('no submitted together changes', () => {
-      flush();
-      assert.include(element.$.submittedTogether.className, 'hidden');
-    });
-
-    test('no non-visible submitted together changes', () => {
-      element._submittedTogether = {changes: [change]};
-      flush();
-      assert.notInclude(element.$.submittedTogether.className, 'hidden');
-      assert.isNull(element.shadowRoot
-          .querySelector('.note'));
-    });
-
-    test('no visible submitted together changes', () => {
-      // Technically this should never happen, but worth asserting the logic.
-      element._submittedTogether = {changes: [], non_visible_changes: 1};
-      flush();
-      assert.notInclude(element.$.submittedTogether.className, 'hidden');
-      assert.isNotNull(element.shadowRoot
-          .querySelector('.note'));
-      assert.strictEqual(
-          element.shadowRoot
-              .querySelector('.note').innerText.trim(),
-          '(+ 1 non-visible change)');
-    });
-
-    test('visible and non-visible submitted together changes', () => {
-      element._submittedTogether = {changes: [change], non_visible_changes: 2};
-      flush();
-      assert.notInclude(element.$.submittedTogether.className, 'hidden');
-      assert.isNotNull(element.shadowRoot
-          .querySelector('.note'));
-      assert.strictEqual(
-          element.shadowRoot
-              .querySelector('.note').innerText.trim(),
-          '(+ 2 non-visible changes)');
-    });
-  });
-});
-
-suite('gr-related-changes-list plugin tests', () => {
-  let element;
-
-  setup(() => {
-    resetPlugins();
-    element = basicFixture.instantiate();
-  });
-
-  teardown(() => {
-    resetPlugins();
-  });
-
-  test('endpoint params', done => {
-    element.change = {labels: {}};
-    let hookEl;
-    let plugin;
-    pluginApi.install(
-        p => {
-          plugin = p;
-          plugin.hook('related-changes-section').getLastAttached()
-              .then(el => hookEl = el);
-        },
-        '0.1',
-        'http://some/plugins/url1.html');
-    getPluginLoader().loadPlugins([]);
-    flush(() => {
-      assert.strictEqual(hookEl.plugin, plugin);
-      assert.strictEqual(hookEl.change, element.change);
-      done();
-    });
-  });
-
-  test('hiding and unhiding', done => {
-    element.change = {labels: {}};
-    let hookEl;
-    let plugin;
-
-    // No changes, and no plugin. The element is still hidden.
-    element._resultsChanged({}, {}, [], [], []);
-    assert.isTrue(element.hidden);
-    pluginApi.install(
-        p => {
-          plugin = p;
-          plugin.hook('related-changes-section').getLastAttached()
-              .then(el => hookEl = el);
-        },
-        '0.1',
-        'http://some/plugins/url2.html');
-    getPluginLoader().loadPlugins([]);
-    flush(() => {
-      // No changes, and plugin without hidden attribute. So it's visible.
-      element._resultsChanged({}, {}, [], [], []);
-      assert.isFalse(element.hidden);
-
-      // No changes, but plugin with true hidden attribute. So it's invisible.
-      hookEl.hidden = true;
-
-      element._resultsChanged({}, {}, [], [], []);
-      assert.isTrue(element.hidden);
-
-      // No changes, and plugin with false hidden attribute. So it's visible.
-      hookEl.hidden = false;
-      element._resultsChanged({}, {}, [], [], []);
-      assert.isFalse(element.hidden);
-
-      // Hiding triggered by plugin itself
-      hookEl.hidden = true;
-      hookEl.dispatchEvent(new CustomEvent('new-section-loaded', {
-        composed: true, bubbles: true,
-      }));
-      assert.isTrue(element.hidden);
-
-      // Unhiding triggered by plugin itself
-      hookEl.hidden = false;
-      hookEl.dispatchEvent(new CustomEvent('new-section-loaded', {
-        composed: true, bubbles: true,
-      }));
-      assert.isFalse(element.hidden);
-
-      // Hiding plugin keeps list visible, if there are changes
-      hookEl.hidden = false;
-      element._sameTopic = ['test'];
-      element._resultsChanged({}, {}, [], [], ['test']);
-      assert.isFalse(element.hidden);
-      hookEl.hidden = true;
-      hookEl.dispatchEvent(new CustomEvent('new-section-loaded', {
-        composed: true, bubbles: true,
-      }));
-      assert.isFalse(element.hidden);
-
-      done();
-    });
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
new file mode 100644
index 0000000..c4bfe77
--- /dev/null
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
@@ -0,0 +1,853 @@
+/**
+ * @license
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {ChangeStatus} from '../../../constants/constants';
+import '../../../test/common-test-setup-karma';
+import {
+  createChange,
+  createCommit,
+  createCommitInfoWithRequiredCommit,
+  createParsedChange,
+  createRelatedChangeAndCommitInfo,
+  createRevision,
+} from '../../../test/test-data-generators';
+import {
+  ChangeId,
+  ChangeInfo,
+  CommitId,
+  NumericChangeId,
+  PatchSetNum,
+  RelatedChangeAndCommitInfo,
+  RepoName,
+} from '../../../types/common';
+import {ParsedChangeInfo} from '../../../types/types';
+import './gr-related-changes-list';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation';
+import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader';
+import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit';
+import {
+  query,
+  queryAndAssert,
+  resetPlugins,
+  stubRestApi,
+} from '../../../test/test-utils';
+import {GrRelatedChangesList} from './gr-related-changes-list';
+import {SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+import {RestApiService} from '../../../services/gr-rest-api/gr-rest-api';
+import {PluginApi} from '../../../api/plugin';
+import {GrEndpointDecorator} from '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
+import {_testOnly_resetEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
+
+const pluginApi = _testOnly_initGerritPluginApi();
+
+const basicFixture = fixtureFromElement('gr-related-changes-list');
+
+suite('gr-related-changes-list tests', () => {
+  let element: GrRelatedChangesList;
+
+  setup(() => {
+    // Since pluginEndpoints are global, must reset state.
+    _testOnly_resetEndpoints();
+    element = basicFixture.instantiate();
+  });
+
+  test('connected revisions', () => {
+    const change: ParsedChangeInfo = {
+      ...createParsedChange(),
+      revisions: {
+        e3c6d60783bfdec9ebae7dcfec4662360433449e: createRevision(1),
+        '26e5e4c9c7ae31cbd876271cca281ce22b413997': createRevision(2),
+        bf7884d695296ca0c91702ba3e2bc8df0f69a907: createRevision(7),
+        b5fc49f2e67d1889d5275cac04ad3648f2ec7fe3: createRevision(5),
+        d6bcee67570859ccb684873a85cf50b1f0e96fda: createRevision(6),
+        cc960918a7f90388f4a9e05753d0f7b90ad44546: createRevision(3),
+        '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6': createRevision(4),
+      },
+    };
+    let patchNum = 7 as PatchSetNum;
+    let relatedChanges: RelatedChangeAndCommitInfo[] = [
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '2cebeedfb1e80f4b872d0a13ade529e70652c0c8'
+          ),
+          parents: [
+            {
+              commit: '87ed20b241576b620bbaa3dfd47715ce6782b7dd' as CommitId,
+              subject: 'subject1',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '87ed20b241576b620bbaa3dfd47715ce6782b7dd'
+          ),
+          parents: [
+            {
+              commit: '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb' as CommitId,
+              subject: 'subject2',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb'
+          ),
+          parents: [
+            {
+              commit: 'b0ccb183494a8e340b8725a2dc553967d61e6dae' as CommitId,
+              subject: 'subject3',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            'b0ccb183494a8e340b8725a2dc553967d61e6dae'
+          ),
+          parents: [
+            {
+              commit: 'bf7884d695296ca0c91702ba3e2bc8df0f69a907' as CommitId,
+              subject: 'subject4',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            'bf7884d695296ca0c91702ba3e2bc8df0f69a907'
+          ),
+          parents: [
+            {
+              commit: '613bc4f81741a559c6667ac08d71dcc3348f73ce' as CommitId,
+              subject: 'subject5',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '613bc4f81741a559c6667ac08d71dcc3348f73ce'
+          ),
+          parents: [
+            {
+              commit: '455ed9cd27a16bf6991f04dcc57ef575dc4d5e75' as CommitId,
+              subject: 'subject6',
+            },
+          ],
+        },
+      },
+    ];
+
+    let connectedChanges = element._computeConnectedRevisions(
+      change,
+      patchNum,
+      relatedChanges
+    );
+    assert.deepEqual(connectedChanges, [
+      '613bc4f81741a559c6667ac08d71dcc3348f73ce',
+      'bf7884d695296ca0c91702ba3e2bc8df0f69a907',
+      'bf7884d695296ca0c91702ba3e2bc8df0f69a907',
+      'b0ccb183494a8e340b8725a2dc553967d61e6dae',
+      '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb',
+      '87ed20b241576b620bbaa3dfd47715ce6782b7dd',
+      '2cebeedfb1e80f4b872d0a13ade529e70652c0c8',
+    ]);
+
+    patchNum = 4 as PatchSetNum;
+    relatedChanges = [
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '2cebeedfb1e80f4b872d0a13ade529e70652c0c8'
+          ),
+          parents: [
+            {
+              commit: '87ed20b241576b620bbaa3dfd47715ce6782b7dd' as CommitId,
+              subject: 'My parent commit',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '87ed20b241576b620bbaa3dfd47715ce6782b7dd'
+          ),
+          parents: [
+            {
+              commit: '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb' as CommitId,
+              subject: 'My parent commit',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '6c71f9e86ba955a7e01e2088bce0050a90eb9fbb'
+          ),
+          parents: [
+            {
+              commit: 'b0ccb183494a8e340b8725a2dc553967d61e6dae' as CommitId,
+              subject: 'My parent commit',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            'a3e5d9d4902b915a39e2efba5577211b9b3ebe7b'
+          ),
+          parents: [
+            {
+              commit: '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6' as CommitId,
+              subject: 'My parent commit',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6'
+          ),
+          parents: [
+            {
+              commit: 'af815dac54318826b7f1fa468acc76349ffc588e' as CommitId,
+              subject: 'My parent commit',
+            },
+          ],
+        },
+      },
+      {
+        ...createRelatedChangeAndCommitInfo(),
+        commit: {
+          ...createCommitInfoWithRequiredCommit(
+            'af815dac54318826b7f1fa468acc76349ffc588e'
+          ),
+          parents: [
+            {
+              commit: '58f76e406e24cb8b0f5d64c7f5ac1e8616d0a22c' as CommitId,
+              subject: 'My parent commit',
+            },
+          ],
+        },
+      },
+    ];
+
+    connectedChanges = element._computeConnectedRevisions(
+      change,
+      patchNum,
+      relatedChanges
+    );
+    assert.deepEqual(connectedChanges, [
+      'af815dac54318826b7f1fa468acc76349ffc588e',
+      '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6',
+      '9e593f6dcc2c0785a2ad2c895a34ad2aa9a0d8b6',
+      'a3e5d9d4902b915a39e2efba5577211b9b3ebe7b',
+    ]);
+  });
+
+  test('_changesEqual', () => {
+    const change1: ChangeInfo = {
+      ...createChange(),
+      change_id: '123' as ChangeId,
+      _number: 0 as NumericChangeId,
+    };
+    const change2: ChangeInfo = {
+      ...createChange(),
+      change_id: '456' as ChangeId,
+      _number: 1 as NumericChangeId,
+    };
+    const change3: ChangeInfo = {
+      ...createChange(),
+      change_id: '123' as ChangeId,
+      _number: 2 as NumericChangeId,
+    };
+    const change4: RelatedChangeAndCommitInfo = {
+      ...createRelatedChangeAndCommitInfo(),
+      change_id: '123' as ChangeId,
+      _change_number: 1 as NumericChangeId,
+    };
+
+    assert.isTrue(element._changesEqual(change1, change1));
+    assert.isFalse(element._changesEqual(change1, change2));
+    assert.isFalse(element._changesEqual(change1, change3));
+    assert.isTrue(element._changesEqual(change2, change4));
+  });
+
+  test('_getChangeNumber', () => {
+    const change1: ChangeInfo = {
+      ...createChange(),
+      change_id: '123' as ChangeId,
+      _number: 0 as NumericChangeId,
+    };
+    const change2: ChangeInfo = {
+      ...createChange(),
+      change_id: '456' as ChangeId,
+      _number: 1 as NumericChangeId,
+    };
+    assert.equal(element._getChangeNumber(change1), 0);
+    assert.equal(element._getChangeNumber(change2), 1);
+  });
+
+  test('event for section loaded fires for each section ', () => {
+    const loadedStub = sinon.stub();
+    element.patchNum = 7 as PatchSetNum;
+    element.change = {
+      ...createParsedChange(),
+      change_id: '123' as ChangeId,
+      status: ChangeStatus.NEW,
+    };
+    element.mergeable = true;
+    element.addEventListener('new-section-loaded', loadedStub);
+
+    return element.reload().then(() => {
+      assert.equal(loadedStub.callCount, 4);
+    });
+  });
+
+  suite('getChangeConflicts resolves undefined', () => {
+    let element: GrRelatedChangesList;
+
+    setup(() => {
+      element = basicFixture.instantiate();
+    });
+
+    test('_conflicts are an empty array', () => {
+      element.patchNum = 7 as PatchSetNum;
+      element.change = {
+        ...createParsedChange(),
+        change_id: '123' as ChangeId,
+        status: ChangeStatus.NEW,
+      };
+      element.mergeable = true;
+      element.reload();
+      assert.equal(element._conflicts.length, 0);
+    });
+  });
+
+  suite('get conflicts tests', () => {
+    let element: GrRelatedChangesList;
+    let conflictsStub: SinonStubbedMember<RestApiService['getChangeConflicts']>;
+
+    setup(() => {
+      element = basicFixture.instantiate();
+      conflictsStub = stubRestApi('getChangeConflicts').returns(
+        Promise.resolve(undefined)
+      );
+    });
+
+    test('request conflicts if open and mergeable', () => {
+      element.patchNum = 7 as PatchSetNum;
+      element.change = {
+        ...createParsedChange(),
+        change_id: '123' as ChangeId,
+        status: ChangeStatus.NEW,
+      };
+      element.mergeable = true;
+      element.reload();
+      assert.isTrue(conflictsStub.called);
+    });
+
+    test('does not request conflicts if closed and mergeable', () => {
+      element.patchNum = 7 as PatchSetNum;
+      element.change = {
+        ...createParsedChange(),
+        change_id: '123' as ChangeId,
+        status: ChangeStatus.NEW,
+      };
+      element.reload();
+      assert.isFalse(conflictsStub.called);
+    });
+
+    test('does not request conflicts if open and not mergeable', () => {
+      element.patchNum = 7 as PatchSetNum;
+      element.change = {
+        ...createParsedChange(),
+        change_id: '123' as ChangeId,
+        status: ChangeStatus.NEW,
+      };
+      element.mergeable = false;
+      element.reload();
+      assert.isFalse(conflictsStub.called);
+    });
+
+    test('doesnt request conflicts if closed and not mergeable', () => {
+      element.patchNum = 7 as PatchSetNum;
+      element.change = {
+        ...createParsedChange(),
+        change_id: '123' as ChangeId,
+        status: ChangeStatus.NEW,
+      };
+      element.mergeable = false;
+      element.reload();
+      assert.isFalse(conflictsStub.called);
+    });
+  });
+
+  test('_calculateHasParent', () => {
+    const changeId = '123' as ChangeId;
+    const relatedChanges: RelatedChangeAndCommitInfo[] = [];
+
+    assert.equal(element._calculateHasParent(changeId, relatedChanges), false);
+
+    relatedChanges.push({
+      ...createRelatedChangeAndCommitInfo(),
+      change_id: '123' as ChangeId,
+    });
+    assert.equal(element._calculateHasParent(changeId, relatedChanges), false);
+
+    relatedChanges.push({
+      ...createRelatedChangeAndCommitInfo(),
+      change_id: '234' as ChangeId,
+    });
+    assert.equal(element._calculateHasParent(changeId, relatedChanges), true);
+  });
+
+  suite('hidden attribute and update event', () => {
+    const changes: ChangeInfo[] = [
+      {
+        ...createChange(),
+        project: 'foo/bar' as RepoName,
+        change_id: 'Ideadbeef' as ChangeId,
+        status: ChangeStatus.NEW,
+      },
+    ];
+    const relatedChanges: RelatedChangeAndCommitInfo[] = [
+      {
+        ...createCommitInfoWithRequiredCommit(),
+        project: 'foo/bar' as RepoName,
+        change_id: 'Ideadbeef' as ChangeId,
+        commit: {
+          ...createCommit(),
+          commit: 'deadbeef' as CommitId,
+          parents: [
+            {
+              commit: 'abc123' as CommitId,
+              subject: 'abc123',
+            },
+          ],
+          subject: 'do that thing',
+        },
+        _change_number: 12345 as NumericChangeId,
+        _revision_number: 1,
+        _current_revision_number: 1,
+        status: ChangeStatus.NEW,
+      },
+    ];
+
+    test('clear and empties', () => {
+      element._relatedResponse = {changes: relatedChanges};
+      element._submittedTogether = {
+        changes,
+        non_visible_changes: 0,
+      };
+      element._conflicts = changes;
+      element._cherryPicks = changes;
+      element._sameTopic = changes;
+
+      element.hidden = false;
+      element.clear();
+      assert.isTrue(element.hidden);
+      assert.equal(element._relatedResponse.changes.length, 0);
+      assert.equal(element._submittedTogether?.changes.length, 0);
+      assert.equal(element._conflicts.length, 0);
+      assert.equal(element._cherryPicks.length, 0);
+      assert.equal(element._sameTopic?.length, 0);
+    });
+
+    test('update fires', () => {
+      const updateHandler = sinon.stub();
+      element.addEventListener('update', updateHandler);
+
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 0},
+        [],
+        [],
+        []
+      );
+      assert.isTrue(element.hidden);
+      assert.isFalse(updateHandler.called);
+
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 0},
+        [],
+        [],
+        changes
+      );
+      assert.isFalse(element.hidden);
+      assert.isTrue(updateHandler.called);
+      updateHandler.reset();
+
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 0},
+        [],
+        [],
+        []
+      );
+      assert.isTrue(element.hidden);
+      assert.isFalse(updateHandler.called);
+
+      element._resultsChanged(
+        {changes: []},
+        {changes, non_visible_changes: 0},
+        [],
+        [],
+        []
+      );
+      assert.isFalse(element.hidden);
+      assert.isTrue(updateHandler.called);
+      updateHandler.reset();
+
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 1},
+        [],
+        [],
+        []
+      );
+      assert.isFalse(element.hidden);
+      assert.isTrue(updateHandler.called);
+    });
+
+    suite('hiding and unhiding', () => {
+      test('related response', () => {
+        assert.isTrue(element.hidden);
+        element._resultsChanged(
+          {changes: relatedChanges},
+          {changes: [], non_visible_changes: 0},
+          [],
+          [],
+          []
+        );
+        assert.isFalse(element.hidden);
+      });
+
+      test('submitted together', () => {
+        assert.isTrue(element.hidden);
+        element._resultsChanged(
+          {changes: []},
+          {changes, non_visible_changes: 0},
+          [],
+          [],
+          []
+        );
+        assert.isFalse(element.hidden);
+      });
+
+      test('conflicts', () => {
+        assert.isTrue(element.hidden);
+        element._resultsChanged(
+          {changes: []},
+          {changes: [], non_visible_changes: 0},
+          changes,
+          [],
+          []
+        );
+        assert.isFalse(element.hidden);
+      });
+
+      test('cherrypicks', () => {
+        assert.isTrue(element.hidden);
+        element._resultsChanged(
+          {changes: []},
+          {changes: [], non_visible_changes: 0},
+          [],
+          changes,
+          []
+        );
+        assert.isFalse(element.hidden);
+      });
+
+      test('same topic', () => {
+        assert.isTrue(element.hidden);
+        element._resultsChanged(
+          {changes: []},
+          {changes: [], non_visible_changes: 0},
+          [],
+          [],
+          changes
+        );
+        assert.isFalse(element.hidden);
+      });
+    });
+  });
+
+  test('_computeChangeURL uses GerritNav', () => {
+    const getUrlStub = sinon.stub(GerritNav, 'getUrlForChangeById');
+    element._computeChangeURL(
+      123 as NumericChangeId,
+      'abc/def' as RepoName,
+      12 as PatchSetNum
+    );
+    assert.isTrue(getUrlStub.called);
+  });
+
+  suite('submitted together changes', () => {
+    const change: ChangeInfo = {
+      ...createChange(),
+      project: 'foo/bar' as RepoName,
+      change_id: 'Ideadbeef' as ChangeId,
+      status: ChangeStatus.NEW,
+    };
+
+    test('_computeSubmittedTogetherClass', () => {
+      assert.strictEqual(
+        element._computeSubmittedTogetherClass(undefined),
+        'hidden'
+      );
+      assert.strictEqual(
+        element._computeSubmittedTogetherClass({
+          changes: [],
+          non_visible_changes: 0,
+        }),
+        'hidden'
+      );
+      assert.strictEqual(
+        element._computeSubmittedTogetherClass({
+          changes: [change],
+          non_visible_changes: 0,
+        }),
+        ''
+      );
+      assert.strictEqual(
+        element._computeSubmittedTogetherClass({
+          changes: [],
+          non_visible_changes: 0,
+        }),
+        'hidden'
+      );
+      assert.strictEqual(
+        element._computeSubmittedTogetherClass({
+          changes: [],
+          non_visible_changes: 1,
+        }),
+        ''
+      );
+      assert.strictEqual(
+        element._computeSubmittedTogetherClass({
+          changes: [],
+          non_visible_changes: 1,
+        }),
+        ''
+      );
+    });
+
+    test('no submitted together changes', () => {
+      flush();
+      assert.include(element.$.submittedTogether.className, 'hidden');
+    });
+
+    test('no non-visible submitted together changes', () => {
+      element._submittedTogether = {changes: [change], non_visible_changes: 0};
+      flush();
+      assert.notInclude(element.$.submittedTogether.className, 'hidden');
+      assert.isUndefined(query(element, '.note'));
+    });
+
+    test('no visible submitted together changes', () => {
+      // Technically this should never happen, but worth asserting the logic.
+      element._submittedTogether = {changes: [], non_visible_changes: 1};
+      flush();
+      assert.notInclude(element.$.submittedTogether.className, 'hidden');
+      assert.strictEqual(
+        queryAndAssert<HTMLDivElement>(element, '.note').innerText.trim(),
+        '(+ 1 non-visible change)'
+      );
+    });
+
+    test('visible and non-visible submitted together changes', () => {
+      element._submittedTogether = {changes: [change], non_visible_changes: 2};
+      flush();
+      assert.notInclude(element.$.submittedTogether.className, 'hidden');
+      assert.strictEqual(
+        queryAndAssert<HTMLDivElement>(element, '.note').innerText.trim(),
+        '(+ 2 non-visible changes)'
+      );
+    });
+  });
+
+  suite('gr-related-changes-list plugin tests', () => {
+    let element: GrRelatedChangesList;
+
+    setup(() => {
+      resetPlugins();
+      element = basicFixture.instantiate();
+    });
+
+    teardown(() => {
+      resetPlugins();
+    });
+
+    test('endpoint params', done => {
+      element.change = {...createParsedChange(), labels: {}};
+      interface RelatedChangesListGrEndpointDecorator
+        extends GrEndpointDecorator {
+        plugin: PluginApi;
+        change: ParsedChangeInfo;
+      }
+      let hookEl: RelatedChangesListGrEndpointDecorator;
+      let plugin: PluginApi;
+      pluginApi.install(
+        p => {
+          plugin = p;
+          plugin
+            .hook('related-changes-section')
+            .getLastAttached()
+            .then(el => (hookEl = el as RelatedChangesListGrEndpointDecorator));
+        },
+        '0.1',
+        'http://some/plugins/url1.js'
+      );
+      getPluginLoader().loadPlugins([]);
+      flush(() => {
+        assert.strictEqual(hookEl.plugin, plugin);
+        assert.strictEqual(hookEl.change, element.change);
+        done();
+      });
+    });
+  });
+
+  test('hiding and unhiding', done => {
+    element.change = {...createParsedChange(), labels: {}};
+    let hookEl: HTMLElement;
+    let plugin;
+
+    // No changes, and no plugin. The element is still hidden.
+    element._resultsChanged(
+      {changes: []},
+      {changes: [], non_visible_changes: 0},
+      [],
+      [],
+      []
+    );
+    assert.isTrue(element.hidden);
+    pluginApi.install(
+      p => {
+        plugin = p;
+        plugin
+          .hook('related-changes-section')
+          .getLastAttached()
+          .then(el => (hookEl = el));
+      },
+      '0.1',
+      'http://some/plugins/url2.js'
+    );
+    getPluginLoader().loadPlugins([]);
+    flush(() => {
+      // No changes, and plugin without hidden attribute. So it's visible.
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 0},
+        [],
+        [],
+        []
+      );
+      assert.isFalse(element.hidden);
+
+      // No changes, but plugin with true hidden attribute. So it's invisible.
+      hookEl.hidden = true;
+
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 0},
+        [],
+        [],
+        []
+      );
+      assert.isTrue(element.hidden);
+
+      // No changes, and plugin with false hidden attribute. So it's visible.
+      hookEl.hidden = false;
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 0},
+        [],
+        [],
+        []
+      );
+      assert.isFalse(element.hidden);
+
+      // Hiding triggered by plugin itself
+      hookEl.hidden = true;
+      hookEl.dispatchEvent(
+        new CustomEvent('new-section-loaded', {
+          composed: true,
+          bubbles: true,
+        })
+      );
+      assert.isTrue(element.hidden);
+
+      // Unhiding triggered by plugin itself
+      hookEl.hidden = false;
+      hookEl.dispatchEvent(
+        new CustomEvent('new-section-loaded', {
+          composed: true,
+          bubbles: true,
+        })
+      );
+      assert.isFalse(element.hidden);
+
+      // Hiding plugin keeps list visible, if there are changes
+      hookEl.hidden = false;
+      const change = createChange();
+      element._sameTopic = [change];
+      element._resultsChanged(
+        {changes: []},
+        {changes: [], non_visible_changes: 0},
+        [],
+        [],
+        [change]
+      );
+      assert.isFalse(element.hidden);
+      hookEl.hidden = true;
+      hookEl.dispatchEvent(
+        new CustomEvent('new-section-loaded', {
+          composed: true,
+          bubbles: true,
+        })
+      );
+      assert.isFalse(element.hidden);
+
+      done();
+    });
+  });
+});
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js
index 686714e..5f35fd3 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js
@@ -16,12 +16,10 @@
  */
 
 import '../../../test/common-test-setup-karma.js';
-import {resetPlugins} from '../../../test/test-utils.js';
+import {resetPlugins, stubRestApi} from '../../../test/test-utils.js';
 import './gr-reply-dialog.js';
-import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
 import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
 import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
-import {stubRestApi} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-reply-dialog');
 const pluginApi = _testOnly_initGerritPluginApi();
@@ -105,7 +103,7 @@
     assert.isTrue(sendStub.called);
   });
 
-  test('lgtm plugin', done => {
+  test('lgtm plugin', async () => {
     resetPlugins();
     pluginApi.install(plugin => {
       const replyApi = plugin.changeReply();
@@ -122,20 +120,17 @@
     element = basicFixture.instantiate();
     setupElement(element);
     getPluginLoader().loadPlugins([]);
-    getPluginLoader().awaitPluginsLoaded()
-        .then(() => {
-          flush(() => {
-            const textarea = element.$.textarea.getNativeTextarea();
-            textarea.value = 'LGTM';
-            textarea.dispatchEvent(new CustomEvent(
-                'input', {bubbles: true, composed: true}));
-            const labelScoreRows = dom(element.$.labelScores.root)
-                .querySelector('gr-label-score-row[name="Code-Review"]');
-            const selectedBtn = dom(labelScoreRows.root)
-                .querySelector('gr-button[data-value="+1"].iron-selected');
-            assert.isOk(selectedBtn);
-            done();
-          });
-        });
+    await getPluginLoader().awaitPluginsLoaded();
+    await flush();
+    const textarea = element.$.textarea.getNativeTextarea();
+    textarea.value = 'LGTM';
+    textarea.dispatchEvent(new CustomEvent(
+        'input', {bubbles: true, composed: true}));
+    await flush();
+    const labelScoreRows = element.$.labelScores.shadowRoot
+        .querySelector('gr-label-score-row[name="Code-Review"]');
+    const selectedBtn = labelScoreRows.shadowRoot
+        .querySelector('gr-button[data-value="+1"].iron-selected');
+    assert.isOk(selectedBtn);
   });
 });
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
index 1175b1d..e0e2e46 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
@@ -21,12 +21,10 @@
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-formatted-text/gr-formatted-text';
 import '../../shared/gr-overlay/gr-overlay';
-import '../../shared/gr-storage/gr-storage';
 import '../../shared/gr-account-list/gr-account-list';
 import '../gr-label-scores/gr-label-scores';
 import '../gr-thread-list/gr-thread-list';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-reply-dialog_html';
 import {
@@ -95,21 +93,26 @@
   assertNever,
   containsAll,
 } from '../../../utils/common-util';
-import {CommentThread} from '../../../utils/comment-util';
+import {CommentThread, isUnresolved} from '../../../utils/comment-util';
 import {GrTextarea} from '../../shared/gr-textarea/gr-textarea';
 import {GrAccountChip} from '../../shared/gr-account-chip/gr-account-chip';
 import {GrOverlay} from '../../shared/gr-overlay/gr-overlay';
-import {GrStorage, StorageLocation} from '../../shared/gr-storage/gr-storage';
 import {isAttentionSetEnabled} from '../../../utils/attention-set-util';
 import {
   CODE_REVIEW,
   getApprovalInfo,
   getMaxAccounts,
 } from '../../../utils/label-util';
-import {isUnresolved} from '../../../utils/comment-util';
 import {pluralize} from '../../../utils/string-util';
-import {fireAlert, fireEvent, fireServerError} from '../../../utils/event-util';
+import {
+  fireAlert,
+  fireEvent,
+  fireIronAnnounce,
+  fireServerError,
+} from '../../../utils/event-util';
 import {ErrorCallback} from '../../../api/rest';
+import {debounce, DelayedTask} from '../../../utils/async-util';
+import {StorageLocation} from '../../../services/storage/gr-storage';
 
 const STORAGE_DEBOUNCE_INTERVAL_MS = 400;
 
@@ -168,12 +171,8 @@
   };
 }
 
-const DEBOUNCER_STORE = 'store';
-
 @customElement('gr-reply-dialog')
-export class GrReplyDialog extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrReplyDialog extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -374,10 +373,12 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  private readonly storage = new GrStorage();
+  private readonly storage = appContext.storageService;
 
   private readonly jsAPI = appContext.jsApiService;
 
+  private storeTask?: DelayedTask;
+
   get keyBindings() {
     return {
       esc: '_handleEscKey',
@@ -394,8 +395,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     ((IronA11yAnnouncer as unknown) as FixIronA11yAnnouncer).requestAvailability();
     this._getAccount().then(account => {
       if (account) this._account = account;
@@ -428,8 +429,9 @@
   }
 
   /** @override */
-  detached() {
-    this.cancelDebouncer(DEBOUNCER_STORE);
+  disconnectedCallback() {
+    this.storeTask?.cancel();
+    super.disconnectedCallback();
   }
 
   open(focusTarget?: FocusTarget) {
@@ -731,7 +733,7 @@
             bubbles: false,
           })
         );
-        this.fire('iron-announce', {text: 'Reply sent'}, {bubbles: true});
+        fireIronAnnounce(this, 'Reply sent');
         return accountAdditions;
       })
       .then(result => {
@@ -751,13 +753,13 @@
     }
     if (section === FocusTarget.BODY) {
       const textarea = this.$.textarea;
-      textarea.async(() => textarea.getNativeTextarea().focus());
+      setTimeout(() => textarea.getNativeTextarea().focus());
     } else if (section === FocusTarget.REVIEWERS) {
       const reviewerEntry = this.$.reviewers.focusStart;
-      reviewerEntry.async(() => reviewerEntry.focus());
+      setTimeout(() => reviewerEntry.focus());
     } else if (section === FocusTarget.CCS) {
       const ccEntry = this.$.ccs.focusStart;
-      ccEntry.async(() => ccEntry.focus());
+      setTimeout(() => ccEntry.focus());
     }
   }
 
@@ -1338,8 +1340,8 @@
   }
 
   _draftChanged(newDraft: string, oldDraft?: string) {
-    this.debounce(
-      DEBOUNCER_STORE,
+    this.storeTask = debounce(
+      this.storeTask,
       () => {
         if (!newDraft.length && oldDraft) {
           // If the draft has been modified to be empty, then erase the storage
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js
index 466f7bd..c1e2564 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js
@@ -18,7 +18,7 @@
 import '../../../test/common-test-setup-karma.js';
 import {IronOverlayManager} from '@polymer/iron-overlay-behavior/iron-overlay-manager.js';
 import './gr-reply-dialog.js';
-import {mockPromise} from '../../../test/test-utils.js';
+import {mockPromise, stubStorage} from '../../../test/test-utils.js';
 import {SpecialFilePath} from '../../../constants/constants.js';
 import {appContext} from '../../../services/app-context.js';
 import {addListenerForTest} from '../../../test/test-utils.js';
@@ -113,9 +113,9 @@
       ],
     };
 
-    getDraftCommentStub = sinon.stub(element.storage, 'getDraftComment');
-    setDraftCommentStub = sinon.stub(element.storage, 'setDraftComment');
-    eraseDraftCommentStub = sinon.stub(element.storage, 'eraseDraftComment');
+    getDraftCommentStub = stubStorage('getDraftComment');
+    setDraftCommentStub = stubStorage('setDraftComment');
+    eraseDraftCommentStub = stubStorage('eraseDraftComment');
 
     // sinon.stub(patchSetUtilMockProxy, 'fetchChangeUpdates')
     //     .returns(Promise.resolve({isLatest: true}));
@@ -609,7 +609,7 @@
     return false;
   }
 
-  function testConfirmationDialog(done, cc) {
+  async function testConfirmationDialog(cc) {
     const yesButton = element
         .shadowRoot
         .querySelector('.reviewerConfirmationButtons gr-button:first-child');
@@ -651,95 +651,90 @@
           element._pendingConfirmationDetails);
     }
 
-    observer
-        .then(() => {
-          assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
-          observer = overlayObserver('closed');
-          const expected = 'Group name has 10 members';
-          assert.notEqual(
-              element.$.reviewerConfirmationOverlay.innerText
-                  .indexOf(expected),
-              -1);
-          MockInteractions.tap(noButton); // close the overlay
-          return observer;
-        }).then(() => {
-          assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
+    await observer;
+    assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
+    observer = overlayObserver('closed');
+    const expected = 'Group name has 10 members';
+    assert.notEqual(
+        element.$.reviewerConfirmationOverlay.innerText
+            .indexOf(expected),
+        -1);
+    MockInteractions.tap(noButton); // close the overlay
 
-          // We should be focused on account entry input.
-          assert.isTrue(
-              isFocusInsideElement(
-                  element.$.reviewers.$.entry.$.input.$.input
-              )
-          );
+    await observer;
+    assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
 
-          // No reviewer/CC should have been added.
-          assert.equal(element.$.ccs.additions().length, 0);
-          assert.equal(element.$.reviewers.additions().length, 0);
+    // We should be focused on account entry input.
+    assert.isTrue(
+        isFocusInsideElement(
+            element.$.reviewers.$.entry.$.input.$.input
+        )
+    );
 
-          // Reopen confirmation dialog.
-          observer = overlayObserver('opened');
-          if (cc) {
-            element._ccPendingConfirmation = {
-              group,
-              count: 10,
-            };
-          } else {
-            element._reviewerPendingConfirmation = {
-              group,
-              count: 10,
-            };
-          }
-          return observer;
-        })
-        .then(() => {
-          assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
-          observer = overlayObserver('closed');
-          MockInteractions.tap(yesButton); // Confirm the group.
-          return observer;
-        })
-        .then(() => {
-          assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
-          const additions = cc ?
-            element.$.ccs.additions() :
-            element.$.reviewers.additions();
-          assert.deepEqual(
-              additions,
-              [
-                {
-                  group: {
-                    id: 'id',
-                    name: 'name',
-                    confirmed: true,
-                    _group: true,
-                    _pendingAdd: true,
-                  },
-                },
-              ]);
+    // No reviewer/CC should have been added.
+    assert.equal(element.$.ccs.additions().length, 0);
+    assert.equal(element.$.reviewers.additions().length, 0);
 
-          // We should be focused on account entry input.
-          if (cc) {
-            assert.isTrue(
-                isFocusInsideElement(
-                    element.$.ccs.$.entry.$.input.$.input
-                )
-            );
-          } else {
-            assert.isTrue(
-                isFocusInsideElement(
-                    element.$.reviewers.$.entry.$.input.$.input
-                )
-            );
-          }
-        })
-        .then(done);
+    // Reopen confirmation dialog.
+    observer = overlayObserver('opened');
+    if (cc) {
+      element._ccPendingConfirmation = {
+        group,
+        count: 10,
+      };
+    } else {
+      element._reviewerPendingConfirmation = {
+        group,
+        count: 10,
+      };
+    }
+
+    await observer;
+    assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
+    observer = overlayObserver('closed');
+    MockInteractions.tap(yesButton); // Confirm the group.
+
+    await observer;
+    assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
+    const additions = cc ?
+      element.$.ccs.additions() :
+      element.$.reviewers.additions();
+    assert.deepEqual(
+        additions,
+        [
+          {
+            group: {
+              id: 'id',
+              name: 'name',
+              confirmed: true,
+              _group: true,
+              _pendingAdd: true,
+            },
+          },
+        ]);
+
+    // We should be focused on account entry input.
+    if (cc) {
+      assert.isTrue(
+          isFocusInsideElement(
+              element.$.ccs.$.entry.$.input.$.input
+          )
+      );
+    } else {
+      assert.isTrue(
+          isFocusInsideElement(
+              element.$.reviewers.$.entry.$.input.$.input
+          )
+      );
+    }
   }
 
-  test('cc confirmation', done => {
-    testConfirmationDialog(done, true);
+  test('cc confirmation', async () => {
+    testConfirmationDialog(true);
   });
 
-  test('reviewer confirmation', done => {
-    testConfirmationDialog(done, false);
+  test('reviewer confirmation', async () => {
+    testConfirmationDialog(false);
   });
 
   test('_getStorageLocation', () => {
@@ -801,12 +796,12 @@
     const location = element._getStorageLocation();
 
     element.draft = firstEdit;
-    element.flushDebouncer('store');
+    element.storeTask.flush();
 
     assert.isTrue(setDraftCommentStub.calledWith(location, firstEdit));
 
     element.draft = '';
-    element.flushDebouncer('store');
+    element.storeTask.flush();
 
     assert.isTrue(eraseDraftCommentStub.calledWith(location));
   });
@@ -887,42 +882,37 @@
     assert.isFalse(filter({group: cc2}));
   });
 
-  test('_focusOn', () => {
+  test('_focusOn', async () => {
     sinon.spy(element, '_chooseFocusTarget');
-    flush();
-    const textareaStub = sinon.stub(element.$.textarea, 'async');
-    const reviewerEntryStub = sinon.stub(element.$.reviewers.focusStart,
-        'async');
-    const ccStub = sinon.stub(element.$.ccs.focusStart, 'async');
     element._focusOn();
+    await flush();
     assert.equal(element._chooseFocusTarget.callCount, 1);
-    assert.deepEqual(textareaStub.callCount, 1);
-    assert.deepEqual(reviewerEntryStub.callCount, 0);
-    assert.deepEqual(ccStub.callCount, 0);
+    assert.equal(element.shadowRoot.activeElement.tagName, 'GR-TEXTAREA');
+    assert.equal(element.shadowRoot.activeElement.id, 'textarea');
 
     element._focusOn(element.FocusTarget.ANY);
+    await flush();
     assert.equal(element._chooseFocusTarget.callCount, 2);
-    assert.deepEqual(textareaStub.callCount, 2);
-    assert.deepEqual(reviewerEntryStub.callCount, 0);
-    assert.deepEqual(ccStub.callCount, 0);
+    assert.equal(element.shadowRoot.activeElement.tagName, 'GR-TEXTAREA');
+    assert.equal(element.shadowRoot.activeElement.id, 'textarea');
 
     element._focusOn(element.FocusTarget.BODY);
+    await flush();
     assert.equal(element._chooseFocusTarget.callCount, 2);
-    assert.deepEqual(textareaStub.callCount, 3);
-    assert.deepEqual(reviewerEntryStub.callCount, 0);
-    assert.deepEqual(ccStub.callCount, 0);
+    assert.equal(element.shadowRoot.activeElement.tagName, 'GR-TEXTAREA');
+    assert.equal(element.shadowRoot.activeElement.id, 'textarea');
 
     element._focusOn(element.FocusTarget.REVIEWERS);
+    await flush();
     assert.equal(element._chooseFocusTarget.callCount, 2);
-    assert.deepEqual(textareaStub.callCount, 3);
-    assert.deepEqual(reviewerEntryStub.callCount, 1);
-    assert.deepEqual(ccStub.callCount, 0);
+    assert.equal(element.shadowRoot.activeElement.tagName, 'GR-ACCOUNT-LIST');
+    assert.equal(element.shadowRoot.activeElement.id, 'reviewers');
 
     element._focusOn(element.FocusTarget.CCS);
+    await flush();
     assert.equal(element._chooseFocusTarget.callCount, 2);
-    assert.deepEqual(textareaStub.callCount, 3);
-    assert.deepEqual(reviewerEntryStub.callCount, 1);
-    assert.deepEqual(ccStub.callCount, 1);
+    assert.equal(element.shadowRoot.activeElement.tagName, 'GR-ACCOUNT-LIST');
+    assert.equal(element.shadowRoot.activeElement.id, 'ccs');
   });
 
   test('_chooseFocusTarget', () => {
diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.ts b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.ts
index ec895d9..817dc93 100644
--- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.ts
@@ -18,7 +18,6 @@
 import '../../shared/gr-button/gr-button';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-reviewer-list_html';
 import {isServiceUser} from '../../../utils/account-util';
@@ -44,7 +43,7 @@
 import {KnownExperimentId} from '../../../services/flags/flags';
 
 @customElement('gr-reviewer-list')
-export class GrReviewerList extends LegacyElementMixin(PolymerElement) {
+export class GrReviewerList extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts
index b7592b0..1cedf55 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts
@@ -18,7 +18,6 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-comment-thread/gr-comment-thread';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-thread-list_html';
 import {parseDate} from '../../../utils/date-util';
@@ -56,7 +55,7 @@
 }
 
 @customElement('gr-thread-list')
-export class GrThreadList extends LegacyElementMixin(PolymerElement) {
+export class GrThreadList extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts
index 8b1ba25..382e17c 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts
@@ -71,6 +71,9 @@
       padding-left: 8px;
       margin-right: 16px;
     }
+    .partypopper{
+      margin-right: var(--spacing-s);
+    }
   </style>
   <template is="dom-if" if="[[!hideToggleButtons]]">
     <div class="header">
@@ -79,7 +82,7 @@
           <paper-toggle-button
             id="unresolvedToggle"
             checked="{{!unresolvedOnly}}"
-            on-tap="_onTapUnresolvedToggle"
+            on-click="_onTapUnresolvedToggle"
             >All comments</paper-toggle-button
           >
         </div>
@@ -89,7 +92,7 @@
           <paper-toggle-button
             id="draftToggle"
             checked="{{_draftsOnly}}"
-            on-tap="_onTapUnresolvedToggle"
+            on-click="_onTapUnresolvedToggle"
             >Comments with drafts</paper-toggle-button
           >
         </div>
@@ -139,7 +142,7 @@
       <div>
         <span>
           <template is="dom-if" if="[[_showPartyPopper(threads)]]">
-            <span> \&#x1F389 </span>
+            <span class="partypopper">\&#x1F389</span>
           </template>
           [[_computeEmptyThreadsMessage(threads, _displayedThreads,
           unresolvedOnly)]]
diff --git a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.ts b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.ts
index d26ae53..bfc2bdf 100644
--- a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.ts
@@ -17,7 +17,6 @@
 import '../../shared/gr-dialog/gr-dialog';
 import '../../shared/gr-shell-command/gr-shell-command';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-upload-help-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -31,7 +30,7 @@
 const PREFERRED_FETCH_COMMAND_ORDER = ['checkout', 'cherry pick', 'pull'];
 
 @customElement('gr-upload-help-dialog')
-export class GrUploadHelpDialog extends LegacyElementMixin(PolymerElement) {
+export class GrUploadHelpDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -66,8 +65,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.restApiService
       .getLoggedIn()
       .then(loggedIn =>
diff --git a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog_html.ts b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog_html.ts
index d44cbb0..d633de5 100644
--- a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog_html.ts
@@ -43,7 +43,10 @@
             the files.
           </p>
           <template is="dom-if" if="[[_fetchCommand]]">
-            <gr-shell-command command="[[_fetchCommand]]"></gr-shell-command>
+            <gr-shell-command
+              class="fetch-command"
+              command="[[_fetchCommand]]"
+            ></gr-shell-command>
           </template>
         </li>
         <li>
@@ -51,14 +54,20 @@
             Update the local commit with your modifications using the following
             command.
           </p>
-          <gr-shell-command command="[[_commitCommand]]"></gr-shell-command>
+          <gr-shell-command
+            class="commit-command"
+            command="[[_commitCommand]]"
+          ></gr-shell-command>
           <p>
             Leave the "Change-Id:" line of the commit message as is.
           </p>
         </li>
         <li>
           <p>Push the updated commit to Gerrit.</p>
-          <gr-shell-command command="[[_pushCommand]]"></gr-shell-command>
+          <gr-shell-command
+            class="push-command"
+            command="[[_pushCommand]]"
+          ></gr-shell-command>
         </li>
         <li>
           <p>Refresh this page to view the the update.</p>
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-results.ts b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
index bf37e20..fb8a149 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-results.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
@@ -284,11 +284,11 @@
       <gr-endpoint-decorator name="check-result-expanded">
         <gr-endpoint-param
           name="run"
-          value="${this.result}"
+          .value="${this.result}"
         ></gr-endpoint-param>
         <gr-endpoint-param
           name="result"
-          value="${this.result}"
+          .value="${this.result}"
         ></gr-endpoint-param>
         <div class="message">
           ${this.result.message}
diff --git a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts
index 33c95db..198f1d9 100644
--- a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts
+++ b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts
@@ -18,7 +18,6 @@
 import '../../shared/gr-dropdown/gr-dropdown';
 import '../../../styles/shared-styles';
 import '../../shared/gr-avatar/gr-avatar';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-account-dropdown_html';
 import {getUserName} from '../../../utils/display-name-util';
@@ -36,7 +35,7 @@
 }
 
 @customElement('gr-account-dropdown')
-export class GrAccountDropdown extends LegacyElementMixin(PolymerElement) {
+export class GrAccountDropdown extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -65,10 +64,10 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
-    this._handleLocationChange();
-    this.listen(window, 'location-change', '_handleLocationChange');
+  connectedCallback() {
+    super.connectedCallback();
+    this.handleLocationChange();
+    window.addEventListener('location-change', this.handleLocationChange);
     this.restApiService.getConfig().then(cfg => {
       this.config = cfg;
 
@@ -82,9 +81,9 @@
   }
 
   /** @override */
-  detached() {
-    super.detached();
-    this.unlisten(window, 'location-change', '_handleLocationChange');
+  disconnectedCallback() {
+    window.removeEventListener('location-change', this.handleLocationChange);
+    super.disconnectedCallback();
   }
 
   _getLinks(switchAccountUrl: string, path: string) {
@@ -116,10 +115,10 @@
     fireEvent(this, 'show-keyboard-shortcuts');
   }
 
-  _handleLocationChange() {
+  private readonly handleLocationChange = () => {
     this._path =
       window.location.pathname + window.location.search + window.location.hash;
-  }
+  };
 
   _interpolateUrl(url: string, replacements: {[key: string]: string}) {
     return url.replace(
diff --git a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.ts b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.ts
index 181e132..63b5bc8 100644
--- a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.ts
+++ b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.ts
@@ -16,7 +16,6 @@
  */
 import '../../shared/gr-dialog/gr-dialog';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-error-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -28,7 +27,7 @@
 }
 
 @customElement('gr-error-dialog')
-export class GrErrorDialog extends LegacyElementMixin(PolymerElement) {
+export class GrErrorDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.js b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.ts
similarity index 63%
rename from polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.js
rename to polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.ts
index ea8f7c5..fa57a23 100644
--- a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.js
+++ b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.ts
@@ -15,21 +15,25 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import './gr-error-dialog.js';
+import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
+import '../../../test/common-test-setup-karma';
+import {queryAndAssert} from '../../../test/test-utils';
+import {GrDialog} from '../../shared/gr-dialog/gr-dialog';
+import {GrErrorDialog} from './gr-error-dialog';
 
 const basicFixture = fixtureFromElement('gr-error-dialog');
 
 suite('gr-error-dialog tests', () => {
-  let element;
+  let element: GrErrorDialog;
 
   setup(() => {
     element = basicFixture.instantiate();
   });
 
   test('dismiss tap fires event', done => {
-    element.addEventListener('dismiss', () => { done(); });
-    MockInteractions.tap(element.$.dialog.$.confirm);
+    element.addEventListener('dismiss', () => done());
+    MockInteractions.tap(
+      (queryAndAssert(element, '#dialog') as GrDialog).$.confirm
+    );
   });
 });
-
diff --git a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts
index 4aad50d..4985c1b 100644
--- a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts
+++ b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts
@@ -19,7 +19,6 @@
 import '../gr-error-dialog/gr-error-dialog';
 import '../../shared/gr-alert/gr-alert';
 import '../../shared/gr-overlay/gr-overlay';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-error-manager_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -31,13 +30,16 @@
 import {GrAlert} from '../../shared/gr-alert/gr-alert';
 import {ErrorType, FixIronA11yAnnouncer} from '../../../types/types';
 import {AccountId} from '../../../types/common';
-import {EventType} from '../../../utils/event-util';
 import {
+  EventType,
   NetworkErrorEvent,
   ServerErrorEvent,
-  ShowAlertEvent,
+  ShowAlertEventDetail,
+  ShowErrorEvent,
 } from '../../../types/events';
 import {windowLocationReload} from '../../../utils/dom-util';
+import {debounce, DelayedTask} from '../../../utils/async-util';
+import {fireIronAnnounce} from '../../../utils/event-util';
 
 const HIDE_ALERT_TIMEOUT_MS = 5000;
 const CHECK_SIGN_IN_INTERVAL_MS = 60 * 1000;
@@ -73,10 +75,8 @@
   };
 }
 
-const DEBOUNCER_CHECK_LOGGED_IN = 'checkLoggedIn';
-
 @customElement('gr-error-manager')
-export class GrErrorManager extends LegacyElementMixin(PolymerElement) {
+export class GrErrorManager extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -116,16 +116,18 @@
 
   private readonly restApiService = appContext.restApiService;
 
+  private checkLoggedInTask?: DelayedTask;
+
   /** @override */
-  attached() {
-    super.attached();
-    this.listen(document, EventType.SERVER_ERROR, '_handleServerError');
-    this.listen(document, EventType.NETWORK_ERROR, '_handleNetworkError');
-    this.listen(document, EventType.SHOW_ALERT, '_handleShowAlert');
-    this.listen(document, 'hide-alert', '_hideAlert');
-    this.listen(document, 'show-error', '_handleShowErrorDialog');
-    this.listen(document, 'visibilitychange', '_handleVisibilityChange');
-    this.listen(document, 'show-auth-required', '_handleAuthRequired');
+  connectedCallback() {
+    super.connectedCallback();
+    document.addEventListener(EventType.SERVER_ERROR, this.handleServerError);
+    document.addEventListener(EventType.NETWORK_ERROR, this.handleNetworkError);
+    document.addEventListener(EventType.SHOW_ALERT, this.handleShowAlert);
+    document.addEventListener('hide-alert', this.hideAlert);
+    document.addEventListener('show-error', this.handleShowErrorDialog);
+    document.addEventListener('visibilitychange', this.handleVisibilityChange);
+    document.addEventListener('show-auth-required', this.handleAuthRequired);
 
     this._authErrorHandlerDeregistrationHook = this.eventEmitter.on(
       'auth-error',
@@ -138,33 +140,42 @@
   }
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     this._clearHideAlertHandle();
-    this.unlisten(document, EventType.SERVER_ERROR, '_handleServerError');
-    this.unlisten(document, EventType.NETWORK_ERROR, '_handleNetworkError');
-    this.unlisten(document, EventType.SHOW_ALERT, '_handleShowAlert');
-    this.unlisten(document, 'hide-alert', '_hideAlert');
-    this.unlisten(document, 'show-error', '_handleShowErrorDialog');
-    this.unlisten(document, 'visibilitychange', '_handleVisibilityChange');
-    this.unlisten(document, 'show-auth-required', '_handleAuthRequired');
-    this.cancelDebouncer(DEBOUNCER_CHECK_LOGGED_IN);
+    document.removeEventListener(
+      EventType.SERVER_ERROR,
+      this.handleServerError
+    );
+    document.removeEventListener(
+      EventType.NETWORK_ERROR,
+      this.handleNetworkError
+    );
+    document.removeEventListener(EventType.SHOW_ALERT, this.handleShowAlert);
+    document.removeEventListener('hide-alert', this.hideAlert);
+    document.removeEventListener('show-error', this.handleShowErrorDialog);
+    document.removeEventListener(
+      'visibilitychange',
+      this.handleVisibilityChange
+    );
+    document.removeEventListener('show-auth-required', this.handleAuthRequired);
+    this.checkLoggedInTask?.cancel();
 
     if (this._authErrorHandlerDeregistrationHook) {
       this._authErrorHandlerDeregistrationHook();
     }
+    super.disconnectedCallback();
   }
 
   _shouldSuppressError(msg: string) {
     return msg.includes(TOO_MANY_FILES);
   }
 
-  _handleAuthRequired() {
+  private readonly handleAuthRequired = () => {
     this._showAuthErrorAlert(
       'Log in is required to perform that action.',
       'Log in.'
     );
-  }
+  };
 
   _handleAuthError(msg: string, action: string) {
     this.$.noInteractionOverlay.open().then(() => {
@@ -172,7 +183,7 @@
     });
   }
 
-  _handleServerError(e: ServerErrorEvent) {
+  private readonly handleServerError = (e: ServerErrorEvent) => {
     const {request, response} = e.detail;
     response.text().then(errorText => {
       const url = request && (request.anonymizedUrl || request.url);
@@ -184,7 +195,7 @@
       ) {
         // if not authed previously, this is trying to access auth required APIs
         // show auth required alert
-        this._handleAuthRequired();
+        this.handleAuthRequired();
       } else if (
         response.status === 403 &&
         this._authService.isAuthed &&
@@ -220,7 +231,7 @@
       }
       console.info(`server error: ${errorText}`);
     });
-  }
+  };
 
   _showNotFoundMessageWithTip({
     status,
@@ -280,7 +291,7 @@
     return err;
   }
 
-  _handleShowAlert(e: ShowAlertEvent) {
+  private readonly handleShowAlert = (e: CustomEvent<ShowAlertEventDetail>) => {
     this._showAlert(
       e.detail.message,
       e.detail.action,
@@ -289,12 +300,12 @@
       undefined,
       e.detail.showDismiss
     );
-  }
+  };
 
-  _handleNetworkError(e: NetworkErrorEvent) {
+  private readonly handleNetworkError = (e: NetworkErrorEvent) => {
     this._showAlert('Server unavailable');
     console.error(e.detail.error.message);
-  }
+  };
 
   // TODO(dhruvsr): allow less priority alerts to override high priority alerts
   // In some use cases we may want generic alerts to show along/over errors
@@ -313,27 +324,27 @@
     if (this._alertElement) {
       // check priority before hiding
       if (!this._canOverride(type, this._alertElement.type)) return;
-      this._hideAlert();
+      this.hideAlert();
     }
 
     this._clearHideAlertHandle();
     if (dismissOnNavigation) {
       // Persist alert until navigation.
-      this.listen(document, 'location-change', '_hideAlert');
+      document.addEventListener('location-change', this.hideAlert);
     } else {
-      this._hideAlertHandle = this.async(
-        this._hideAlert,
+      this._hideAlertHandle = window.setTimeout(
+        this.hideAlert,
         HIDE_ALERT_TIMEOUT_MS
       );
     }
     const el = this._createToastAlert(showDismiss);
     el.show(text, actionText, actionCallback);
     this._alertElement = el;
-    this.fire('iron-announce', {text: `Alert: ${text}`}, {bubbles: true});
+    fireIronAnnounce(this, `Alert: ${text}`);
     this.reporting.reportInteraction('show-alert', {text});
   }
 
-  _hideAlert() {
+  private readonly hideAlert = () => {
     if (!this._alertElement) {
       return;
     }
@@ -342,12 +353,12 @@
     this._alertElement = null;
 
     // Remove listener for page navigation, if it exists.
-    this.unlisten(document, 'location-change', '_hideAlert');
-  }
+    document.removeEventListener('location-change', this.hideAlert);
+  };
 
   _clearHideAlertHandle() {
     if (this._hideAlertHandle !== null) {
-      this.cancelAsync(this._hideAlertHandle);
+      window.clearTimeout(this._hideAlertHandle);
       this._hideAlertHandle = null;
     }
   }
@@ -364,12 +375,12 @@
     this._alertElement.show(errorText, actionText, () =>
       this._createLoginPopup()
     );
-    this.fire('iron-announce', {text: errorText}, {bubbles: true});
+    fireIronAnnounce(this, errorText);
     this.reporting.reportInteraction('show-auth-error', {text: errorText});
     this._refreshingCredentials = true;
     this._requestCheckLoggedIn();
     if (!document.hidden) {
-      this._handleVisibilityChange();
+      this.handleVisibilityChange();
     }
   }
 
@@ -380,7 +391,7 @@
     return el;
   }
 
-  _handleVisibilityChange() {
+  private readonly handleVisibilityChange = () => {
     // Ignore when the page is transitioning to hidden (or hidden is undefined).
     if (document.hidden !== false) return;
 
@@ -401,12 +412,12 @@
       // - user switched account
       this._checkSignedIn();
     }
-  }
+  };
 
   _requestCheckLoggedIn() {
-    this.debounce(
-      DEBOUNCER_CHECK_LOGGED_IN,
-      this._checkSignedIn,
+    this.checkLoggedInTask = debounce(
+      this.checkLoggedInTask,
+      () => this._checkSignedIn(),
       CHECK_SIGN_IN_INTERVAL_MS
     );
   }
@@ -441,7 +452,7 @@
               return;
             }
 
-            this._handleCredentialRefreshed();
+            this.handleCredentialRefreshed();
           }
         });
       }
@@ -466,13 +477,13 @@
       '_blank',
       options.join(',')
     );
-    this.listen(window, 'focus', '_handleWindowFocus');
+    window.addEventListener('focus', this.handleWindowFocus);
   }
 
-  _handleCredentialRefreshed() {
-    this.unlisten(window, 'focus', '_handleWindowFocus');
+  handleCredentialRefreshed() {
+    window.removeEventListener('focus', this.handleWindowFocus);
     this._refreshingCredentials = false;
-    this._hideAlert();
+    this.hideAlert();
     this._showAlert('Credentials refreshed.');
     this.$.noInteractionOverlay.close();
 
@@ -480,13 +491,13 @@
     this._authService.clearCache();
   }
 
-  _handleWindowFocus() {
-    this.flushDebouncer(DEBOUNCER_CHECK_LOGGED_IN);
-  }
+  private readonly handleWindowFocus = () => {
+    this.checkLoggedInTask?.flush();
+  };
 
-  _handleShowErrorDialog(e: CustomEvent) {
+  private readonly handleShowErrorDialog = (e: ShowErrorEvent) => {
     this._showErrorDialog(e.detail.message);
-  }
+  };
 
   _handleDismissErrorDialog() {
     this.$.errorOverlay.close();
diff --git a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js
index 092daa2..7d643a0 100644
--- a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js
+++ b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.js
@@ -297,8 +297,8 @@
 
       // now fake authed
       fetchStub.returns(Promise.resolve({status: 204}));
-      element._handleWindowFocus();
-      element.flushDebouncer('checkLoggedIn');
+      element.handleWindowFocus();
+      element.checkLoggedInTask.flush();
       await flush();
       assert.isTrue(refreshStub.called);
       assert.isTrue(hideToastSpy.called);
@@ -443,14 +443,14 @@
           '_checkSignedIn');
       sinon.stub(Date, 'now').returns(999999);
       element._lastCredentialCheck = 0;
-      element._handleVisibilityChange();
+      element.handleVisibilityChange();
 
       // Since there is no known account, it should not test credentials.
       assert.isFalse(refreshStub.called);
       assert.equal(element._lastCredentialCheck, 0);
 
       element.knownAccountId = 123;
-      element._handleVisibilityChange();
+      element.handleVisibilityChange();
 
       // Should test credentials, since there is a known account.
       assert.isTrue(refreshStub.called);
@@ -463,7 +463,7 @@
           .returns(accountPromise);
       const requestCheckStub = sinon.stub(element, '_requestCheckLoggedIn');
       const handleRefreshStub = sinon.stub(element,
-          '_handleCredentialRefreshed');
+          'handleCredentialRefreshed');
       const reloadStub = sinon.stub(element, '_reloadPage');
 
       element.knownAccountId = 1234;
@@ -480,7 +480,7 @@
 
     test('_showAlert hides existing alerts', () => {
       element._alertElement = element._createToastAlert();
-      const hideStub = sinon.stub(element, '_hideAlert');
+      const hideStub = sinon.stub(element, 'hideAlert');
       element._showAlert();
       assert.isTrue(hideStub.calledOnce);
     });
@@ -522,7 +522,7 @@
           element,
           '_requestCheckLoggedIn');
       const handleRefreshStub = sinon.stub(element,
-          '_handleCredentialRefreshed');
+          'handleCredentialRefreshed');
       const reloadStub = sinon.stub(element, '_reloadPage');
 
       element.knownAccountId = 4321; // Different from 1234
@@ -557,7 +557,7 @@
           element,
           '_requestCheckLoggedIn');
       const handleRefreshStub = sinon.stub(element,
-          '_handleCredentialRefreshed');
+          'handleCredentialRefreshed');
       const reloadStub = sinon.stub(element, '_reloadPage');
 
       element._refreshingCredentials = true;
diff --git a/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display_test.ts b/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display_test.ts
index 875cde8..dd023cb 100644
--- a/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display_test.ts
@@ -15,9 +15,9 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import './gr-key-binding-display.js';
-import {GrKeyBindingDisplay} from './gr-key-binding-display.js';
+import '../../../test/common-test-setup-karma';
+import './gr-key-binding-display';
+import {GrKeyBindingDisplay} from './gr-key-binding-display';
 
 const basicFixture = fixtureFromElement('gr-key-binding-display');
 
diff --git a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts
index b76f0d3..0ec9b39 100644
--- a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts
+++ b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts
@@ -17,7 +17,6 @@
 import '../../shared/gr-button/gr-button';
 import '../gr-key-binding-display/gr-key-binding-display';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-keyboard-shortcuts-dialog_html';
 import {
@@ -41,7 +40,7 @@
 
 @customElement('gr-keyboard-shortcuts-dialog')
 export class GrKeyboardShortcutsDialog extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
+  PolymerElement
 ) {
   static get template() {
     return htmlTemplate;
@@ -75,19 +74,19 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.addKeyboardShortcutDirectoryListener(
       this.keyboardShortcutDirectoryListener
     );
   }
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     this.removeKeyboardShortcutDirectoryListener(
       this.keyboardShortcutDirectoryListener
     );
+    super.disconnectedCallback();
   }
 
   _handleCloseTap(e: MouseEvent) {
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts
index 847e49f..7b9329d 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts
@@ -19,7 +19,6 @@
 import '../../shared/gr-icons/gr-icons';
 import '../gr-account-dropdown/gr-account-dropdown';
 import '../gr-smart-search/gr-smart-search';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-main-header_html';
 import {getBaseUrl, getDocsBaseUrl} from '../../../utils/url-util';
@@ -100,7 +99,7 @@
 ]);
 
 @customElement('gr-main-header')
-export class GrMainHeader extends LegacyElementMixin(PolymerElement) {
+export class GrMainHeader extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -162,15 +161,15 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadAccount();
     this._loadConfig();
   }
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
+    super.disconnectedCallback();
   }
 
   reload() {
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_html.ts b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_html.ts
index cf7d3ae..7f3970f 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_html.ts
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_html.ts
@@ -225,7 +225,7 @@
         <iron-icon
           id="mobileSearch"
           icon="gr-icons:search"
-          on-tap="_onMobileSearchTap"
+          on-click="_onMobileSearchTap"
           role="button"
           aria-label="[[_computeShowHideAriaLabel(mobileSearchHidden)]]"
         ></iron-icon>
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts
index f764373..784b440 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts
@@ -35,11 +35,7 @@
 
   setup(() => {
     stubRestApi('probePath').returns(Promise.resolve(false));
-    stub('gr-main-header', {
-      _loadAccount() {
-        return Promise.resolve();
-      },
-    });
+    stub('gr-main-header', '_loadAccount').callsFake(() => Promise.resolve());
     element = basicFixture.instantiate();
   });
 
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
index 1e7f51d..cb2c6cf 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {
   page,
@@ -22,7 +21,6 @@
   PageNextCallback,
 } from '../../../utils/page-wrapper-utils';
 import {htmlTemplate} from './gr-router_html';
-import {encodeURL, getBaseUrl} from '../../../utils/url-util';
 import {
   DashboardSection,
   GeneratedWebLink,
@@ -68,7 +66,14 @@
 import {firePageError} from '../../../utils/event-util';
 import {addQuotesWhen} from '../../../utils/string-util';
 import {windowLocationReload} from '../../../utils/dom-util';
-import {toPath, toPathname, toSearchParams} from '../../../utils/url-util';
+import {
+  encodeURL,
+  getBaseUrl,
+  toPath,
+  toPathname,
+  toSearchParams,
+} from '../../../utils/url-util';
+import {Execution, LifeCycle} from '../../../constants/reporting';
 
 const RoutePattern = {
   ROOT: '/',
@@ -287,7 +292,7 @@
 }
 
 @customElement('gr-router')
-export class GrRouter extends LegacyElementMixin(PolymerElement) {
+export class GrRouter extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -771,7 +776,9 @@
       if (window.URLSearchParams) {
         return new URLSearchParams(ctx.querystring);
       } else {
-        this.reporting.reportExecution('noURLSearchParams');
+        this.reporting.reportExecution(Execution.REACHABLE_CODE, {
+          id: 'noURLSearchParams',
+        });
         return new Map(this._parseQueryString(ctx.querystring));
       }
     }
@@ -853,6 +860,8 @@
         const pathname = toPathname(ctx.canonicalPath);
         const searchParams = toSearchParams(ctx.canonicalPath);
         if (searchParams.has('usp')) {
+          const usp = searchParams.get('usp');
+          this.reporting.reportLifeCycle(LifeCycle.USER_REFERRED_FROM, {usp});
           searchParams.delete('usp');
           this._redirect(toPath(pathname, searchParams));
           return;
@@ -875,7 +884,7 @@
 
       // Fire asynchronously so that the URL is changed by the time the event
       // is processed.
-      this.async(() => {
+      setTimeout(() => {
         const detail: LocationChangeEventDetail = {
           hash: window.location.hash,
           pathname: window.location.pathname,
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js
index 4531110..ad4ebcb 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js
@@ -19,10 +19,8 @@
 import './gr-router.js';
 import {page} from '../../../utils/page-wrapper-utils.js';
 import {GerritNav} from '../gr-navigation/gr-navigation.js';
-import {stubBaseUrl} from '../../../test/test-utils.js';
+import {stubBaseUrl, stubRestApi, addListenerForTest} from '../../../test/test-utils.js';
 import {_testOnly_RoutePattern} from './gr-router.js';
-import {stubRestApi} from '../../../test/test-utils.js';
-import {addListenerForTest} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-router');
 
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
index 942effe..9c63f8b 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
@@ -17,7 +17,6 @@
 import '../../shared/gr-autocomplete/gr-autocomplete';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-search-bar_html';
 import {
@@ -146,9 +145,7 @@
 }
 
 @customElement('gr-search-bar')
-export class GrSearchBar extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrSearchBar extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -198,8 +195,8 @@
     this.query = (input: string) => this._getSearchSuggestions(input);
   }
 
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.restApiService.getConfig().then((serverConfig?: ServerInfo) => {
       const mergeability =
         serverConfig &&
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.js b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.js
index 212bf8f..ae7e10c 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.js
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.js
@@ -18,10 +18,9 @@
 import '../../../test/common-test-setup-karma.js';
 import './gr-search-bar.js';
 import '../../../scripts/util.js';
-import {TestKeyboardShortcutBinder} from '../../../test/test-utils.js';
+import {TestKeyboardShortcutBinder, stubRestApi} from '../../../test/test-utils.js';
 import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
 import {_testOnly_clearDocsBaseUrlCache} from '../../../utils/url-util.js';
-import {stubRestApi} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-search-bar');
 
diff --git a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.ts b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.ts
index c5d6df9..aa7e2e0 100644
--- a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.ts
+++ b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../gr-search-bar/gr-search-bar';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-smart-search_html';
 import {GerritNav} from '../gr-navigation/gr-navigation';
@@ -34,7 +33,7 @@
 const ME_EXPRESSION = 'me';
 
 @customElement('gr-smart-search')
-export class GrSmartSearch extends LegacyElementMixin(PolymerElement) {
+export class GrSmartSearch extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -63,8 +62,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.restApiService.getConfig().then(cfg => {
       this._config = cfg;
     });
diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
index ddb940b..716d142 100644
--- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
+++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
@@ -19,7 +19,6 @@
 import '../../shared/gr-dialog/gr-dialog';
 import '../../shared/gr-overlay/gr-overlay';
 import '../gr-diff/gr-diff';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-apply-fix-dialog_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -53,7 +52,7 @@
 }
 
 @customElement('gr-apply-fix-dialog')
-export class GrApplyFixDialog extends LegacyElementMixin(PolymerElement) {
+export class GrApplyFixDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -132,8 +131,8 @@
     });
   }
 
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.refitOverlay = () => {
       // re-center the dialog as content changed
       fireEvent(this.$.applyFixOverlay, 'iron-resize');
@@ -141,11 +140,11 @@
     this.addEventListener('diff-context-expanded', this.refitOverlay);
   }
 
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     if (this.refitOverlay) {
       this.removeEventListener('diff-context-expanded', this.refitOverlay);
     }
+    super.disconnectedCallback();
   }
 
   _showSelectedFixSuggestion(fixSuggestion: FixSuggestionInfo) {
diff --git a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts
index 0ca6ea3..fa8e69d 100644
--- a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts
+++ b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-comment-api_html';
 import {CURRENT} from '../../../utils/patch-set-util';
@@ -595,7 +594,7 @@
 export const _testOnly_getCommentsForPath =
   ChangeComments.prototype.getCommentsForPath;
 @customElement('gr-comment-api')
-export class GrCommentApi extends LegacyElementMixin(PolymerElement) {
+export class GrCommentApi extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -605,15 +604,6 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  /** @override */
-  created() {
-    super.created();
-  }
-
-  constructor() {
-    super();
-  }
-
   /**
    * Load all comments (with drafts and robot comments) for the given change
    * number. The returned promise resolves when the comments have loaded, but
diff --git a/polygerrit-ui/app/elements/diff/gr-coverage-layer/gr-coverage-layer.ts b/polygerrit-ui/app/elements/diff/gr-coverage-layer/gr-coverage-layer.ts
index 388cc73..f121113 100644
--- a/polygerrit-ui/app/elements/diff/gr-coverage-layer/gr-coverage-layer.ts
+++ b/polygerrit-ui/app/elements/diff/gr-coverage-layer/gr-coverage-layer.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-coverage-layer_html';
 import {CoverageRange, CoverageType, DiffLayer} from '../../../types/types';
@@ -34,8 +33,7 @@
 ]);
 
 @customElement('gr-coverage-layer')
-export class GrCoverageLayer extends LegacyElementMixin(PolymerElement)
-  implements DiffLayer {
+export class GrCoverageLayer extends PolymerElement implements DiffLayer {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element.ts
index 25aac8d..e9eb8cd 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element.ts
@@ -19,7 +19,6 @@
 import '../../shared/gr-hovercard/gr-hovercard';
 import '../gr-ranged-comment-layer/gr-ranged-comment-layer';
 import './gr-diff-builder-side-by-side';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-builder-element_html';
 import {GrAnnotation} from '../gr-diff-highlight/gr-annotation';
@@ -66,7 +65,7 @@
 }
 
 @customElement('gr-diff-builder')
-export class GrDiffBuilderElement extends LegacyElementMixin(PolymerElement) {
+export class GrDiffBuilderElement extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -161,15 +160,16 @@
   _cancelableRenderPromise: CancelablePromise<unknown> | null = null;
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     if (this._builder) {
       this._builder.clear();
     }
+    super.disconnectedCallback();
   }
 
-  get diffElement() {
-    return this.queryEffectiveChildren('#diffTable') as HTMLTableElement;
+  get diffElement(): HTMLTableElement {
+    // Not searching in shadowRoot, because the diff table is slotted!
+    return this.querySelector('#diffTable') as HTMLTableElement;
   }
 
   _computeLeftCoverageRanges(coverageRanges: CoverageRange[]) {
@@ -326,7 +326,7 @@
       sectionEl.parentNode.removeChild(sectionEl);
     }
 
-    this.async(() => fireEvent(this, 'render-content'), 1);
+    setTimeout(() => fireEvent(this, 'render-content'), 1);
   }
 
   cancel() {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element_test.js b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element_test.js
index 0ae0e84..7c01a95 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-element_test.js
@@ -843,7 +843,7 @@
         },
       ];
       element = basicFixture.instantiate();
-      outputEl = element.queryEffectiveChildren('#diffTable');
+      outputEl = element.querySelector('#diffTable');
       keyLocations = {left: {}, right: {}};
       sinon.stub(element, '_getDiffBuilder').callsFake(() => {
         const builder = new GrDiffBuilderSideBySide({content}, prefs, outputEl);
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
index 37142ff..24a7d78 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
@@ -31,6 +31,7 @@
 import {DiffViewMode, Side} from '../../../constants/constants';
 import {DiffLayer} from '../../../types/types';
 import {pluralize} from '../../../utils/string-util';
+import {fire} from '../../../utils/event-util';
 
 /**
  * In JS, unicode code points above 0xFFFF occupy two elements of a string.
@@ -62,12 +63,16 @@
   ALL = 'all',
 }
 
-export interface ContextEvent extends Event {
-  detail: {
-    groups: GrDiffGroup[];
-    section: HTMLElement;
-    numLines: number;
-  };
+export interface DiffContextExpandedEventDetail {
+  groups: GrDiffGroup[];
+  section: HTMLElement;
+  numLines: number;
+}
+
+declare global {
+  interface HTMLElementEventMap {
+    'diff-context-expanded': CustomEvent<DiffContextExpandedEventDetail>;
+  }
 }
 
 export abstract class GrDiffBuilder {
@@ -492,7 +497,7 @@
     button.appendChild(textSpan);
 
     if (requiresLoad) {
-      button.addEventListener('tap', e => {
+      button.addEventListener('click', e => {
         e.stopPropagation();
         const firstRange = groups[0].lineRange;
         const lastRange = groups[groups.length - 1].lineRange;
@@ -506,25 +511,18 @@
             end_line: lastRange.right.end_line,
           },
         };
-        button.dispatchEvent(
-          new CustomEvent<ContentLoadNeededEventDetail>('content-load-needed', {
-            detail: {
-              lineRange,
-            },
-            bubbles: true,
-            composed: true,
-          })
-        );
+        fire<ContentLoadNeededEventDetail>(button, 'content-load-needed', {
+          lineRange,
+        });
       });
     } else {
-      button.addEventListener('tap', e => {
-        const event = e as ContextEvent;
-        event.detail = {
+      button.addEventListener('click', e => {
+        e.stopPropagation();
+        fire<DiffContextExpandedEventDetail>(button, 'diff-context-expanded', {
           groups,
           section,
           numLines,
-        };
-        // Let it bubble up the DOM tree.
+        });
       });
     }
 
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
index a19968c..6f6705e 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
@@ -25,7 +25,6 @@
 } from '../../shared/gr-cursor-manager/gr-cursor-manager';
 import {afterNextRender} from '@polymer/polymer/lib/utils/render-status';
 import {dom} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-cursor_html';
 import {DiffViewMode} from '../../../api/diff';
@@ -37,6 +36,8 @@
 import {GrDiffGroupType} from '../gr-diff/gr-diff-group';
 import {GrDiff} from '../gr-diff/gr-diff';
 import {fireAlert, fireEvent} from '../../../utils/event-util';
+import {Subscription} from 'rxjs';
+import {toggleClass} from '../../../utils/dom-util';
 
 type GrDiffRowType = GrDiffLineType | GrDiffGroupType;
 
@@ -47,13 +48,11 @@
 const NAVIGATE_TO_NEXT_FILE_TIMEOUT_MS = 5000;
 
 export interface GrDiffCursor {
-  $: {
-    cursorManager: GrCursorManager;
-  };
+  $: {};
 }
 
 @customElement('gr-diff-cursor')
-export class GrDiffCursor extends LegacyElementMixin(PolymerElement) {
+export class GrDiffCursor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -82,20 +81,18 @@
   @property({type: Number})
   initialLineNumber: number | null = null;
 
-  /**
-   * The scroll behavior for the cursor. Values are 'never' and
-   * 'keep-visible'. 'keep-visible' will only scroll if the cursor is beyond
-   * the viewport.
-   */
-  @property({type: String})
-  _scrollMode = ScrollMode.KEEP_VISIBLE;
-
-  @property({type: Boolean})
-  _focusOnMove = true;
-
   @property({type: Boolean})
   _listeningForScroll = false;
 
+  private cursorManager = new GrCursorManager();
+
+  constructor() {
+    super();
+    this.cursorManager.cursorTargetClass = 'target-row';
+    this.cursorManager.scrollMode = ScrollMode.KEEP_VISIBLE;
+    this.cursorManager.focusOnMove = true;
+  }
+
   /** @override */
   ready() {
     super.ready();
@@ -119,27 +116,34 @@
     });
   }
 
+  private targetSubscription?: Subscription;
+
   /** @override */
   connectedCallback() {
     super.connectedCallback();
     // Catch when users are scrolling as the view loads.
     window.addEventListener('scroll', this._boundHandleWindowScroll);
+    this.targetSubscription = this.cursorManager.target$.subscribe(target => {
+      this.diffRow = target || undefined;
+    });
   }
 
   /** @override */
   disconnectedCallback() {
-    super.disconnectedCallback();
+    if (this.targetSubscription) this.targetSubscription.unsubscribe();
     window.removeEventListener('scroll', this._boundHandleWindowScroll);
+    this.cursorManager.unsetCursor();
+    super.disconnectedCallback();
   }
 
   // Don't remove - used by clients embedding gr-diff outside of Gerrit.
   isAtStart() {
-    return this.$.cursorManager.isAtStart();
+    return this.cursorManager.isAtStart();
   }
 
   // Don't remove - used by clients embedding gr-diff outside of Gerrit.
   isAtEnd() {
-    return this.$.cursorManager.isAtEnd();
+    return this.cursorManager.isAtEnd();
   }
 
   moveLeft() {
@@ -158,31 +162,31 @@
 
   moveDown() {
     if (this._getViewMode() === DiffViewMode.SIDE_BY_SIDE) {
-      return this.$.cursorManager.next({
+      return this.cursorManager.next({
         filter: (row: Element) => this._rowHasSide(row),
       });
     } else {
-      return this.$.cursorManager.next();
+      return this.cursorManager.next();
     }
   }
 
   moveUp() {
     if (this._getViewMode() === DiffViewMode.SIDE_BY_SIDE) {
-      return this.$.cursorManager.previous({
+      return this.cursorManager.previous({
         filter: (row: Element) => this._rowHasSide(row),
       });
     } else {
-      return this.$.cursorManager.previous();
+      return this.cursorManager.previous();
     }
   }
 
   moveToVisibleArea() {
     if (this._getViewMode() === DiffViewMode.SIDE_BY_SIDE) {
-      this.$.cursorManager.moveToVisibleArea((row: Element) =>
+      this.cursorManager.moveToVisibleArea((row: Element) =>
         this._rowHasSide(row)
       );
     } else {
-      this.$.cursorManager.moveToVisibleArea();
+      this.cursorManager.moveToVisibleArea();
     }
   }
 
@@ -190,7 +194,7 @@
     clipToTop?: boolean,
     navigateToNextFile?: boolean
   ): CursorMoveResult {
-    const result = this.$.cursorManager.next({
+    const result = this.cursorManager.next({
       filter: (row: HTMLElement) => this._isFirstRowOfChunk(row),
       getTargetHeight: target =>
         (target?.parentNode as HTMLElement)?.scrollHeight || 0,
@@ -225,7 +229,7 @@
   }
 
   moveToPreviousChunk(): CursorMoveResult {
-    const result = this.$.cursorManager.previous({
+    const result = this.cursorManager.previous({
       filter: (row: HTMLElement) => this._isFirstRowOfChunk(row),
     });
     this._fixSide();
@@ -237,7 +241,7 @@
       fireEvent(this, 'navigate-to-next-file-with-comments');
       return;
     }
-    const result = this.$.cursorManager.next({
+    const result = this.cursorManager.next({
       filter: (row: HTMLElement) => this._rowHasThread(row),
     });
     this._fixSide();
@@ -245,7 +249,7 @@
   }
 
   moveToPreviousCommentThread(): CursorMoveResult {
-    const result = this.$.cursorManager.previous({
+    const result = this.cursorManager.previous({
       filter: (row: HTMLElement) => this._rowHasThread(row),
     });
     this._fixSide();
@@ -256,7 +260,7 @@
     const row = this._findRowByNumberAndFile(number, side, path);
     if (row) {
       this.side = side;
-      this.$.cursorManager.setCursor(row);
+      this.cursorManager.setCursor(row);
     }
   }
 
@@ -288,7 +292,7 @@
   }
 
   moveToFirstChunk() {
-    this.$.cursorManager.moveToStart();
+    this.cursorManager.moveToStart();
     if (this.diffRow && !this._isFirstRowOfChunk(this.diffRow)) {
       this.moveToNextChunk(true);
     } else {
@@ -297,7 +301,7 @@
   }
 
   moveToLastChunk() {
-    this.$.cursorManager.moveToEnd();
+    this.cursorManager.moveToEnd();
     if (this.diffRow && !this._isFirstRowOfChunk(this.diffRow)) {
       this.moveToPreviousChunk();
     } else {
@@ -317,7 +321,7 @@
   reInitCursor() {
     if (!this.diffRow) {
       // does not scroll during init unless requested
-      this._scrollMode = this.initialLineNumber
+      this.cursorManager.scrollMode = this.initialLineNumber
         ? ScrollMode.KEEP_VISIBLE
         : ScrollMode.NEVER;
       if (this.initialLineNumber) {
@@ -331,13 +335,13 @@
   }
 
   reInit() {
-    this._scrollMode = ScrollMode.KEEP_VISIBLE;
+    this.cursorManager.scrollMode = ScrollMode.KEEP_VISIBLE;
   }
 
   private _boundHandleWindowScroll = () => {
     if (this.preventAutoScrollOnManualScroll) {
-      this._scrollMode = ScrollMode.NEVER;
-      this._focusOnMove = false;
+      this.cursorManager.scrollMode = ScrollMode.NEVER;
+      this.cursorManager.focusOnMove = false;
       this.preventAutoScrollOnManualScroll = false;
     }
   };
@@ -363,7 +367,7 @@
   private _boundHandleDiffRenderContent = () => {
     this._updateStops();
     // When done rendering, turn focus on move and automatic scrolling back on
-    this._focusOnMove = true;
+    this.cursorManager.focusOnMove = true;
     this.preventAutoScrollOnManualScroll = false;
   };
 
@@ -498,8 +502,8 @@
     if (!this.diffRow) {
       return;
     }
-    this.toggleClass(LEFT_SIDE_CLASS, this.side === Side.LEFT, this.diffRow);
-    this.toggleClass(RIGHT_SIDE_CLASS, this.side === Side.RIGHT, this.diffRow);
+    toggleClass(this.diffRow, LEFT_SIDE_CLASS, this.side === Side.LEFT);
+    toggleClass(this.diffRow, RIGHT_SIDE_CLASS, this.side === Side.RIGHT);
   }
 
   _isActionType(type: GrDiffRowType) {
@@ -522,7 +526,7 @@
   }
 
   _updateStops() {
-    this.$.cursorManager.stops = this.diffs.reduce(
+    this.cursorManager.stops = this.diffs.reduce(
       (stops: Stop[], diff) => stops.concat(diff.getCursorStops()),
       []
     );
@@ -601,7 +605,7 @@
       const diff = this.diffs.filter(diff => diff.path === path)[0];
       stops = diff.getCursorStops();
     } else {
-      stops = this.$.cursorManager.stops;
+      stops = this.cursorManager.stops;
     }
     // Sadly needed for type narrowing to understand that the result is always
     // targetable.
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_html.ts b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_html.ts
index 1539a22..1489006 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_html.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_html.ts
@@ -16,12 +16,4 @@
  */
 import {html} from '@polymer/polymer/lib/utils/html-tag';
 
-export const htmlTemplate = html`
-  <gr-cursor-manager
-    id="cursorManager"
-    scroll-mode="[[_scrollMode]]"
-    cursor-target-class="target-row"
-    focus-on-move="[[_focusOnMove]]"
-    target="{{diffRow}}"
-  ></gr-cursor-manager>
-`;
+export const htmlTemplate = html``;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.js b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.js
index 60b82da..75439c8 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.js
@@ -187,20 +187,20 @@
   });
 
   test('cursor scroll behavior', () => {
-    assert.equal(cursorElement._scrollMode, 'keep-visible');
+    assert.equal(cursorElement.cursorManager.scrollMode, 'keep-visible');
 
     diffElement.dispatchEvent(new Event('render-start'));
-    assert.isTrue(cursorElement._focusOnMove);
+    assert.isTrue(cursorElement.cursorManager.focusOnMove);
 
     window.dispatchEvent(new Event('scroll'));
-    assert.equal(cursorElement._scrollMode, 'never');
-    assert.isFalse(cursorElement._focusOnMove);
+    assert.equal(cursorElement.cursorManager.scrollMode, 'never');
+    assert.isFalse(cursorElement.cursorManager.focusOnMove);
 
     diffElement.dispatchEvent(new Event('render-content'));
-    assert.isTrue(cursorElement._focusOnMove);
+    assert.isTrue(cursorElement.cursorManager.focusOnMove);
 
     cursorElement.reInitCursor();
-    assert.equal(cursorElement._scrollMode, 'keep-visible');
+    assert.equal(cursorElement.cursorManager.scrollMode, 'keep-visible');
   });
 
   test('moves to selected line', () => {
@@ -266,7 +266,7 @@
     // to the right side.
     assert.equal(cursorElement.side, 'right');
     assert.equal(cursorElement.diffRow, firstDeltaRow);
-    const firstIndex = cursorElement.$.cursorManager.index;
+    const firstIndex = cursorElement.cursorManager.index;
 
     // Move the side to the left. Because this delta only has a right side, we
     // should be moved up to the previous line where there is content on the
@@ -275,7 +275,7 @@
 
     assert.equal(cursorElement.side, 'left');
     assert.notEqual(cursorElement.diffRow, firstDeltaRow);
-    assert.equal(cursorElement.$.cursorManager.index, firstIndex - 1);
+    assert.equal(cursorElement.cursorManager.index, firstIndex - 1);
     assert.equal(cursorElement.diffRow.parentElement,
         firstDeltaSection.previousSibling);
 
@@ -285,7 +285,7 @@
 
     assert.equal(cursorElement.side, 'left');
     assert.notEqual(cursorElement.diffRow, firstDeltaRow);
-    assert.isTrue(cursorElement.$.cursorManager.index > firstIndex);
+    assert.isTrue(cursorElement.cursorManager.index > firstIndex);
     assert.equal(cursorElement.diffRow.parentElement,
         firstDeltaSection.nextSibling);
   });
@@ -446,8 +446,7 @@
   });
 
   test('navigate to next unreviewed file via moveToNextChunk', () => {
-    const cursorManager =
-        cursorElement.shadowRoot.querySelector('#cursorManager');
+    const cursorManager = cursorElement.cursorManager;
     cursorManager.index = cursorManager.stops.length - 1;
     const dispatchEventStub = sinon.stub(cursorElement, 'dispatchEvent');
     cursorElement.moveToNextChunk(/* opt_clipToTop = */false,
@@ -465,8 +464,9 @@
     let scrollBehaviorDuringMove;
     const moveToNumStub = sinon.stub(cursorElement, 'moveToLineNumber');
     const moveToChunkStub = sinon.stub(cursorElement, 'moveToFirstChunk')
-        .callsFake(
-            () => { scrollBehaviorDuringMove = cursorElement._scrollMode; });
+        .callsFake(() => {
+          scrollBehaviorDuringMove = cursorElement.cursorManager.scrollMode;
+        });
 
     function renderHandler() {
       diffElement.removeEventListener('render', renderHandler);
@@ -474,7 +474,7 @@
       assert.isFalse(moveToNumStub.called);
       assert.isTrue(moveToChunkStub.called);
       assert.equal(scrollBehaviorDuringMove, 'never');
-      assert.equal(cursorElement._scrollMode, 'keep-visible');
+      assert.equal(cursorElement.cursorManager.scrollMode, 'keep-visible');
       done();
     }
     diffElement.addEventListener('render', renderHandler);
@@ -484,8 +484,9 @@
   test('initialLineNumber provided', done => {
     let scrollBehaviorDuringMove;
     const moveToNumStub = sinon.stub(cursorElement, 'moveToLineNumber')
-        .callsFake(
-            () => { scrollBehaviorDuringMove = cursorElement._scrollMode; });
+        .callsFake(() => {
+          scrollBehaviorDuringMove = cursorElement.cursorManager.scrollMode;
+        });
     const moveToChunkStub = sinon.stub(cursorElement, 'moveToFirstChunk');
     function renderHandler() {
       diffElement.removeEventListener('render', renderHandler);
@@ -495,7 +496,7 @@
       assert.equal(moveToNumStub.lastCall.args[0], 10);
       assert.equal(moveToNumStub.lastCall.args[1], 'right');
       assert.equal(scrollBehaviorDuringMove, 'keep-visible');
-      assert.equal(cursorElement._scrollMode, 'keep-visible');
+      assert.equal(cursorElement.cursorManager.scrollMode, 'keep-visible');
       done();
     }
     diffElement.addEventListener('render', renderHandler);
@@ -600,7 +601,7 @@
         {leftSide: true, number: 10});
 
     // Should be null if there is no selection.
-    cursorElement.$.cursorManager.unsetCursor();
+    cursorElement.cursorManager.unsetCursor();
     assert.isNotOk(cursorElement.getAddress());
   });
 
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.ts b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.ts
index 0f53a26..76e02f0 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.ts
@@ -17,7 +17,6 @@
 import '../../../styles/shared-styles';
 import '../gr-selection-action-box/gr-selection-action-box';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-highlight_html';
 import {GrAnnotation} from './gr-annotation';
@@ -30,6 +29,7 @@
 import {GrDiffBuilderElement} from '../gr-diff-builder/gr-diff-builder-element';
 import {FILE} from '../gr-diff/gr-diff-line';
 import {getRange, getSide} from '../gr-diff/gr-diff-utils';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 
 interface SidedRange {
   side: Side;
@@ -53,10 +53,8 @@
   rootId: string;
 }
 
-const DEBOUNCER_SELECTION_CHANGE = 'selectionChange';
-
 @customElement('gr-diff-highlight')
-export class GrDiffHighlight extends LegacyElementMixin(PolymerElement) {
+export class GrDiffHighlight extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -73,9 +71,10 @@
   @property({type: Object, notify: true})
   selectedRange?: SidedRange;
 
-  /** @override */
-  created() {
-    super.created();
+  private selectionChangeTask?: DelayedTask;
+
+  constructor() {
+    super();
     this.addEventListener('comment-thread-mouseleave', e =>
       this._handleCommentThreadMouseleave(e)
     );
@@ -88,8 +87,9 @@
   }
 
   /** @override */
-  detached() {
-    this.cancelDebouncer(DEBOUNCER_SELECTION_CHANGE);
+  disconnectedCallback() {
+    this.selectionChangeTask?.cancel();
+    super.disconnectedCallback();
   }
 
   get diffBuilder() {
@@ -126,8 +126,8 @@
     // quick 'c' press after the selection change. If you wait less than 10
     // ms, then you will have about 50 _handleSelection calls when doing a
     // simple drag for select.
-    this.debounce(
-      DEBOUNCER_SELECTION_CHANGE,
+    this.selectionChangeTask = debounce(
+      this.selectionChangeTask,
       () => this._handleSelection(selection, isMouseUp),
       10
     );
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js
index 11b1f38..07e83a8 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js
@@ -266,10 +266,8 @@
 
     setup(() => {
       contentStubs = [];
-      stub('gr-selection-action-box', {
-        placeAbove: sinon.stub(),
-        placeBelow: sinon.stub(),
-      });
+      stub('gr-selection-action-box', 'placeAbove');
+      stub('gr-selection-action-box', 'placeBelow');
       diff = element.querySelector('#diffTable');
       builder = {
         getContentTdByLine: sinon.stub(),
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts
index e6f08b01..d4b615c 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts
@@ -16,7 +16,6 @@
  */
 import '../../shared/gr-comment-thread/gr-comment-thread';
 import '../gr-diff/gr-diff';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-host_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -79,6 +78,7 @@
 } from '../../../utils/event-util';
 import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader';
 import {assertIsDefined} from '../../../utils/common-util';
+import {DiffContextExpandedEventDetail} from '../gr-diff-builder/gr-diff-builder';
 
 const MSG_EMPTY_BLAME = 'No blame information for this diff.';
 
@@ -130,7 +130,7 @@
  * specific component, while <gr-diff> is a re-usable component.
  */
 @customElement('gr-diff-host')
-export class GrDiffHost extends LegacyElementMixin(PolymerElement) {
+export class GrDiffHost extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -269,9 +269,8 @@
 
   private readonly syntaxLayer = new GrSyntaxLayer();
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener(
       // These are named inconsistently for a reason:
       // The create-comment event is fired to indicate that we should
@@ -307,17 +306,17 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._getLoggedIn().then(loggedIn => {
       this._loggedIn = loggedIn;
     });
   }
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     this.clear();
+    super.disconnectedCallback();
   }
 
   initLayers() {
@@ -325,8 +324,7 @@
       .awaitPluginsLoaded()
       .then(() => {
         assertIsDefined(this.path, 'path');
-        assertIsDefined(this.changeNum, 'changeNum');
-        this._layers = this._getLayers(this.path, this.changeNum);
+        this._layers = this._getLayers(this.path);
         this._coverageRanges = [];
         // We kick off fetching the data here, but we don't return the promise,
         // so awaiting initLayers() will not wait for coverage data to be
@@ -403,9 +401,9 @@
     }
   }
 
-  private _getLayers(path: string, changeNum: NumericChangeId): DiffLayer[] {
+  private _getLayers(path: string): DiffLayer[] {
     // Get layers from plugins (if any).
-    return [this.syntaxLayer, ...this.jsAPI.getDiffLayers(path, changeNum)];
+    return [this.syntaxLayer, ...this.jsAPI.getDiffLayers(path)];
   }
 
   clear() {
@@ -1068,9 +1066,9 @@
     });
   }
 
-  _handleDiffContextExpanded(event: CustomEvent) {
+  _handleDiffContextExpanded(e: CustomEvent<DiffContextExpandedEventDetail>) {
     this.reporting.reportInteraction('diff-context-expanded', {
-      numLines: event.detail.numLines,
+      numLines: e.detail.numLines,
     });
   }
 
@@ -1156,7 +1154,7 @@
     /* prettier-ignore */
     'render': CustomEvent;
     'normalize-range': CustomEvent;
-    'diff-context-expanded': CustomEvent;
+    'diff-context-expanded': CustomEvent<DiffContextExpandedEventDetail>;
     'create-comment': CustomEvent;
     'comment-discard': CustomEvent;
     'comment-update': CustomEvent;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
index 3d6383b..d31d934 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
@@ -21,11 +21,10 @@
 import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
 import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
 import {createCommentThreads} from '../../../utils/comment-util.js';
-import {Side} from '../../../constants/constants.js';
+import {Side, createDefaultDiffPrefs} from '../../../constants/constants.js';
 import {createChange} from '../../../test/test-data-generators.js';
 import {CoverageType} from '../../../types/types.js';
 import {addListenerForTest, stubRestApi} from '../../../test/test-utils.js';
-import {createDefaultDiffPrefs} from '../../../constants/constants.js';
 import {EditPatchSetNum, ParentPatchSetNum} from '../../../types/common.js';
 
 const basicFixture = fixtureFromElement('gr-diff-host');
@@ -103,8 +102,7 @@
 
     threadEls[0].dispatchEvent(
         new CustomEvent('thread-discard', {detail: {rootId: 4711}}));
-    const attachedThreads = element.queryAllEffectiveChildren(
-        'gr-comment-thread');
+    const attachedThreads = element.querySelectorAll('gr-comment-thread');
     assert.equal(attachedThreads.length, 1);
     assert.equal(attachedThreads[0].comments[0].id, 42);
   });
@@ -159,6 +157,7 @@
       element.reload();
       // Multiple cascading microtasks are scheduled.
       await flush();
+      await flush();
       // Reporting can be called with other parameters (ex. PluginsLoaded),
       // but only 'Diff Total Render' is important in this test.
       assert.equal(
@@ -970,7 +969,7 @@
   suite('create-comment', () => {
     setup(async () => {
       loggedIn = true;
-      element.attached();
+      element.connectedCallback();
       await flush();
     });
 
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts
index 0a22556..b576896 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts
@@ -19,16 +19,16 @@
 import '../../../styles/shared-styles';
 import '../../shared/gr-button/gr-button';
 import {DiffViewMode} from '../../../constants/constants';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-mode-selector_html';
 import {customElement, property} from '@polymer/decorators';
 import {IronA11yAnnouncer} from '@polymer/iron-a11y-announcer/iron-a11y-announcer';
 import {FixIronA11yAnnouncer} from '../../../types/types';
 import {appContext} from '../../../services/app-context';
+import {fireIronAnnounce} from '../../../utils/event-util';
 
 @customElement('gr-diff-mode-selector')
-export class GrDiffModeSelector extends LegacyElementMixin(PolymerElement) {
+export class GrDiffModeSelector extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -45,7 +45,9 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  attached() {
+  /** @override */
+  connectedCallback() {
+    super.connectedCallback();
     ((IronA11yAnnouncer as unknown) as FixIronA11yAnnouncer).requestAvailability();
   }
 
@@ -64,13 +66,7 @@
       announcement = 'Changed diff view to side by side';
     }
     if (announcement) {
-      this.fire(
-        'iron-announce',
-        {
-          text: announcement,
-        },
-        {bubbles: true}
-      );
+      fireIronAnnounce(this, announcement);
     }
   }
 
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.ts b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.ts
index 96c2c03..5a8c55d 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.ts
@@ -18,7 +18,6 @@
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-diff-preferences/gr-diff-preferences';
 import '../../shared/gr-overlay/gr-overlay';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-preferences-dialog_html';
 import {customElement, property} from '@polymer/decorators';
@@ -36,9 +35,7 @@
   };
 }
 @customElement('gr-diff-preferences-dialog')
-export class GrDiffPreferencesDialog extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrDiffPreferencesDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts
index f4772e3..d5e2a07 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {
   GrDiffLine,
@@ -32,6 +31,7 @@
 import {customElement, property} from '@polymer/decorators';
 import {DiffContent} from '../../../types/diff';
 import {Side} from '../../../constants/constants';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 
 const WHOLE_FILE = -1;
 
@@ -63,8 +63,6 @@
  */
 const MAX_GROUP_SIZE = 120;
 
-const DEBOUNCER_RESET_IS_SCROLLING = 'resetIsScrolling';
-
 /**
  * Converts the API's `DiffContent`s  to `GrDiffGroup`s for rendering.
  *
@@ -91,7 +89,7 @@
  *    the rest is not.
  */
 @customElement('gr-diff-processor')
-export class GrDiffProcessor extends LegacyElementMixin(PolymerElement) {
+export class GrDiffProcessor extends PolymerElement {
   @property({type: Number})
   context = 3;
 
@@ -113,30 +111,30 @@
   @property({type: Boolean})
   _isScrolling?: boolean;
 
+  private resetIsScrollingTask?: DelayedTask;
+
   /** @override */
-  attached() {
-    super.attached();
-    this.listen(window, 'scroll', '_handleWindowScroll');
+  connectedCallback() {
+    super.connectedCallback();
+    window.addEventListener('scroll', this.handleWindowScroll);
   }
 
   /** @override */
-  detached() {
-    super.detached();
-    this.cancelDebouncer(DEBOUNCER_RESET_IS_SCROLLING);
+  disconnectedCallback() {
+    this.resetIsScrollingTask?.cancel();
     this.cancel();
-    this.unlisten(window, 'scroll', '_handleWindowScroll');
+    window.removeEventListener('scroll', this.handleWindowScroll);
+    super.disconnectedCallback();
   }
 
-  _handleWindowScroll() {
+  private readonly handleWindowScroll = () => {
     this._isScrolling = true;
-    this.debounce(
-      DEBOUNCER_RESET_IS_SCROLLING,
-      () => {
-        this._isScrolling = false;
-      },
+    this.resetIsScrollingTask = debounce(
+      this.resetIsScrollingTask,
+      () => (this._isScrolling = false),
       50
     );
-  }
+  };
 
   /**
    * Asynchronously process the diff chunks into groups. As it processes, it
@@ -173,7 +171,7 @@
         let currentBatch = 0;
         const nextStep = () => {
           if (this._isScrolling) {
-            this._nextStepHandle = this.async(nextStep, 100);
+            this._nextStepHandle = window.setTimeout(nextStep, 100);
             return;
           }
           // If we are done, resolve the promise.
@@ -196,7 +194,7 @@
           state.chunkIndex = stateUpdate.newChunkIndex;
           if (currentBatch >= this._asyncThreshold) {
             currentBatch = 0;
-            this._nextStepHandle = this.async(nextStep, 1);
+            this._nextStepHandle = window.setTimeout(nextStep, 1);
           } else {
             nextStep.call(this);
           }
@@ -215,7 +213,7 @@
    */
   cancel() {
     if (this._nextStepHandle !== null) {
-      this.cancelAsync(this._nextStepHandle);
+      window.clearTimeout(this._nextStepHandle);
       this._nextStepHandle = null;
     }
     if (this._processPromise) {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.js b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.js
index b8f7498..0bb5eac 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.js
@@ -750,7 +750,6 @@
         ],
       };
       const content = _.times(200, _.constant(contentRow));
-      sinon.stub(element, 'async');
       element._isScrolling = true;
       element.process(content);
       // Just the files group - no more processing during scrolling.
@@ -770,7 +769,6 @@
         ],
       };
       const content = _.times(200, _.constant(contentRow));
-      sinon.stub(element, 'async');
       element.process(content, true);
       assert.equal(element.groups.length, 2);
 
@@ -1113,7 +1111,7 @@
   test('detaching cancels', () => {
     element = basicFixture.instantiate();
     sinon.stub(element, 'cancel');
-    element.detached();
+    element.disconnectedCallback();
     assert(element.cancel.called);
   });
 });
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts
index 39acb86..3df2e18 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts
@@ -17,7 +17,6 @@
 import '../../../styles/shared-styles';
 import {addListener} from '@polymer/polymer/lib/utils/gestures';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-selection_html';
 import {
@@ -52,7 +51,7 @@
 }
 
 @customElement('gr-diff-selection')
-export class GrDiffSelection extends LegacyElementMixin(PolymerElement) {
+export class GrDiffSelection extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -66,16 +65,15 @@
   @property({type: Object})
   _linesCache: LinesCache = {left: null, right: null};
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('copy', e => this._handleCopy(e));
     addListener(this, 'down', e => this._handleDown(e));
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.classList.add(SelectionClass.RIGHT);
   }
 
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
index 0271f07..b5ea72e 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
@@ -31,7 +31,6 @@
 import '../gr-diff-preferences-dialog/gr-diff-preferences-dialog';
 import '../gr-patch-range-select/gr-patch-range-select';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-view_html';
 import {
@@ -78,6 +77,7 @@
   PreferencesInfo,
   RepoName,
   RevisionInfo,
+  RevisionPatchSetNum,
 } from '../../../types/common';
 import {DiffInfo, DiffPreferencesInfo} from '../../../types/diff';
 import {ChangeViewState, CommitRange, FileRange} from '../../../types/types';
@@ -98,6 +98,7 @@
 import {fireAlert, fireEvent, fireTitleChange} from '../../../utils/event-util';
 import {GerritView} from '../../../services/router/router-model';
 import {assertIsDefined} from '../../../utils/common-util';
+import {toggleClass} from '../../../utils/dom-util';
 const ERR_REVIEW_STATUS = 'Couldn’t change file review status.';
 const MSG_LOADING_BLAME = 'Loading blame...';
 const MSG_LOADED_BLAME = 'Blame loaded';
@@ -126,9 +127,7 @@
 }
 
 @customElement('gr-diff-view')
-export class GrDiffView extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrDiffView extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -326,11 +325,6 @@
     this._throttledToggleFileReviewed = this._throttleWrap(e =>
       this._handleToggleFileReviewed(e as CustomKeyboardEvent)
     );
-  }
-
-  /** @override */
-  attached() {
-    super.attached();
     this._getLoggedIn().then(loggedIn => {
       this._loggedIn = loggedIn;
     });
@@ -344,10 +338,11 @@
   }
 
   /** @override */
-  detached() {
+  disconnectedCallback() {
     if (this._onRenderHandler) {
       this.$.diffHost.removeEventListener('render', this._onRenderHandler);
     }
+    super.disconnectedCallback();
   }
 
   _getLoggedIn() {
@@ -1474,7 +1469,7 @@
     const comparedAgainstParent = patchRange.basePatchNum === 'PARENT';
 
     if (isBase && !comparedAgainstParent) {
-      patchNum = patchRange.basePatchNum;
+      patchNum = patchRange.basePatchNum as RevisionPatchSetNum;
     }
 
     let url =
@@ -1627,7 +1622,7 @@
     if (this.shouldSuppressKeyboardShortcut(e)) return;
     if (this.modifierPressed(e)) return;
 
-    this.toggleClass('hideComments');
+    toggleClass(this, 'hideComments');
   }
 
   _handleOpenFileList(e: CustomKeyboardEvent) {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js
index ac91659..5c3dfdc 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js
@@ -19,7 +19,7 @@
 import './gr-diff-view.js';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
 import {ChangeStatus} from '../../../constants/constants.js';
-import {TestKeyboardShortcutBinder} from '../../../test/test-utils.js';
+import {TestKeyboardShortcutBinder, stubRestApi} from '../../../test/test-utils.js';
 import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
 import {ChangeComments, _testOnly_findCommentById, _testOnly_getCommentsForPath} from '../gr-comment-api/gr-comment-api.js';
 import {GerritView} from '../../../services/router/router-model.js';
@@ -28,7 +28,6 @@
   createRevisions,
   createComment,
 } from '../../../test/test-data-generators.js';
-import {stubRestApi} from '../../../test/test-utils.js';
 import {EditPatchSetNum} from '../../../types/common.js';
 
 const basicFixture = fixtureFromElement('gr-diff-view');
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts
index 802397b..beaec75 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts
@@ -25,7 +25,6 @@
 import '../gr-ranged-comment-hint/gr-ranged-comment-hint';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {htmlTemplate} from './gr-diff_html';
 import {LineNumber} from './gr-diff-line';
 import {
@@ -73,8 +72,10 @@
   CreateCommentEventDetail as CreateCommentEventDetailApi,
   RenderPreferences,
 } from '../../../api/diff';
-import {isSafari} from '../../../utils/dom-util';
+import {isSafari, toggleClass} from '../../../utils/dom-util';
 import {assertIsDefined} from '../../../utils/common-util';
+import {debounce, DelayedTask} from '../../../utils/async-util';
+import {DiffContextExpandedEventDetail} from '../gr-diff-builder/gr-diff-builder';
 
 const NO_NEWLINE_BASE = 'No newline at end of base file.';
 const NO_NEWLINE_REVISION = 'No newline at end of revision file.';
@@ -92,8 +93,6 @@
  */
 const COMMIT_MSG_LINE_LENGTH = 72;
 
-const RENDER_DIFF_TABLE_DEBOUNCE_NAME = 'renderDiffTable';
-
 export interface LineOfInterest {
   number: number;
   leftSide: boolean;
@@ -112,7 +111,7 @@
 }
 
 @customElement('gr-diff')
-export class GrDiff extends LegacyElementMixin(PolymerElement) {
+export class GrDiff extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -283,9 +282,13 @@
   @property({type: Array})
   layers?: DiffLayer[];
 
-  /** @override */
-  created() {
-    super.created();
+  @property({type: Boolean})
+  isAttached = false;
+
+  private renderDiffTableTask?: DelayedTask;
+
+  constructor() {
+    super();
     this._setLoading(true);
     this.addEventListener('create-range-comment', (e: Event) =>
       this._handleCreateRangeComment(e as CustomEvent)
@@ -295,17 +298,19 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._observeNodes();
+    this.isAttached = true;
   }
 
   /** @override */
-  detached() {
-    this.cancelDebouncer(RENDER_DIFF_TABLE_DEBOUNCE_NAME);
-    super.detached();
+  disconnectedCallback() {
+    this.isAttached = false;
+    this.renderDiffTableTask?.cancel();
     this._unobserveIncrementalNodes();
     this._unobserveNodes();
+    super.disconnectedCallback();
   }
 
   showNoChangeMessage(
@@ -325,44 +330,37 @@
   }
 
   @observe('loggedIn', 'isAttached')
-  _enableSelectionObserver(loggedIn: boolean, isAttached?: boolean) {
-    // Polymer 2: check for undefined
-    if ([loggedIn, isAttached].includes(undefined)) {
-      return;
-    }
-
+  _enableSelectionObserver(loggedIn: boolean, isAttached: boolean) {
     if (loggedIn && isAttached) {
-      this.listen(
-        document,
+      document.addEventListener(
         '-shadow-selectionchange',
-        '_handleSelectionChange'
+        this.handleSelectionChange
       );
-      this.listen(document, 'mouseup', '_handleMouseUp');
+      document.addEventListener('mouseup', this.handleMouseUp);
     } else {
-      this.unlisten(
-        document,
+      document.removeEventListener(
         '-shadow-selectionchange',
-        '_handleSelectionChange'
+        this.handleSelectionChange
       );
-      this.unlisten(document, 'mouseup', '_handleMouseUp');
+      document.removeEventListener('mouseup', this.handleMouseUp);
     }
   }
 
-  _handleSelectionChange() {
+  private readonly handleSelectionChange = () => {
     // Because of shadow DOM selections, we handle the selectionchange here,
     // and pass the shadow DOM selection into gr-diff-highlight, where the
     // corresponding range is determined and normalized.
     const selection = this._getShadowOrDocumentSelection();
     this.$.highlights.handleSelectionChange(selection, false);
-  }
+  };
 
-  _handleMouseUp() {
+  private readonly handleMouseUp = () => {
     // To handle double-click outside of text creating comments, we check on
     // mouse-up if there's a selection that just covers a line change. We
     // can't do that on selection change since the user may still be dragging.
     const selection = this._getShadowOrDocumentSelection();
     this.$.highlights.handleSelectionChange(selection, true);
-  }
+  };
 
   /** Gets the current selection, preferring the shadow DOM selection. */
   _getShadowOrDocumentSelection() {
@@ -477,7 +475,7 @@
   /** Cancel any remaining diff builder rendering work. */
   cancel() {
     this.$.diffBuilder.cancel();
-    this.cancelDebouncer(RENDER_DIFF_TABLE_DEBOUNCE_NAME);
+    this.renderDiffTableTask?.cancel();
   }
 
   getCursorStops(): Array<HTMLElement | AbortStop> {
@@ -499,7 +497,7 @@
   }
 
   toggleLeftDiff() {
-    this.toggleClass('no-left');
+    toggleClass(this, 'no-left');
   }
 
   _blameChanged(newValue?: BlameInfo[] | null) {
@@ -526,21 +524,15 @@
     return classes.join(' ');
   }
 
+  _handleDiffContextExpanded(e: CustomEvent<DiffContextExpandedEventDetail>) {
+    // Don't stop propagation. The host may listen for reporting or resizing.
+    this.$.diffBuilder.showContext(e.detail.groups, e.detail.section);
+  }
+
   _handleTap(e: CustomEvent) {
     const el = (dom(e) as EventApi).localTarget as Element;
 
-    if (el.classList.contains('showContext')) {
-      this.dispatchEvent(
-        new CustomEvent('diff-context-expanded', {
-          detail: {
-            numLines: e.detail.numLines,
-          },
-          composed: true,
-          bubbles: true,
-        })
-      );
-      this.$.diffBuilder.showContext(e.detail.groups, e.detail.section);
-    } else if (
+    if (
       el.getAttribute('data-value') !== 'LOST' &&
       (el.classList.contains('lineNum') ||
         el.classList.contains('lineNumButton'))
@@ -776,7 +768,7 @@
    * render once.
    */
   _debounceRenderDiffTable() {
-    this.debounce(RENDER_DIFF_TABLE_DEBOUNCE_NAME, () =>
+    this.renderDiffTableTask = debounce(this.renderDiffTableTask, () =>
       this._renderDiffTable()
     );
   }
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_html.ts b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_html.ts
index 12803b3..4029e90 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_html.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_html.ts
@@ -580,7 +580,8 @@
   </div>
   <div
     class$="[[_computeContainerClass(loggedIn, viewMode, displayLine)]]"
-    on-tap="_handleTap"
+    on-click="_handleTap"
+    on-diff-context-expanded="_handleDiffContextExpanded"
   >
     <gr-diff-selection diff="[[diff]]">
       <gr-diff-highlight
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js
index c6bd8d6..488dd75 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js
@@ -52,15 +52,17 @@
       sinon.stub(element.$.highlights, 'handleSelectionChange');
     });
 
-    test('enabled if logged in', () => {
+    test('enabled if logged in', async () => {
       element.loggedIn = true;
       emulateSelection();
+      await flush();
       assert.isTrue(element.$.highlights.handleSelectionChange.called);
     });
 
-    test('ignored if logged out', () => {
+    test('ignored if logged out', async () => {
       element.loggedIn = false;
       emulateSelection();
+      await flush();
       assert.isFalse(element.$.highlights.handleSelectionChange.called);
     });
   });
@@ -460,7 +462,7 @@
       const el = document.createElement('div');
       el.className = 'showContext';
       el.addEventListener('click', e => {
-        element._handleTap(e);
+        element._handleDiffContextExpanded(e);
         assert.isTrue(showContextStub.called);
         done();
       });
@@ -660,14 +662,14 @@
           change_type: 'MODIFIED',
           content: [{skip: 66}],
         };
-        element.flushDebouncer('renderDiffTable');
+        element.renderDiffTableTask.flush();
       });
 
       test('change in preferences re-renders diff', () => {
         sinon.stub(element, '_renderDiffTable');
         element.prefs = {
           ...MINIMAL_PREFS, time_format: 'HHMM_12'};
-        element.flushDebouncer('renderDiffTable');
+        element.renderDiffTableTask.flush();
         assert.isTrue(element._renderDiffTable.called);
       });
 
@@ -676,14 +678,14 @@
         const newPrefs1 = {...MINIMAL_PREFS,
           line_wrapping: true};
         element.prefs = newPrefs1;
-        element.flushDebouncer('renderDiffTable');
+        element.renderDiffTableTask.flush();
         assert.isTrue(element._renderDiffTable.called);
         stub.reset();
 
         const newPrefs2 = {...newPrefs1};
         delete newPrefs2.line_wrapping;
         element.prefs = newPrefs2;
-        element.flushDebouncer('renderDiffTable');
+        element.renderDiffTableTask.flush();
         assert.isTrue(element._renderDiffTable.called);
       });
 
@@ -693,7 +695,7 @@
         element.noRenderOnPrefsChange = true;
         element.prefs = {
           ...MINIMAL_PREFS, time_format: 'HHMM_12'};
-        element.flushDebouncer('renderDiffTable');
+        element.renderDiffTableTask.flush();
         assert.isFalse(element._renderDiffTable.called);
       });
     });
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts
index ad894ce..4b53269 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts
@@ -18,7 +18,6 @@
 import '../../shared/gr-dropdown-list/gr-dropdown-list';
 import '../../shared/gr-select/gr-select';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-patch-range-select_html';
 import {pluralize} from '../../../utils/string-util';
@@ -81,10 +80,9 @@
  *
  * @property {string} patchNum
  * @property {string} basePatchNum
- * @extends PolymerElement
  */
 @customElement('gr-patch-range-select')
-export class GrPatchRangeSelect extends LegacyElementMixin(PolymerElement) {
+export class GrPatchRangeSelect extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.ts b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.ts
index 45a7de6..11712dc 100644
--- a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.ts
+++ b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import {GrAnnotation} from '../gr-diff-highlight/gr-annotation';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-ranged-comment-layer_html';
 import {GrDiffLine, GrDiffLineType} from '../gr-diff/gr-diff-line';
@@ -71,8 +70,7 @@
 const HOVER_HIGHLIGHT = 'style-scope gr-diff range rangeHoverHighlight';
 
 @customElement('gr-ranged-comment-layer')
-export class GrRangedCommentLayer extends LegacyElementMixin(PolymerElement)
-  implements DiffLayer {
+export class GrRangedCommentLayer extends PolymerElement implements DiffLayer {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
index 3e67c49..3b026b3 100644
--- a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
+++ b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
@@ -18,7 +18,6 @@
 import {GrTooltip} from '../../shared/gr-tooltip/gr-tooltip';
 import {customElement, property} from '@polymer/decorators';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-selection-action-box_html';
 import {fireEvent} from '../../../utils/event-util';
@@ -36,7 +35,7 @@
 }
 
 @customElement('gr-selection-action-box')
-export class GrSelectionActionBox extends LegacyElementMixin(PolymerElement) {
+export class GrSelectionActionBox extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -53,10 +52,8 @@
   @property({type: Boolean})
   positionBelow = false;
 
-  /** @override */
-  created() {
-    super.created();
-
+  constructor() {
+    super();
     // See https://crbug.com/gerrit/4767
     this.addEventListener('mousedown', e => this._handleMouseDown(e));
   }
diff --git a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts
index aff9c3d..7e4edd6 100644
--- a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts
+++ b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts
@@ -17,7 +17,6 @@
 import '../../../styles/gr-table-styles';
 import '../../../styles/shared-styles';
 import '../../shared/gr-list-view/gr-list-view';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-documentation-search_html';
 import {
@@ -31,9 +30,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-documentation-search')
-export class GrDocumentationSearch extends ListViewMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrDocumentationSearch extends ListViewMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -56,8 +53,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     fireTitleChange(this, 'Documentation Search');
   }
 
diff --git a/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts b/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts
index eff2d94..2828918 100644
--- a/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts
+++ b/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-default-editor_html';
 import {customElement, property} from '@polymer/decorators';
@@ -31,8 +30,7 @@
 }
 
 @customElement('gr-default-editor')
-/** @extends PolymerElement */
-export class GrDefaultEditor extends LegacyElementMixin(PolymerElement) {
+export class GrDefaultEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
index e9dc40c..5746d73 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
@@ -22,7 +22,6 @@
 import '../../shared/gr-overlay/gr-overlay';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-edit-controls_html';
 import {GrEditAction, GrEditConstants} from '../gr-edit-constants';
@@ -48,7 +47,7 @@
 }
 
 @customElement('gr-edit-controls')
-export class GrEditControls extends LegacyElementMixin(PolymerElement) {
+export class GrEditControls extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -164,7 +163,7 @@
       if (autocomplete) {
         autocomplete.focus();
       }
-      this.async(() => {
+      setTimeout(() => {
         this.$.overlay.center();
       }, 1);
     });
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
index 609cda2..d2e1d64 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
@@ -17,7 +17,6 @@
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-dropdown/gr-dropdown';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-edit-file-controls_html';
 import {GrEditConstants} from '../gr-edit-constants';
@@ -28,9 +27,8 @@
   id: string;
 }
 
-/** @extends PolymerElement */
 @customElement('gr-edit-file-controls')
-class GrEditFileControls extends LegacyElementMixin(PolymerElement) {
+class GrEditFileControls extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
index dd9592d..fb8c2e0 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
@@ -18,10 +18,8 @@
 import '../../plugins/gr-endpoint-param/gr-endpoint-param';
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-editable-label/gr-editable-label';
-import '../../shared/gr-storage/gr-storage';
 import '../gr-default-editor/gr-default-editor';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-editor-view_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -39,12 +37,12 @@
   NumericChangeId,
   EditPatchSetNum,
 } from '../../../types/common';
-import {GrStorage} from '../../shared/gr-storage/gr-storage';
 import {HttpMethod, NotifyType} from '../../../constants/constants';
 import {fireAlert, fireTitleChange} from '../../../utils/event-util';
 import {appContext} from '../../../services/app-context';
 import {ErrorCallback} from '../../../api/rest';
 import {assertIsDefined} from '../../../utils/common-util';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 
 const RESTORED_MESSAGE = 'Content restored from a previous edit.';
 const SAVING_MESSAGE = 'Saving changes...';
@@ -55,12 +53,8 @@
 
 const STORAGE_DEBOUNCE_INTERVAL_MS = 100;
 
-const DEBOUNCER_STORE = 'store';
-
 @customElement('gr-editor-view')
-export class GrEditorView extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrEditorView extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -121,7 +115,9 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  private readonly storage = new GrStorage();
+  private readonly storage = appContext.storageService;
+
+  private storeTask?: DelayedTask;
 
   reporting = appContext.reportingService;
 
@@ -131,25 +127,25 @@
     };
   }
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('content-change', e => {
       this._handleContentChange(e as CustomEvent<{value: string}>);
     });
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._getEditPrefs().then(prefs => {
       this._prefs = prefs;
     });
   }
 
   /** @override */
-  detached() {
-    this.cancelDebouncer(DEBOUNCER_STORE);
+  disconnectedCallback() {
+    this.storeTask?.cancel();
+    super.disconnectedCallback();
   }
 
   get storageKey() {
@@ -178,7 +174,7 @@
     // NOTE: This may be called before attachment (e.g. while parentElement is
     // null). Fire title-change in an async so that, if attachment to the DOM
     // has been queued, the event can bubble up to the handler in gr-app.
-    this.async(() => {
+    setTimeout(() => {
       const title = `Editing ${computeTruncatedPath(value.path)}`;
       fireTitleChange(this, title);
     });
@@ -354,8 +350,8 @@
   }
 
   _handleContentChange(e: CustomEvent<{value: string}>) {
-    this.debounce(
-      DEBOUNCER_STORE,
+    this.storeTask = debounce(
+      this.storeTask,
       () => {
         const content = e.detail.value;
         if (content) {
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.js b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.js
index 8512545..a29d45d 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.js
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view_test.js
@@ -109,7 +109,7 @@
       bubbles: true, composed: true,
       detail: {value: 'new content value'},
     }));
-    element.flushDebouncer('store');
+    element.storeTask.flush();
     flush();
 
     assert.equal(element._newContent, 'new content value');
diff --git a/polygerrit-ui/app/elements/gr-app-element.ts b/polygerrit-ui/app/elements/gr-app-element.ts
index 009e9a6..20d1801 100644
--- a/polygerrit-ui/app/elements/gr-app-element.ts
+++ b/polygerrit-ui/app/elements/gr-app-element.ts
@@ -37,7 +37,6 @@
 import './settings/gr-cla-view/gr-cla-view';
 import './settings/gr-registration-dialog/gr-registration-dialog';
 import './settings/gr-settings-view/gr-settings-view';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-app-element_html';
 import {getBaseUrl} from '../utils/url-util';
@@ -74,12 +73,13 @@
   ShortcutTriggeredEvent,
   TitleChangeEventDetail,
   DialogChangeEventDetail,
+  EventType,
 } from '../types/events';
 import {ViewState} from '../types/types';
-import {EventType} from '../utils/event-util';
 import {GerritView} from '../services/router/router-model';
 import {windowLocationReload} from '../utils/dom-util';
 import {LifeCycle} from '../constants/reporting';
+import {fireIronAnnounce} from '../utils/event-util';
 
 interface ErrorInfo {
   text: string;
@@ -98,9 +98,7 @@
 
 // TODO(TS): implement AppElement interface from gr-app-types.ts
 @customElement('gr-app-element')
-export class GrAppElement extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrAppElement extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -219,9 +217,8 @@
     };
   }
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this._bindKeyboardShortcuts();
     document.addEventListener(EventType.PAGE_ERROR, e => {
       this._handlePageError(e);
@@ -485,7 +482,7 @@
     // because _showPluginScreen value does not change. To force restamp,
     // change _showPluginScreen value between true and false.
     if (isPluginScreen) {
-      this.async(() => this.set('_showPluginScreen', true), 1);
+      setTimeout(() => this.set('_showPluginScreen', true), 1);
     }
     this.set(
       '_showDocumentationSearch',
@@ -511,7 +508,7 @@
     }
     // To fix bug announce read after each new view, we reset announce with
     // empty space
-    this.fire('iron-announce', {text: ' '}, {bubbles: true});
+    fireIronAnnounce(this, ' ');
   }
 
   _handleShortcutTriggered(event: ShortcutTriggeredEvent) {
@@ -547,17 +544,19 @@
     this.$.errorView.classList.add('show');
     const response = e.detail.response;
     const err: ErrorInfo = {
-      text: [response.status, response.statusText].join(' '),
+      text: [response?.status, response?.statusText].join(' '),
     };
-    if (response.status === 404) {
+    if (response?.status === 404) {
       err.emoji = '¯\\_(ツ)_/¯';
       this._lastError = err;
     } else {
       err.emoji = 'o_O';
-      response.text().then(text => {
-        err.moreInfo = text;
-        this._lastError = err;
-      });
+      if (response) {
+        response.text().then(text => {
+          err.moreInfo = text;
+          this._lastError = err;
+        });
+      }
     }
   }
 
diff --git a/polygerrit-ui/app/elements/gr-app-global-var-init.ts b/polygerrit-ui/app/elements/gr-app-global-var-init.ts
index 8a632bb..85a6d49 100644
--- a/polygerrit-ui/app/elements/gr-app-global-var-init.ts
+++ b/polygerrit-ui/app/elements/gr-app-global-var-init.ts
@@ -23,57 +23,16 @@
  */
 
 import {GrAnnotation} from './diff/gr-diff-highlight/gr-annotation';
-import {GrDiffLine, GrDiffLineType} from './diff/gr-diff/gr-diff-line';
-import {GrDiffGroup, GrDiffGroupType} from './diff/gr-diff/gr-diff-group';
-import {getPluginEndpoints} from './shared/gr-js-api-interface/gr-plugin-endpoints';
-import {util} from '../scripts/util';
 import {page} from '../utils/page-wrapper-utils';
 import {appContext} from '../services/app-context';
-import {
-  getPluginLoader,
-  PluginLoader,
-} from './shared/gr-js-api-interface/gr-plugin-loader';
 import {GrPluginActionContext} from './shared/gr-js-api-interface/gr-plugin-action-context';
-import {
-  getPluginNameFromUrl,
-  PLUGIN_LOADING_TIMEOUT_MS,
-  PRELOADED_PROTOCOL,
-  send,
-} from './shared/gr-js-api-interface/gr-api-utils';
-import {getBaseUrl} from '../utils/url-util';
 import {GerritNav} from './core/gr-navigation/gr-navigation';
-import {getRootElement} from '../scripts/rootElement';
-import {RevisionInfo} from './shared/revision-info/revision-info';
 
 export function initGlobalVariables() {
   window.GrAnnotation = GrAnnotation;
-  window.GrDiffLine = GrDiffLine;
-  window.GrDiffLineType = GrDiffLineType;
-  window.GrDiffGroup = GrDiffGroup;
-  window.GrDiffGroupType = GrDiffGroupType;
-  window.util = util;
   window.page = page;
-  window.Auth = appContext.authService;
-  window.EventEmitter = appContext.eventEmitter;
-  window.PluginLoader = PluginLoader;
   window.GrPluginActionContext = GrPluginActionContext;
-
-  window._apiUtils = {
-    getPluginNameFromUrl,
-    send,
-    getBaseUrl,
-    PRELOADED_PROTOCOL,
-    PLUGIN_LOADING_TIMEOUT_MS,
-  };
-
   window.Gerrit = window.Gerrit || {};
   window.Gerrit.Nav = GerritNav;
-  window.Gerrit.getRootElement = getRootElement;
   window.Gerrit.Auth = appContext.authService;
-
-  window.Gerrit._pluginLoader = getPluginLoader();
-  // TODO: should define as a getter
-  window.Gerrit._endpoints = getPluginEndpoints();
-
-  window.Gerrit.RevisionInfo = RevisionInfo;
 }
diff --git a/polygerrit-ui/app/elements/gr-app-types.ts b/polygerrit-ui/app/elements/gr-app-types.ts
index c0779a7..2ae85f7 100644
--- a/polygerrit-ui/app/elements/gr-app-types.ts
+++ b/polygerrit-ui/app/elements/gr-app-types.ts
@@ -24,8 +24,8 @@
   DashboardId,
   GroupId,
   NumericChangeId,
-  PatchSetNum,
   RepoName,
+  RevisionPatchSetNum,
   UrlEncodedCommentId,
 } from '../types/common';
 import {GerritView} from '../services/router/router-model';
@@ -100,7 +100,7 @@
   project?: RepoName;
   commentId?: UrlEncodedCommentId;
   path?: string;
-  patchNum?: PatchSetNum;
+  patchNum?: RevisionPatchSetNum;
   basePatchNum?: BasePatchSetNum;
   lineNum: number;
   leftSide?: boolean;
@@ -111,7 +111,7 @@
   changeNum: NumericChangeId;
   project: RepoName;
   edit?: boolean;
-  patchNum?: PatchSetNum;
+  patchNum?: RevisionPatchSetNum;
   basePatchNum?: BasePatchSetNum;
   queryMap?: Map<string, string> | URLSearchParams;
 }
diff --git a/polygerrit-ui/app/elements/gr-app.ts b/polygerrit-ui/app/elements/gr-app.ts
index 2e7618a..463fab9 100644
--- a/polygerrit-ui/app/elements/gr-app.ts
+++ b/polygerrit-ui/app/elements/gr-app.ts
@@ -36,7 +36,6 @@
 
 import {initGlobalVariables} from './gr-app-global-var-init';
 import './gr-app-element';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-app_html';
 import {initGerritPluginApi} from './shared/gr-js-api-interface/gr-gerrit';
@@ -46,7 +45,7 @@
 installPolymerResin(safeTypesBridge);
 
 @customElement('gr-app')
-class GrApp extends LegacyElementMixin(PolymerElement) {
+export class GrApp extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/gr-app_test.js b/polygerrit-ui/app/elements/gr-app_test.js
deleted file mode 100644
index 1a04411..0000000
--- a/polygerrit-ui/app/elements/gr-app_test.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../test/common-test-setup-karma.js';
-import './gr-app.js';
-import {appContext} from '../services/app-context.js';
-import {GerritNav} from './core/gr-navigation/gr-navigation.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-import {stubRestApi} from '../test/test-utils.js';
-
-const basicFixture = fixtureFromTemplate(html`<gr-app id="app"></gr-app>`);
-
-suite('gr-app tests', () => {
-  let element;
-  let configStub;
-
-  setup(done => {
-    sinon.stub(appContext.reportingService, 'appStarted');
-    stub('gr-account-dropdown', {
-      _getTopContent: sinon.stub(),
-    });
-    stub('gr-router', {
-      start: sinon.stub(),
-    });
-    stubRestApi('getAccount').returns(Promise.resolve({}));
-    stubRestApi('getAccountCapabilities').returns(Promise.resolve({}));
-    configStub = stubRestApi('getConfig').returns(Promise.resolve({
-      plugin: {},
-      auth: {
-        auth_type: undefined,
-      },
-    }));
-    stubRestApi('getPreferences').returns(Promise.resolve({my: []}));
-    stubRestApi('getVersion').returns(Promise.resolve(42));
-    stubRestApi('probePath').returns(Promise.resolve(42));
-
-    element = basicFixture.instantiate();
-    flush(done);
-  });
-
-  const appElement = () => element.$['app-element'];
-
-  test('reporting', () => {
-    assert.isTrue(appElement().reporting.appStarted.calledOnce);
-  });
-
-  test('reporting called before router start', () => {
-    const element = appElement();
-    const appStartedStub = element.reporting.appStarted;
-    const routerStartStub = element.$.router.start;
-    sinon.assert.callOrder(appStartedStub, routerStartStub);
-  });
-
-  test('passes config to gr-plugin-host', () =>
-    configStub.lastCall.returnValue.then(config => {
-      assert.deepEqual(appElement().$.plugins.config, config);
-    })
-  );
-
-  test('_paramsChanged sets search page', () => {
-    appElement()._paramsChanged({base: {view: GerritNav.View.CHANGE}});
-    assert.notOk(appElement()._lastSearchPage);
-    appElement()._paramsChanged({base: {view: GerritNav.View.SEARCH}});
-    assert.ok(appElement()._lastSearchPage);
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/gr-app_test.ts b/polygerrit-ui/app/elements/gr-app_test.ts
new file mode 100644
index 0000000..3583a6a
--- /dev/null
+++ b/polygerrit-ui/app/elements/gr-app_test.ts
@@ -0,0 +1,82 @@
+/**
+ * @license
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import '../test/common-test-setup-karma';
+import {GrApp} from './gr-app';
+import {appContext} from '../services/app-context';
+import {html} from '@polymer/polymer/lib/utils/html-tag';
+import {queryAndAssert} from '../test/test-utils';
+import {createServerInfo} from '../test/test-data-generators';
+import {GrAppElement} from './gr-app-element';
+import {GrPluginHost} from './plugins/gr-plugin-host/gr-plugin-host';
+import {GerritView} from '../services/router/router-model';
+import {
+  AppElementChangeViewParams,
+  AppElementSearchParam,
+} from './gr-app-types';
+import {GrRouter} from './core/gr-router/gr-router';
+import {ReportingService} from '../services/gr-reporting/gr-reporting';
+
+const basicFixture = fixtureFromTemplate(html`<gr-app id="app"></gr-app>`);
+
+suite('gr-app tests', () => {
+  let element: GrApp;
+  let appStartedStub: sinon.SinonStubbedMember<ReportingService['appStarted']>;
+  let routerStartStub: sinon.SinonStubbedMember<GrRouter['start']>;
+
+  setup(done => {
+    appStartedStub = sinon.stub(appContext.reportingService, 'appStarted');
+    routerStartStub = stub('gr-router', 'start');
+    stub('gr-account-dropdown', '_getTopContent');
+
+    element = basicFixture.instantiate() as GrApp;
+    flush(done);
+  });
+
+  const appElement = () =>
+    queryAndAssert<GrAppElement>(element, '#app-element');
+
+  test('reporting', () => {
+    assert.isTrue(appStartedStub.calledOnce);
+  });
+
+  test('reporting called before router start', () => {
+    sinon.assert.callOrder(appStartedStub, routerStartStub);
+  });
+
+  test('passes config to gr-plugin-host', () => {
+    assert.deepEqual(
+      queryAndAssert<GrPluginHost>(appElement(), 'gr-plugin-host').config,
+      createServerInfo()
+    );
+  });
+
+  test('_paramsChanged sets search page', () => {
+    appElement()._paramsChanged({
+      path: '',
+      value: undefined,
+      base: {view: GerritView.CHANGE} as AppElementChangeViewParams,
+    });
+    assert.notOk(appElement()._lastSearchPage);
+    appElement()._paramsChanged({
+      path: '',
+      value: undefined,
+      base: {view: GerritView.SEARCH} as AppElementSearchParam,
+    });
+    assert.ok(appElement()._lastSearchPage);
+  });
+});
diff --git a/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.ts b/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.ts
deleted file mode 100644
index bbb58fc..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @license
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {PluginApi} from '../../../api/plugin';
-import {ChangeMetadataPluginApi} from '../../../api/change-metadata';
-import {HookApi} from '../../../api/hook';
-import {appContext} from '../../../services/app-context';
-
-export class GrChangeMetadataApi implements ChangeMetadataPluginApi {
-  private hook: HookApi | null;
-
-  public plugin: PluginApi;
-
-  private readonly reporting = appContext.reportingService;
-
-  constructor(plugin: PluginApi) {
-    this.plugin = plugin;
-    this.hook = null;
-    this.reporting.trackApi(this.plugin, 'metadata', 'constructor');
-  }
-
-  _createHook() {
-    this.hook = this.plugin.hook('change-metadata-item');
-  }
-
-  onLabelsChanged(callback: (value: unknown) => void) {
-    this.reporting.trackApi(this.plugin, 'metadata', 'onLabelsChanged');
-    if (!this.hook) {
-      this._createHook();
-    }
-    this.hook!.onAttached((element: Element) =>
-      this.plugin.attributeHelper(element).bind('labels', callback)
-    );
-    return this;
-  }
-}
diff --git a/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api_test.ts b/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api_test.ts
index 3ab3efb..e1ec158 100644
--- a/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api_test.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api_test.ts
@@ -15,9 +15,9 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
+import '../../../test/common-test-setup-karma';
+import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader';
+import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit';
 import {PluginApi} from '../../../api/plugin';
 import {ChecksPluginApi} from '../../../api/checks';
 
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
index 998e84e..0e8cbcb 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-endpoint-decorator_html';
 import {
@@ -29,7 +28,7 @@
 const INIT_PROPERTIES_TIMEOUT_MS = 10000;
 
 @customElement('gr-endpoint-decorator')
-export class GrEndpointDecorator extends LegacyElementMixin(PolymerElement) {
+export class GrEndpointDecorator extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -51,12 +50,12 @@
   _endpointCallBack: (info: ModuleInfo) => void = () => {};
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     for (const [el, domHook] of this._domHooks) {
       domHook.handleInstanceDetached(el);
     }
     getPluginEndpoints().onDetachedEndpoint(this.name, this._endpointCallBack);
+    super.disconnectedCallback();
   }
 
   _initDecoration(
@@ -68,7 +67,9 @@
     return this._initProperties(
       el,
       plugin,
-      this.getContentChildren().find(el => el.nodeName !== 'GR-ENDPOINT-PARAM')
+      // The direct children are slotted into <slot>, so this is identical to
+      // this.shadowRoot.querySelector('slot').assignedElements()[0].
+      this.firstElementChild
     ).then(el => {
       const slotEl = slot
         ? this.querySelector(`gr-endpoint-slot[name=${slot}]`)
@@ -82,9 +83,16 @@
     });
   }
 
+  // As of March 2021 the only known plugin that replaces an endpoint instead
+  // of decorating it is codemirror_editor.
   _initReplacement(name: string, plugin: PluginApi): Promise<HTMLElement> {
-    this.getContentChildNodes()
+    // The direct children are slotted into <slot>, so they are identical to
+    // this.shadowRoot.querySelector('slot').assignedElements().
+    const directChildren = [...this.childNodes];
+    const shadowChildren = [...(this.shadowRoot?.childNodes ?? [])];
+    [...directChildren, ...shadowChildren]
       .filter(node => node.nodeName !== 'GR-ENDPOINT-PARAM')
+      .filter(node => node.nodeName !== 'SLOT')
       .forEach(node => (node as ChildNode).remove());
     const el = document.createElement(name);
     return this._initProperties(el, plugin).then((el: HTMLElement) =>
@@ -99,13 +107,16 @@
   _initProperties(
     htmlEl: HTMLElement,
     plugin: PluginApi,
-    content?: HTMLElement
+    content?: Element | null
   ) {
     const el = htmlEl as HTMLElement & {
       plugin?: PluginApi;
-      content?: HTMLElement;
+      content?: Element;
     };
     el.plugin = plugin;
+    // The content is (only?) used in ChangeReplyPluginApi.
+    // Maybe it would be better for the consumer side to figure out the content
+    // with something like el.getRootNode().host, etc.
     if (content) {
       el.content = content;
     }
@@ -181,7 +192,6 @@
     if (this.name) {
       getPluginLoader()
         .awaitPluginsLoaded()
-        .then(() => getPluginEndpoints().getAndImportPlugins(this.name))
         .then(() =>
           getPluginEndpoints()
             .getDetails(this.name)
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js
index c48258d..8138ff0 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 import '../../../test/common-test-setup-karma.js';
 import './gr-endpoint-decorator.js';
 import '../gr-endpoint-param/gr-endpoint-param.js';
@@ -22,7 +21,6 @@
 import {html} from '@polymer/polymer/lib/utils/html-tag.js';
 import {resetPlugins} from '../../../test/test-utils.js';
 import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
 import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
 
 const pluginApi = _testOnly_initGerritPluginApi();
@@ -56,10 +54,8 @@
   setup(done => {
     resetPlugins();
     container = basicFixture.instantiate();
-    sinon.stub(getPluginEndpoints(), 'importUrl')
-        .callsFake( url => Promise.resolve());
     pluginApi.install(p => plugin = p, '0.1',
-        'http://some/plugin/url.html');
+        'http://some/plugin/url.js');
     // Decoration
     decorationHook = plugin.registerCustomComponent('first', 'some-module');
     decorationHookWithSlot = plugin.registerCustomComponent(
@@ -83,9 +79,6 @@
     const endpoints =
         Array.from(container.querySelectorAll('gr-endpoint-decorator'));
     assert.equal(endpoints.length, 3);
-    assert.isTrue(getPluginEndpoints().importUrl.calledWith(
-        new URL('http://some/plugin/url.html')
-    ));
   });
 
   test('decoration', () => {
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.ts b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.ts
index f48bb0f..ee89c86 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement, property} from '@polymer/decorators';
 
@@ -25,7 +24,7 @@
 }
 
 @customElement('gr-endpoint-param')
-export class GrEndpointParam extends LegacyElementMixin(PolymerElement) {
+export class GrEndpointParam extends PolymerElement {
   @property({type: String, reflectToAttribute: true})
   name = '';
 
diff --git a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.ts b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.ts
index 0c2f412..0c6dd4d 100644
--- a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.ts
@@ -21,11 +21,6 @@
 import {PluginApi} from '../../../api/plugin';
 import {appContext} from '../../../services/app-context';
 
-export interface ListenOptions {
-  event?: string;
-  capture?: boolean;
-}
-
 export class GrEventHelper implements EventHelperPluginApi {
   private readonly reporting = appContext.reportingService;
 
@@ -34,15 +29,6 @@
   }
 
   /**
-   * Add a callback to arbitrary event.
-   * The callback may return false to prevent event bubbling.
-   */
-  on(event: string, callback: (event: Event) => boolean) {
-    this.reporting.trackApi(this.plugin, 'event', 'on');
-    return this._listen(this.element, callback, {event});
-  }
-
-  /**
    * Alias for @see onClick
    */
   onTap(callback: (event: Event) => boolean) {
@@ -59,33 +45,10 @@
     return this._listen(this.element, callback);
   }
 
-  /**
-   * Alias for @see captureClick
-   */
-  captureTap(callback: (event: Event) => boolean) {
-    this.reporting.trackApi(this.plugin, 'event', 'captureTap');
-    return this.captureClick(callback);
-  }
-
-  /**
-   * Add a callback to element click or touch ahead of normal flow.
-   * Callback is installed on parent during capture phase.
-   * https://www.w3.org/TR/DOM-Level-3-Events/#event-flow
-   * The callback may return false to cancel regular event listeners.
-   */
-  captureClick(callback: (event: Event) => boolean) {
-    this.reporting.trackApi(this.plugin, 'event', 'captureClick');
-    const parent = this.element.parentElement!;
-    return this._listen(parent, callback, {capture: true});
-  }
-
   _listen(
     container: HTMLElement,
-    callback: (event: Event) => boolean,
-    options?: ListenOptions | null
+    callback: (event: Event) => boolean
   ): UnsubscribeCallback {
-    const capture = options?.capture;
-    const event = options?.event || 'click';
     const handler = (e: Event) => {
       const path = e.composedPath();
       if (!path) return;
@@ -103,9 +66,8 @@
         }
       }
     };
-    container.addEventListener(event, handler, capture);
-    const unsubscribe = () =>
-      container.removeEventListener(event, handler, capture);
+    container.addEventListener('click', handler);
+    const unsubscribe = () => container.removeEventListener('click', handler);
     return unsubscribe;
   }
 }
diff --git a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.js b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.js
index 547b575..6291e64 100644
--- a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.js
@@ -71,47 +71,5 @@
     flush();
     assert.isFalse(tapStub.called);
   });
-
-  test('captureTap()', done => {
-    instance.captureTap(() => {
-      done();
-    });
-    MockInteractions.tap(element);
-  });
-
-  test('captureClick()', done => {
-    instance.captureClick(() => {
-      done();
-    });
-    MockInteractions.tap(element);
-  });
-
-  test('captureTap() cancels tap()', () => {
-    const tapStub = sinon.stub();
-    addListener(element.parentElement, 'tap', tapStub);
-    instance.captureTap(() => false);
-    MockInteractions.tap(element);
-    flush();
-    assert.isFalse(tapStub.called);
-  });
-
-  test('captureClick() cancels click()', () => {
-    const tapStub = sinon.stub();
-    element.addEventListener('click', tapStub);
-    instance.captureTap(() => false);
-    MockInteractions.tap(element);
-    flush();
-    assert.isFalse(tapStub.called);
-  });
-
-  test('on()', done => {
-    instance.on('foo', () => {
-      done();
-    });
-    element.dispatchEvent(
-        new CustomEvent('foo', {
-          composed: true, bubbles: true,
-        }));
-  });
 });
 
diff --git a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
index b4fd804..007e4c2 100644
--- a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import {updateStyles} from '@polymer/polymer/lib/mixins/element-mixin';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-external-style_html';
 import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
@@ -23,7 +22,7 @@
 import {customElement, property} from '@polymer/decorators';
 
 @customElement('gr-external-style')
-class GrExternalStyle extends LegacyElementMixin(PolymerElement) {
+class GrExternalStyle extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -53,19 +52,15 @@
   }
 
   _importAndApply() {
-    getPluginEndpoints()
-      .getAndImportPlugins(this.name)
-      .then(() => {
-        const moduleNames = getPluginEndpoints().getModules(this.name);
-        for (const name of moduleNames) {
-          this._applyStyle(name);
-        }
-      });
+    const moduleNames = getPluginEndpoints().getModules(this.name);
+    for (const name of moduleNames) {
+      this._applyStyle(name);
+    }
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._importAndApply();
   }
 
diff --git a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js
index ad30f48..a192f80 100644
--- a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js
@@ -14,12 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 import '../../../test/common-test-setup-karma.js';
 import {resetPlugins} from '../../../test/test-utils.js';
 import './gr-external-style.js';
 import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
 import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
 import {html} from '@polymer/polymer/lib/utils/html-tag.js';
 
@@ -30,7 +28,7 @@
 );
 
 suite('gr-external-style integration tests', () => {
-  const TEST_URL = 'http://some.com/plugins/url.html';
+  const TEST_URL = 'http://some.com/plugins/url.js';
 
   let element;
   let plugin;
@@ -66,8 +64,6 @@
   };
 
   setup(() => {
-    sinon.stub(getPluginEndpoints(), 'importUrl')
-        .callsFake( url => Promise.resolve());
     sinon.stub(getPluginLoader(), 'awaitPluginsLoaded')
         .returns(Promise.resolve());
   });
@@ -78,27 +74,12 @@
         .forEach(style => style.remove());
   });
 
-  test('imports plugin-provided module', async () => {
-    lateRegister();
-    await new Promise(flush);
-    assert.isTrue(getPluginEndpoints().importUrl.calledWith(new URL(TEST_URL)));
-  });
-
   test('applies plugin-provided styles', async () => {
     lateRegister();
     await new Promise(flush);
     assert.isTrue(element._applyStyle.calledWith('some-module'));
   });
 
-  test('does not double import', async () => {
-    earlyRegister();
-    await new Promise(flush);
-    plugin.registerStyleModule('foo', 'some-module');
-    await new Promise(flush);
-    // since loaded, should not call again
-    assert.isFalse(getPluginEndpoints().importUrl.calledOnce);
-  });
-
   test('does not double apply', async () => {
     earlyRegister();
     await new Promise(flush);
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
index 70087a5..651eac4 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
@@ -14,24 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader';
 import {customElement, property} from '@polymer/decorators';
 import {ServerInfo} from '../../../types/common';
 
 @customElement('gr-plugin-host')
-class GrPluginHost extends LegacyElementMixin(PolymerElement) {
+export class GrPluginHost extends PolymerElement {
   @property({type: Object, observer: '_configChanged'})
   config?: ServerInfo;
 
   _configChanged(config: ServerInfo) {
     const plugins = config.plugin;
-    const htmlPlugins = (plugins && plugins.html_resource_paths) || [];
-    const jsPlugins = this._handleMigrations(
-      (plugins && plugins.js_resource_paths) || [],
-      htmlPlugins
-    );
+    const jsPlugins = (plugins && plugins.js_resource_paths) || [];
     const shouldLoadTheme =
       !!config.default_theme &&
       !getPluginLoader().isPluginPreloaded('preloaded:gerrit-theme');
@@ -39,30 +34,9 @@
     const themeToLoad: string[] = shouldLoadTheme
       ? [config.default_theme!]
       : [];
-
-    // Theme should be loaded first if has one to have better UX
-    const pluginsPending = themeToLoad.concat(jsPlugins, htmlPlugins);
-
-    const pluginOpts: {[key: string]: {sync: boolean}} = {};
-
-    if (shouldLoadTheme) {
-      // config.default_theme is defined when shouldLoadTheme is true
-      // Theme needs to be loaded synchronous.
-      pluginOpts[config.default_theme!] = {sync: true};
-    }
-
-    getPluginLoader().loadPlugins(pluginsPending, pluginOpts);
-  }
-
-  /**
-   * Omit .js plugins that have .html counterparts.
-   * For example, if plugin provides foo.js and foo.html, skip foo.js.
-   */
-  _handleMigrations(jsPlugins: string[], htmlPlugins: string[]) {
-    return jsPlugins.filter(url => {
-      const counterpart = url.replace(/\.js$/, '.html');
-      return !htmlPlugins.includes(counterpart);
-    });
+    // Theme should be loaded first for better UX.
+    const pluginsPending = themeToLoad.concat(jsPlugins);
+    getPluginLoader().loadPlugins(pluginsPending);
   }
 }
 
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js
index 7a99dc4..3d35aa4 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js
@@ -34,29 +34,27 @@
     sinon.stub(getPluginLoader(), 'loadPlugins');
     element.config = {
       plugin: {
-        html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
-        js_resource_paths: ['plugins/42'],
+        js_resource_paths: ['plugins/42', 'plugins/foo/bar', 'plugins/baz'],
       },
     };
     assert.isTrue(getPluginLoader().loadPlugins.calledOnce);
     assert.isTrue(getPluginLoader().loadPlugins.calledWith([
       'plugins/42', 'plugins/foo/bar', 'plugins/baz',
-    ], {}));
+    ]));
   });
 
   test('theme plugins should be loaded if enabled', () => {
     sinon.stub(getPluginLoader(), 'loadPlugins');
     element.config = {
-      default_theme: 'gerrit-theme.html',
+      default_theme: 'gerrit-theme.js',
       plugin: {
-        html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
-        js_resource_paths: ['plugins/42'],
+        js_resource_paths: ['plugins/42', 'plugins/foo/bar', 'plugins/baz'],
       },
     };
     assert.isTrue(getPluginLoader().loadPlugins.calledOnce);
     assert.isTrue(getPluginLoader().loadPlugins.calledWith([
-      'gerrit-theme.html', 'plugins/42', 'plugins/foo/bar', 'plugins/baz',
-    ], {'gerrit-theme.html': {sync: true}}));
+      'gerrit-theme.js', 'plugins/42', 'plugins/foo/bar', 'plugins/baz',
+    ]));
   });
 
   test('skip theme if preloaded', () => {
@@ -69,7 +67,7 @@
       plugin: {},
     };
     assert.isTrue(getPluginLoader().loadPlugins.calledOnce);
-    assert.isTrue(getPluginLoader().loadPlugins.calledWith([], {}));
+    assert.isTrue(getPluginLoader().loadPlugins.calledWith([]));
   });
 });
 
diff --git a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.ts b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.ts
index 227fab1..af6a159 100644
--- a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../shared/gr-overlay/gr-overlay';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-plugin-popup_html';
 import {GrOverlay} from '../../shared/gr-overlay/gr-overlay';
@@ -33,7 +32,7 @@
   };
 }
 @customElement('gr-plugin-popup')
-export class GrPluginPopup extends LegacyElementMixin(PolymerElement) {
+export class GrPluginPopup extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.js b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.js
index f2d83e8..6ce77b1 100644
--- a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.js
@@ -25,10 +25,8 @@
 
   setup(() => {
     element = basicFixture.instantiate();
-    stub('gr-overlay', {
-      open: sinon.stub().returns(Promise.resolve()),
-      close: sinon.stub(),
-    });
+    stub('gr-overlay', 'open').callsFake(() => Promise.resolve());
+    stub('gr-overlay', 'close');
   });
 
   test('exists', () => {
diff --git a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command.ts b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command.ts
deleted file mode 100644
index a9aba13..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-plugin-repo-command_html';
-import {customElement, property} from '@polymer/decorators';
-import {fireEvent} from '../../../utils/event-util';
-
-declare global {
-  interface HTMLElementTagNameMap {
-    'gr-plugin-repo-command': GrPluginRepoCommand;
-  }
-}
-@customElement('gr-plugin-repo-command')
-export class GrPluginRepoCommand extends PolymerElement {
-  @property({type: String})
-  title = '';
-
-  static get template() {
-    return htmlTemplate;
-  }
-
-  _handleClick() {
-    fireEvent(this, 'command-tap');
-  }
-}
diff --git a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command_html.ts b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command_html.ts
deleted file mode 100644
index 6eee643..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command_html.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html`
-  <style include="shared-styles">
-    :host {
-      display: block;
-      margin-bottom: var(--spacing-xxl);
-    }
-  </style>
-  <h3>[[title]]</h3>
-  <gr-button on-click="_handleClick">[[title]]</gr-button>
-`;
diff --git a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.ts b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.ts
deleted file mode 100644
index 51e9112..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import './gr-plugin-repo-command';
-import {ConfigInfo} from '../../../types/common';
-import {PluginApi} from '../../../api/plugin';
-import {RepoCommandCallback, RepoPluginApi} from '../../../api/repo';
-import {HookApi} from '../../../api/hook';
-import {appContext} from '../../../services/app-context';
-
-/**
- * Parameters provided on repo-command endpoint
- */
-export interface GrRepoCommandEndpointEl extends HTMLElement {
-  repoName: string;
-  config: ConfigInfo;
-}
-
-export class GrRepoApi implements RepoPluginApi {
-  private hook?: HookApi;
-
-  private readonly reporting = appContext.reportingService;
-
-  constructor(readonly plugin: PluginApi) {
-    this.reporting.trackApi(this.plugin, 'repo', 'constructor');
-  }
-
-  // TODO(TS): should mark as public since used in gr-change-metadata-api
-  _createHook(title: string) {
-    return this.plugin.hook('repo-command').onAttached(element => {
-      const pluginCommand = document.createElement('gr-plugin-repo-command');
-      pluginCommand.title = title;
-      element.appendChild(pluginCommand);
-    });
-  }
-
-  createCommand(title: string, callback: RepoCommandCallback) {
-    this.reporting.trackApi(this.plugin, 'repo', 'createCommand');
-    if (this.hook) {
-      console.warn('Already set up.');
-      return this;
-    }
-    this.hook = this._createHook(title);
-    this.hook.onAttached(element => {
-      if (callback(element.repoName, element.config) === false) {
-        element.hidden = true;
-      }
-    });
-    return this;
-  }
-
-  onTap(callback: (event: Event) => boolean) {
-    this.reporting.trackApi(this.plugin, 'repo', 'onTap');
-    if (!this.hook) {
-      console.warn('Call createCommand first.');
-      return this;
-    }
-    this.hook.onAttached(element => {
-      this.plugin.eventHelper(element).on('command-tap', callback);
-    });
-    return this;
-  }
-}
diff --git a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api_test.js b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api_test.js
deleted file mode 100644
index 9e24fda..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api_test.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
-import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-
-const basicFixture = fixtureFromTemplate(html`
-<gr-endpoint-decorator name="repo-command">
-    </gr-endpoint-decorator>
-`);
-
-const pluginApi = _testOnly_initGerritPluginApi();
-
-suite('gr-repo-api tests', () => {
-  let repoApi;
-
-  setup(() => {
-    let plugin;
-    pluginApi.install(p => { plugin = p; }, '0.1',
-        'http://test.com/plugins/testplugin/static/test.js');
-    getPluginLoader().loadPlugins([]);
-    repoApi = plugin.project();
-  });
-
-  teardown(() => {
-    repoApi = null;
-  });
-
-  test('exists', () => {
-    assert.isOk(repoApi);
-  });
-
-  test('works', done => {
-    const attachedStub = sinon.stub();
-    const tapStub = sinon.stub();
-    repoApi
-        .createCommand('foo', attachedStub)
-        .onTap(tapStub);
-    const element = basicFixture.instantiate();
-    flush(() => {
-      assert.isTrue(attachedStub.called);
-      const pluginCommand = element.shadowRoot
-          .querySelector('gr-plugin-repo-command');
-      assert.isOk(pluginCommand);
-      const btn = pluginCommand.shadowRoot
-          .querySelector('gr-button');
-      assert.isOk(btn);
-      assert.equal(btn.textContent, 'foo');
-      assert.isFalse(tapStub.called);
-      MockInteractions.tap(btn);
-      assert.isTrue(tapStub.called);
-      done();
-    });
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.ts b/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.ts
deleted file mode 100644
index 3f75c0a..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Settings
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import '../../settings/gr-settings-view/gr-settings-item';
-import '../../settings/gr-settings-view/gr-settings-menu-item';
-import {PluginApi} from '../../../api/plugin';
-import {SettingsPluginApi} from '../../../api/settings';
-import {appContext} from '../../../services/app-context';
-
-export class GrSettingsApi implements SettingsPluginApi {
-  private _token: string;
-
-  private _title = '(no title)';
-
-  private _moduleName?: string;
-
-  private readonly reporting = appContext.reportingService;
-
-  constructor(readonly plugin: PluginApi) {
-    this.reporting.trackApi(this.plugin, 'settings', 'constructor');
-    // Generate default screen URL token, specific to plugin, and unique(ish).
-    this._token = plugin.getPluginName() + Math.random().toString(36).substr(5);
-  }
-
-  title(newTitle: string) {
-    this.reporting.trackApi(this.plugin, 'settings', 'title');
-    this._title = newTitle;
-    return this;
-  }
-
-  token(newToken: string) {
-    this.reporting.trackApi(this.plugin, 'settings', 'token');
-    this._token = newToken;
-    return this;
-  }
-
-  module(newModuleName: string) {
-    this.reporting.trackApi(this.plugin, 'settings', 'module');
-    this._moduleName = newModuleName;
-    return this;
-  }
-
-  build() {
-    this.reporting.trackApi(this.plugin, 'settings', 'build');
-    if (!this._moduleName) {
-      throw new Error('Settings screen custom element not defined!');
-    }
-    const token = `x/${this.plugin.getPluginName()}/${this._token}`;
-    this.plugin.hook('settings-menu-item').onAttached(el => {
-      const menuItem = document.createElement('gr-settings-menu-item');
-      menuItem.title = this._title;
-      menuItem.setAttribute('href', `#${token}`);
-      el.appendChild(menuItem);
-    });
-    const moduleName = this._moduleName;
-    return this.plugin.hook('settings-screen').onAttached(el => {
-      const item = document.createElement('gr-settings-item');
-      item.title = this._title;
-      item.anchor = token;
-      item.appendChild(document.createElement(moduleName));
-      el.appendChild(item);
-    });
-  }
-}
diff --git a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api_test.js b/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api_test.js
deleted file mode 100644
index 893f3e4..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api_test.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
-import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-
-const basicFixture = fixtureFromTemplate(html`
-<gr-endpoint-decorator name="settings-menu-item">
-    </gr-endpoint-decorator>
-    <gr-endpoint-decorator name="settings-screen">
-    </gr-endpoint-decorator>
-`);
-
-const pluginApi = _testOnly_initGerritPluginApi();
-
-suite('gr-settings-api tests', () => {
-  let settingsApi;
-
-  setup(() => {
-    let plugin;
-    pluginApi.install(p => { plugin = p; }, '0.1',
-        'http://test.com/plugins/testplugin/static/test.js');
-    getPluginLoader().loadPlugins([]);
-    settingsApi = plugin.settings();
-  });
-
-  teardown(() => {
-    settingsApi = null;
-  });
-
-  test('exists', () => {
-    assert.isOk(settingsApi);
-  });
-
-  test('works', done => {
-    settingsApi
-        .title('foo')
-        .token('bar')
-        .module('some-settings-screen')
-        .build();
-    const element = basicFixture.instantiate();
-    flush(() => {
-      const [menuItemEl, itemEl] = element;
-      const menuItem = menuItemEl.shadowRoot
-          .querySelector('gr-settings-menu-item');
-      assert.isOk(menuItem);
-      assert.equal(menuItem.title, 'foo');
-      assert.equal(menuItem.href, '#x/testplugin/bar');
-      const item = itemEl.shadowRoot
-          .querySelector('gr-settings-item');
-      assert.isOk(item);
-      assert.equal(item.title, 'foo');
-      assert.equal(item.anchor, 'x/testplugin/bar');
-      done();
-    });
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api.ts b/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api.ts
deleted file mode 100644
index 9a15bf5..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * @license
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {StyleObject, StylesPluginApi} from '../../../api/styles';
-import {appContext} from '../../../services/app-context';
-import {PluginApi} from '../../../api/plugin';
-
-/**
- * @fileoverview We should consider dropping support for this API:
- *
- * 1. we need to try avoid using `innerHTML` for xss concerns
- * 2. we have css variables which are more recommended way to custom styling
- */
-
-let styleObjectCount = 0;
-
-interface PgElement extends Element {
-  __pg_js_api_style_tags: {
-    [className: string]: boolean;
-  };
-}
-
-export class GrStyleObject implements StyleObject {
-  private className = '';
-
-  constructor(private readonly rulesStr: string) {
-    this.className = `__pg_js_api_class_${styleObjectCount}`;
-    styleObjectCount++;
-  }
-
-  /**
-   * Creates a new unique CSS class and injects it in a root node of the element
-   * if it hasn't been added yet. A root node is an document or is the
-   * associated shadowRoot. This class can be added to any element with the same
-   * root node.
-   */
-  getClassName(element: Element) {
-    let rootNodeEl = element.getRootNode();
-    if (rootNodeEl === document) {
-      rootNodeEl = document.head;
-    }
-    // TODO(TS): type casting to have correct interface
-    // maybe move this __pg_xxx to attribute
-    const rootNode: PgElement = rootNodeEl as PgElement;
-    if (!rootNode.__pg_js_api_style_tags) {
-      rootNode.__pg_js_api_style_tags = {};
-    }
-    if (!rootNode.__pg_js_api_style_tags[this.className]) {
-      const styleTag = document.createElement('style');
-      styleTag.innerHTML = `.${this.className} { ${this.rulesStr} }`;
-      rootNode.appendChild(styleTag);
-      rootNode.__pg_js_api_style_tags[this.className] = true;
-    }
-    return this.className;
-  }
-
-  /**
-   * Apply shared style to the element.
-   */
-  apply(element: Element) {
-    element.classList.add(this.getClassName(element));
-  }
-}
-
-/**
- * TODO(TS): move to util
- */
-export class GrStylesApi implements StylesPluginApi {
-  private readonly reporting = appContext.reportingService;
-
-  constructor(readonly plugin: PluginApi) {
-    this.reporting.trackApi(this.plugin, 'styles', 'constructor');
-  }
-
-  /**
-   * Creates a new GrStyleObject with specified style properties.
-   */
-  css(ruleStr: string) {
-    this.reporting.trackApi(this.plugin, 'styles', 'css');
-    return new GrStyleObject(ruleStr);
-  }
-}
diff --git a/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api_test.js b/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api_test.js
deleted file mode 100644
index 1c606cd..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api_test.js
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * @license
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
-import {PolymerElement} from '@polymer/polymer/polymer-element.js';
-import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-
-class GrStyleTestElement extends PolymerElement {
-  static get is() { return 'gr-style-test-element'; }
-
-  static get template() {
-    return html`<div id="wrapper"></div>`;
-  }
-}
-
-customElements.define(GrStyleTestElement.is, GrStyleTestElement);
-
-const pluginApi = _testOnly_initGerritPluginApi();
-
-suite('gr-styles-api tests', () => {
-  let stylesApi;
-
-  setup(() => {
-    let plugin;
-    pluginApi.install(p => { plugin = p; }, '0.1',
-        'http://test.com/plugins/testplugin/static/test.js');
-    getPluginLoader().loadPlugins([]);
-    stylesApi = plugin.styles();
-  });
-
-  teardown(() => {
-    stylesApi = null;
-  });
-
-  test('exists', () => {
-    assert.isOk(stylesApi);
-  });
-
-  test('css', () => {
-    const styleObject = stylesApi.css('background: red');
-    assert.isDefined(styleObject);
-  });
-
-  suite('GrStyleObject tests', () => {
-    let stylesApi;
-    let displayInlineStyle;
-    let displayNoneStyle;
-    let elementsToRemove;
-
-    setup(() => {
-      let plugin;
-      pluginApi.install(p => { plugin = p; }, '0.1',
-          'http://test.com/plugins/testplugin/static/test.js');
-      getPluginLoader().loadPlugins([]);
-      stylesApi = plugin.styles();
-      displayInlineStyle = stylesApi.css('display: inline');
-      displayNoneStyle = stylesApi.css('display: none');
-      elementsToRemove = [];
-    });
-
-    teardown(() => {
-      displayInlineStyle = null;
-      displayNoneStyle = null;
-      stylesApi = null;
-      elementsToRemove.forEach(element => {
-        element.remove();
-      });
-      elementsToRemove = null;
-      sinon.restore();
-    });
-
-    function createNestedElements(parentElement) {
-      /* parentElement
-      *  |--- element1
-      *  |--- element2
-      *       |--- element3
-      **/
-      const element1 = document.createElement('div');
-      const element2 = document.createElement('div');
-      const element3 = document.createElement('div');
-      parentElement.appendChild(element1);
-      parentElement.appendChild(element2);
-      element2.appendChild(element3);
-
-      if (parentElement === document.body) {
-        elementsToRemove.push(element1);
-        elementsToRemove.push(element2);
-      }
-
-      return [element1, element2, element3];
-    }
-
-    test('getClassName  - body level elements', () => {
-      const bodyLevelElements = createNestedElements(document.body);
-
-      testGetClassName(bodyLevelElements);
-    });
-
-    test('getClassName  - elements inside polymer element', () => {
-      const polymerElement = document.createElement('gr-style-test-element');
-      document.body.appendChild(polymerElement);
-      elementsToRemove.push(polymerElement);
-      const contentElements = createNestedElements(polymerElement.$.wrapper);
-
-      testGetClassName(contentElements);
-    });
-
-    function testGetClassName(elements) {
-      assertAllElementsHaveDefaultStyle(elements);
-
-      const className1 = displayInlineStyle.getClassName(elements[0]);
-      const className2 = displayNoneStyle.getClassName(elements[1]);
-      const className3 = displayInlineStyle.getClassName(elements[2]);
-
-      assert.notEqual(className2, className1);
-      assert.equal(className3, className1);
-
-      assertAllElementsHaveDefaultStyle(elements);
-
-      elements[0].classList.add(className1);
-      elements[1].classList.add(className2);
-      elements[2].classList.add(className1);
-
-      assertDisplayPropertyValues(elements, ['inline', 'none', 'inline']);
-    }
-
-    test('apply - body level elements', () => {
-      const bodyLevelElements = createNestedElements(document.body);
-
-      testApply(bodyLevelElements);
-    });
-
-    test('apply - elements inside polymer element', () => {
-      const polymerElement = document.createElement('gr-style-test-element');
-      document.body.appendChild(polymerElement);
-      elementsToRemove.push(polymerElement);
-      const contentElements = createNestedElements(polymerElement.$.wrapper);
-
-      testApply(contentElements);
-    });
-
-    function testApply(elements) {
-      assertAllElementsHaveDefaultStyle(elements);
-      displayInlineStyle.apply(elements[0]);
-      displayNoneStyle.apply(elements[1]);
-      displayInlineStyle.apply(elements[2]);
-      assertDisplayPropertyValues(elements, ['inline', 'none', 'inline']);
-    }
-
-    function assertAllElementsHaveDefaultStyle(elements) {
-      for (const element of elements) {
-        assert.equal(getComputedStyle(element).getPropertyValue('display'),
-            'block');
-      }
-    }
-
-    function assertDisplayPropertyValues(elements, expectedDisplayValues) {
-      for (let i = 0; i < elements.length; i++) {
-        assert.equal(
-            getComputedStyle(elements[i]).getPropertyValue('display'),
-            expectedDisplayValues[i]);
-      }
-    }
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api.ts b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api.ts
deleted file mode 100644
index c7be7f6..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import './gr-custom-plugin-header';
-import {GrCustomPluginHeader} from './gr-custom-plugin-header';
-import {PluginApi} from '../../../api/plugin';
-import {ThemePluginApi} from '../../../api/theme';
-import {appContext} from '../../../services/app-context';
-
-/**
- * Defines api for theme, can be used to set header logo and title.
- */
-export class GrThemeApi implements ThemePluginApi {
-  private readonly reporting = appContext.reportingService;
-
-  constructor(private readonly plugin: PluginApi) {
-    this.reporting.trackApi(this.plugin, 'theme', 'constructor');
-  }
-
-  setHeaderLogoAndTitle(logoUrl: string, title: string) {
-    this.reporting.trackApi(this.plugin, 'theme', 'setHeaderLogoAndTitle');
-    this.plugin.hook('header-title', {replace: true}).onAttached(element => {
-      const customHeader: GrCustomPluginHeader = document.createElement(
-        'gr-custom-plugin-header'
-      );
-      customHeader.logoUrl = logoUrl;
-      customHeader.title = title;
-      element.appendChild(customHeader);
-    });
-  }
-}
diff --git a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api_test.js b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api_test.js
deleted file mode 100644
index 787ab0b..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api_test.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
-import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
-import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-
-const headerTitleFixture = fixtureFromTemplate(html`
-<gr-endpoint-decorator name="header-title">
-      <span class="titleText"></span>
-    </gr-endpoint-decorator>
-`);
-
-const pluginApi = _testOnly_initGerritPluginApi();
-
-suite('gr-theme-api tests', () => {
-  let theme;
-
-  setup(() => {
-    let plugin;
-    pluginApi.install(p => { plugin = p; }, '0.1',
-        'http://test.com/plugins/testplugin/static/test.js');
-    theme = plugin.theme();
-  });
-
-  teardown(() => {
-    theme = null;
-  });
-
-  test('exists', () => {
-    assert.isOk(theme);
-  });
-
-  suite('header-title', () => {
-    let customHeader;
-
-    setup(() => {
-      headerTitleFixture.instantiate();
-      stub('gr-custom-plugin-header', {
-        /** @override */
-        ready() { customHeader = this; },
-      });
-      getPluginLoader().loadPlugins([]);
-    });
-
-    test('sets logo and title', done => {
-      theme.setHeaderLogoAndTitle('foo.jpg', 'bar');
-      flush(() => {
-        assert.isNotNull(customHeader);
-        assert.equal(customHeader.logoUrl, 'foo.jpg');
-        assert.equal(customHeader.title, 'bar');
-        done();
-      });
-    });
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts
index 1bb32a1..7ef5a73 100644
--- a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts
+++ b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts
@@ -19,7 +19,6 @@
 import '../../shared/gr-date-formatter/gr-date-formatter';
 import '../../../styles/gr-form-styles';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-account-info_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -29,7 +28,7 @@
 import {fireEvent} from '../../../utils/event-util';
 
 @customElement('gr-account-info')
-export class GrAccountInfo extends LegacyElementMixin(PolymerElement) {
+export class GrAccountInfo extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts b/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts
index 8fa2c94..c1cff72 100644
--- a/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts
+++ b/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts
@@ -17,7 +17,6 @@
 
 import '../../../styles/gr-form-styles';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-agreements-list_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -26,7 +25,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-agreements-list')
-export class GrAgreementsList extends LegacyElementMixin(PolymerElement) {
+export class GrAgreementsList extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -37,8 +36,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.loadData();
   }
 
diff --git a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
index 970fb5f..d13b2a9 100644
--- a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
@@ -19,7 +19,6 @@
 import '../../../styles/shared-styles';
 import '../../../styles/gr-form-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-table-editor_html';
 import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-table-mixin';
@@ -28,9 +27,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-change-table-editor')
-export class GrChangeTableEditor extends ChangeTableMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrChangeTableEditor extends ChangeTableMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.ts b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.ts
index bbfcd7c..b0b7ab8 100644
--- a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.ts
+++ b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.ts
@@ -19,7 +19,6 @@
 import '../../../styles/gr-form-styles';
 import '../../../styles/shared-styles';
 import '../../shared/gr-button/gr-button';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-cla-view_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -39,7 +38,7 @@
 }
 
 @customElement('gr-cla-view')
-export class GrClaView extends LegacyElementMixin(PolymerElement) {
+export class GrClaView extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -68,8 +67,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.loadData();
 
     fireTitleChange(this, 'New Contributor Agreement');
diff --git a/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.ts b/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.ts
index 5d8cc51..5e2c5cb 100644
--- a/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.ts
+++ b/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.ts
@@ -18,7 +18,6 @@
 import '../../../styles/gr-form-styles';
 import '../../../styles/shared-styles';
 import '../../shared/gr-select/gr-select';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-edit-preferences_html';
 import {customElement, property} from '@polymer/decorators';
@@ -36,7 +35,7 @@
   };
 }
 @customElement('gr-edit-preferences')
-export class GrEditPreferences extends LegacyElementMixin(PolymerElement) {
+export class GrEditPreferences extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.ts b/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.ts
index 925d9fb..74c6ac0 100644
--- a/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.ts
@@ -18,7 +18,6 @@
 import '../../shared/gr-button/gr-button';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-email-editor_html';
 import {customElement, property} from '@polymer/decorators';
@@ -26,7 +25,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-email-editor')
-export class GrEmailEditor extends LegacyElementMixin(PolymerElement) {
+export class GrEmailEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor_test.ts b/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor_test.ts
index bc4a4d2..e4c1584 100644
--- a/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor_test.ts
+++ b/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor_test.ts
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import './gr-email-editor.js';
+import '../../../test/common-test-setup-karma';
+import './gr-email-editor';
 import {GrEmailEditor} from './gr-email-editor';
 import {spyRestApi, stubRestApi} from '../../../test/test-utils';
 
diff --git a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.ts b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.ts
index 9cce48e..afbd67e 100644
--- a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.ts
@@ -21,7 +21,6 @@
 import '../../shared/gr-overlay/gr-overlay';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-gpg-editor_html';
 import {customElement, property} from '@polymer/decorators';
@@ -45,7 +44,7 @@
   }
 }
 @customElement('gr-gpg-editor')
-export class GrGpgEditor extends LegacyElementMixin(PolymerElement) {
+export class GrGpgEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.ts b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.ts
index c24eaef..a367969 100644
--- a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.ts
+++ b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.ts
@@ -16,7 +16,6 @@
  */
 import '../../../styles/shared-styles';
 import '../../../styles/gr-form-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-group-list_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -30,7 +29,7 @@
   }
 }
 @customElement('gr-group-list')
-export class GrGroupList extends LegacyElementMixin(PolymerElement) {
+export class GrGroupList extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts
index 701c098..610ea30 100644
--- a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts
+++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts
@@ -19,7 +19,6 @@
 import '../../shared/gr-copy-clipboard/gr-copy-clipboard';
 import '../../shared/gr-overlay/gr-overlay';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-http-password_html';
 import {property, customElement} from '@polymer/decorators';
@@ -39,7 +38,7 @@
 }
 
 @customElement('gr-http-password')
-export class GrHttpPassword extends LegacyElementMixin(PolymerElement) {
+export class GrHttpPassword extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -56,8 +55,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.loadData();
   }
 
diff --git a/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.ts b/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.ts
index 221df1f..d65304c 100644
--- a/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.ts
+++ b/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.ts
@@ -19,7 +19,6 @@
 import '../../admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog';
 import '../../shared/gr-button/gr-button';
 import '../../shared/gr-overlay/gr-overlay';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-identities_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -38,7 +37,7 @@
 }
 
 @customElement('gr-identities')
-export class GrIdentities extends LegacyElementMixin(PolymerElement) {
+export class GrIdentities extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts
index 34acaf9..0ff5e98 100644
--- a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts
@@ -20,14 +20,13 @@
 import '../../../styles/shared-styles';
 import '../../../styles/gr-form-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-menu-editor_html';
 import {customElement, property} from '@polymer/decorators';
 import {TopMenuItemInfo} from '../../../types/common';
 
 @customElement('gr-menu-editor')
-export class GrMenuEditor extends LegacyElementMixin(PolymerElement) {
+export class GrMenuEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.ts b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.ts
index 02ba85d..39a5d54 100644
--- a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.ts
+++ b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.ts
@@ -18,7 +18,6 @@
 import '../../../styles/gr-form-styles';
 import '../../shared/gr-button/gr-button';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-registration-dialog_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -42,7 +41,7 @@
 }
 
 @customElement('gr-registration-dialog')
-export class GrRegistrationDialog extends LegacyElementMixin(PolymerElement) {
+export class GrRegistrationDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.ts
index 887c441..7540960 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-settings-item_html';
 import {property, customElement} from '@polymer/decorators';
@@ -26,7 +25,7 @@
 }
 
 @customElement('gr-settings-item')
-class GrSettingsItem extends LegacyElementMixin(PolymerElement) {
+class GrSettingsItem extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.ts
index 2f89b52..8a6c084 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/gr-page-nav-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-settings-menu-item_html';
 import {property, customElement} from '@polymer/decorators';
@@ -27,7 +26,7 @@
 }
 
 @customElement('gr-settings-menu-item')
-class GrSettingsMenuItem extends LegacyElementMixin(PolymerElement) {
+class GrSettingsMenuItem extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
index e6858b4..492561f 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
@@ -42,7 +42,6 @@
 import '../gr-menu-editor/gr-menu-editor';
 import '../gr-ssh-editor/gr-ssh-editor';
 import '../gr-watched-projects-editor/gr-watched-projects-editor';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-settings-view_html';
 import {getDocsBaseUrl} from '../../../utils/url-util';
@@ -118,9 +117,7 @@
 }
 
 @customElement('gr-settings-view')
-export class GrSettingsView extends ChangeTableMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrSettingsView extends ChangeTableMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -211,11 +208,11 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     // Polymer 2: anchor tag won't work on shadow DOM
     // we need to manually calling scrollIntoView when hash changed
-    this.listen(window, 'location-change', '_handleLocationChange');
+    window.addEventListener('location-change', this.handleLocationChange);
     fireTitleChange(this, 'Settings');
 
     this._isDark = !!window.localStorage.getItem('dark-theme');
@@ -295,16 +292,16 @@
       this._loading = false;
 
       // Handle anchor tag for initial load
-      this._handleLocationChange();
+      this.handleLocationChange();
     });
   }
 
-  detached() {
-    super.detached();
-    this.unlisten(window, 'location-change', '_handleLocationChange');
+  disconnectedCallback() {
+    window.removeEventListener('location-change', this.handleLocationChange);
+    super.disconnectedCallback();
   }
 
-  _handleLocationChange() {
+  private readonly handleLocationChange = () => {
     // Handle anchor tag after dom attached
     const urlHash = window.location.hash;
     if (urlHash) {
@@ -314,7 +311,7 @@
         elem.scrollIntoView();
       }
     }
-  }
+  };
 
   reloadAccountDetail() {
     Promise.all([this.$.accountInfo.loadData(), this.$.emailEditor.loadData()]);
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
index 11372a1..0bb6f09 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
@@ -107,7 +107,7 @@
             aria-labelledby="darkThemeToggleLabel"
             checked="[[_isDark]]"
             on-change="_handleToggleDark"
-            on-tap="_onTapDarkToggle"
+            on-click="_onTapDarkToggle"
           ></paper-toggle-button>
           <div id="darkThemeToggleLabel">Dark theme (alpha)</div>
         </div>
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.js b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.js
index 98abb3fb..79789bb 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.js
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.js
@@ -329,7 +329,7 @@
   test('emails are loaded without emailToken', () => {
     sinon.stub(element.$.emailEditor, 'loadData');
     element.params = {};
-    element.attached();
+    element.connectedCallback();
     assert.isTrue(element.$.emailEditor.loadData.calledOnce);
   });
 
@@ -465,7 +465,7 @@
       confirmEmailStub = stubRestApi('confirmEmail').returns(
           new Promise(resolve => { resolveConfirm = resolve; }));
       element.params = {view: GerritView.SETTINGS, emailToken: 'foo'};
-      element.attached();
+      element.connectedCallback();
     });
 
     test('it is used to confirm email via rest API', () => {
diff --git a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.ts b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.ts
index b2373ec..c1f347f 100644
--- a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.ts
@@ -21,7 +21,6 @@
 import '../../shared/gr-overlay/gr-overlay';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-ssh-editor_html';
 import {property, customElement} from '@polymer/decorators';
@@ -45,7 +44,7 @@
   }
 }
 @customElement('gr-ssh-editor')
-export class GrSshEditor extends LegacyElementMixin(PolymerElement) {
+export class GrSshEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.ts b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.ts
index fe37795..6178e7a 100644
--- a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.ts
@@ -20,7 +20,6 @@
 import '../../../styles/gr-form-styles';
 import '../../../styles/shared-styles';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-watched-projects-editor_html';
 import {customElement, property} from '@polymer/decorators';
@@ -48,9 +47,7 @@
   };
 }
 @customElement('gr-watched-projects-editor')
-export class GrWatchedProjectsEditor extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrWatchedProjectsEditor extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts
index e344a1b..dab778b 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts
@@ -18,7 +18,6 @@
 import '../gr-button/gr-button';
 import '../gr-icons/gr-icons';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-account-chip_html';
 import {customElement, property} from '@polymer/decorators';
@@ -26,7 +25,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-account-chip')
-export class GrAccountChip extends LegacyElementMixin(PolymerElement) {
+export class GrAccountChip extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.ts b/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.ts
index 7c8c479..d793a8d 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.ts
@@ -16,7 +16,6 @@
  */
 import '../../../styles/shared-styles';
 import '../gr-autocomplete/gr-autocomplete';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-account-entry_html';
 import {customElement, property} from '@polymer/decorators';
@@ -32,7 +31,7 @@
  * and/or group with autocomplete support.
  */
 @customElement('gr-account-entry')
-export class GrAccountEntry extends LegacyElementMixin(PolymerElement) {
+export class GrAccountEntry extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
index 4702958..64bae58 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
@@ -18,7 +18,6 @@
 import '../../../styles/shared-styles';
 import '../gr-avatar/gr-avatar';
 import '../gr-hovercard-account/gr-hovercard-account';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-account-label_html';
 import {appContext} from '../../../services/app-context';
@@ -33,7 +32,7 @@
 import {ShowAlertEventDetail} from '../../../types/events';
 
 @customElement('gr-account-label')
-export class GrAccountLabel extends LegacyElementMixin(PolymerElement) {
+export class GrAccountLabel extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts
index 5d72ca5..5c4b76a 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts
@@ -17,7 +17,6 @@
 
 import '../gr-account-label/gr-account-label';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-account-link_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -25,7 +24,7 @@
 import {AccountInfo, ChangeInfo} from '../../../types/common';
 
 @customElement('gr-account-link')
-class GrAccountLink extends LegacyElementMixin(PolymerElement) {
+class GrAccountLink extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts
index 3b15233..1e54f69 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts
@@ -17,7 +17,6 @@
 import '../gr-account-chip/gr-account-chip';
 import '../gr-account-entry/gr-account-entry';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-account-list_html';
 import {appContext} from '../../../services/app-context';
@@ -114,7 +113,7 @@
 }
 
 @customElement('gr-account-list')
-export class GrAccountList extends LegacyElementMixin(PolymerElement) {
+export class GrAccountList extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -189,11 +188,6 @@
     super();
     this.reporting = appContext.reportingService;
     this._querySuggestions = input => this._getSuggestions(input);
-  }
-
-  /** @override */
-  created() {
-    super.created();
     this.addEventListener('remove', e =>
       this._handleRemove(e as CustomEvent<{account: AccountInput}>)
     );
diff --git a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts
index 3b584c7..4d2576a 100644
--- a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts
+++ b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-button/gr-button';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-alert_html';
 import {getRootElement} from '../../../scripts/rootElement';
@@ -30,7 +29,7 @@
 }
 
 @customElement('gr-alert')
-export class GrAlert extends LegacyElementMixin(PolymerElement) {
+export class GrAlert extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -72,21 +71,21 @@
   _actionCallback?: () => void;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._boundTransitionEndHandler = () => this._handleTransitionEnd();
     this.addEventListener('transitionend', this._boundTransitionEndHandler);
   }
 
   /** @override */
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     if (this._boundTransitionEndHandler) {
       this.removeEventListener(
         'transitionend',
         this._boundTransitionEndHandler
       );
     }
+    super.disconnectedCallback();
   }
 
   show(text: string, actionText?: string, actionCallback?: () => void) {
diff --git a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert_html.ts b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert_html.ts
index b66a1dd..bc517a8 100644
--- a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert_html.ts
@@ -27,7 +27,7 @@
       bottom: 1.25rem;
       border-radius: var(--border-radius);
       box-shadow: var(--elevation-level-2);
-      color: var(--view-background-color);
+      color: var(--tooltip-text-color);
       left: 1.25rem;
       position: fixed;
       transform: translateY(5rem);
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts
index 3550b02..cef3b28 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts
@@ -18,7 +18,6 @@
 import '../gr-cursor-manager/gr-cursor-manager';
 import '../../../styles/shared-styles';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-autocomplete-dropdown_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -30,7 +29,6 @@
 
 export interface GrAutocompleteDropdown {
   $: {
-    cursor: GrCursorManager;
     suggestions: Element;
   };
 }
@@ -49,12 +47,9 @@
   value?: string;
 }
 
-/**
- * @extends PolymerElement
- */
 @customElement('gr-autocomplete-dropdown')
 export class GrAutocompleteDropdown extends IronFitMixin(
-  KeyboardShortcutMixin(LegacyElementMixin(PolymerElement)),
+  KeyboardShortcutMixin(PolymerElement),
   IronFitBehavior as IronFitBehavior
 ) {
   static get template() {
@@ -88,9 +83,6 @@
   @property({type: Array})
   suggestions: Item[] = [];
 
-  @property({type: Array})
-  _suggestionEls: Element[] = [];
-
   get keyBindings() {
     return {
       up: '_handleUp',
@@ -101,6 +93,19 @@
     };
   }
 
+  private cursor = new GrCursorManager();
+
+  constructor() {
+    super();
+    this.cursor.cursorTargetClass = 'selected';
+  }
+
+  /** @override */
+  disconnectedCallback() {
+    this.cursor.unsetCursor();
+    super.disconnectedCallback();
+  }
+
   close() {
     this.isHidden = true;
   }
@@ -134,13 +139,13 @@
 
   cursorDown() {
     if (!this.isHidden) {
-      this.$.cursor.next();
+      this.cursor.next();
     }
   }
 
   cursorUp() {
     if (!this.isHidden) {
-      this.$.cursor.previous();
+      this.cursor.previous();
     }
   }
 
@@ -151,7 +156,7 @@
       new CustomEvent('item-selected', {
         detail: {
           trigger: 'tab',
-          selected: this.$.cursor.target,
+          selected: this.cursor.target,
         },
         composed: true,
         bubbles: true,
@@ -166,7 +171,7 @@
       new CustomEvent('item-selected', {
         detail: {
           trigger: 'enter',
-          selected: this.$.cursor.target,
+          selected: this.cursor.target,
         },
         composed: true,
         bubbles: true,
@@ -206,7 +211,7 @@
   }
 
   getCursorTarget() {
-    return this.$.cursor.target;
+    return this.cursor.target;
   }
 
   @observe('suggestions')
@@ -214,18 +219,23 @@
     if (this.suggestions.length > 0) {
       if (!this.isHidden) {
         flush();
-        this._suggestionEls = Array.from(
+        this.cursor.stops = Array.from(
           this.$.suggestions.querySelectorAll('li')
         );
         this._resetCursorIndex();
       }
     } else {
-      this._suggestionEls = [];
+      this.cursor.stops = [];
     }
   }
 
+  @observe('index')
+  _setIndex() {
+    this.cursor.index = this.index || -1;
+  }
+
   _resetCursorIndex() {
-    this.$.cursor.setCursorAtIndex(0);
+    this.cursor.setCursorAtIndex(0);
   }
 
   _computeLabelClass(item: Item) {
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_html.ts b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_html.ts
index d3d2481..b86e8ec 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_html.ts
@@ -91,12 +91,4 @@
       </template>
     </ul>
   </div>
-  <gr-cursor-manager
-    id="cursor"
-    index="{{index}}"
-    cursor-target-class="selected"
-    scroll-mode="never"
-    focus-on-move=""
-    stops="[[_suggestionEls]]"
-  ></gr-cursor-manager>
 `;
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.js b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.js
index ad06649..200fddc 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown_test.js
@@ -55,7 +55,7 @@
     element.addEventListener('item-selected', itemSelectedStub);
     MockInteractions.pressAndReleaseKeyOn(element, 9);
     assert.isTrue(handleTabSpy.called);
-    assert.equal(element.$.cursor.index, 0);
+    assert.equal(element.cursor.index, 0);
     assert.isTrue(itemSelectedStub.called);
     assert.deepEqual(itemSelectedStub.lastCall.args[0].detail, {
       trigger: 'tab',
@@ -69,7 +69,7 @@
     element.addEventListener('item-selected', itemSelectedStub);
     MockInteractions.pressAndReleaseKeyOn(element, 13);
     assert.isTrue(handleEnterSpy.called);
-    assert.equal(element.$.cursor.index, 0);
+    assert.equal(element.cursor.index, 0);
     assert.deepEqual(itemSelectedStub.lastCall.args[0].detail, {
       trigger: 'enter',
       selected: element.getCursorTarget(),
@@ -78,28 +78,28 @@
 
   test('down key', () => {
     element.isHidden = true;
-    const nextSpy = sinon.spy(element.$.cursor, 'next');
+    const nextSpy = sinon.spy(element.cursor, 'next');
     MockInteractions.pressAndReleaseKeyOn(element, 40);
     assert.isFalse(nextSpy.called);
-    assert.equal(element.$.cursor.index, 0);
+    assert.equal(element.cursor.index, 0);
     element.isHidden = false;
     MockInteractions.pressAndReleaseKeyOn(element, 40);
     assert.isTrue(nextSpy.called);
-    assert.equal(element.$.cursor.index, 1);
+    assert.equal(element.cursor.index, 1);
   });
 
   test('up key', () => {
     element.isHidden = true;
-    const prevSpy = sinon.spy(element.$.cursor, 'previous');
+    const prevSpy = sinon.spy(element.cursor, 'previous');
     MockInteractions.pressAndReleaseKeyOn(element, 38);
     assert.isFalse(prevSpy.called);
-    assert.equal(element.$.cursor.index, 0);
+    assert.equal(element.cursor.index, 0);
     element.isHidden = false;
-    element.$.cursor.setCursorAtIndex(1);
-    assert.equal(element.$.cursor.index, 1);
+    element.cursor.setCursorAtIndex(1);
+    assert.equal(element.cursor.index, 1);
     MockInteractions.pressAndReleaseKeyOn(element, 38);
     assert.isTrue(prevSpy.called);
-    assert.equal(element.$.cursor.index, 0);
+    assert.equal(element.cursor.index, 0);
   });
 
   test('tapping selects item', () => {
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts
index 6390237..b8c2c21 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts
@@ -20,16 +20,15 @@
 import '../gr-icons/gr-icons';
 import '../../../styles/shared-styles';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-autocomplete_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
 import {property, customElement, observe} from '@polymer/decorators';
 import {GrAutocompleteDropdown} from '../gr-autocomplete-dropdown/gr-autocomplete-dropdown';
-import {GrCursorManager} from '../gr-cursor-manager/gr-cursor-manager';
 import {PaperInputElementExt} from '../../../types/types';
 import {CustomKeyboardEvent} from '../../../types/events';
 import {fireEvent} from '../../../utils/event-util';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 
 const TOKENIZE_REGEX = /(?:[^\s"]+|"[^"]*")+/g;
 const DEBOUNCE_WAIT_MS = 200;
@@ -38,7 +37,6 @@
   $: {
     input: PaperInputElementExt;
     suggestions: GrAutocompleteDropdown;
-    cursor: GrCursorManager;
   };
 }
 
@@ -67,12 +65,8 @@
   AutocompleteCommitEventDetail
 >;
 
-const DEBOUNCER_UPDATE_SUGGESTIONS = 'update-suggestions';
-
 @customElement('gr-autocomplete')
-export class GrAutocomplete extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrAutocomplete extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -202,6 +196,8 @@
   @property({type: Object})
   _selected: HTMLElement | null = null;
 
+  private updateSuggestionsTask?: DelayedTask;
+
   get _nativeInput() {
     // In Polymer 2 inputElement isn't nativeInput anymore
     return (this.$.input.$.nativeInput ||
@@ -209,16 +205,16 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
-    this.listen(document.body, 'click', '_handleBodyClick');
+  connectedCallback() {
+    super.connectedCallback();
+    document.addEventListener('click', this.handleBodyClick);
   }
 
   /** @override */
-  detached() {
-    super.detached();
-    this.unlisten(document.body, 'click', '_handleBodyClick');
-    this.cancelDebouncer(DEBOUNCER_UPDATE_SUGGESTIONS);
+  disconnectedCallback() {
+    document.removeEventListener('click', this.handleBodyClick);
+    this.updateSuggestionsTask?.cancel();
+    super.disconnectedCallback();
   }
 
   get focusStart() {
@@ -331,7 +327,11 @@
     if (noDebounce) {
       update();
     } else {
-      this.debounce(DEBOUNCER_UPDATE_SUGGESTIONS, update, DEBOUNCE_WAIT_MS);
+      this.updateSuggestionsTask = debounce(
+        this.updateSuggestionsTask,
+        update,
+        DEBOUNCE_WAIT_MS
+      );
     }
   }
 
@@ -444,7 +444,7 @@
     }
   }
 
-  _handleBodyClick(e: Event) {
+  private readonly handleBodyClick = (e: Event) => {
     const eventPath = e.composedPath();
     if (!eventPath) return;
     for (let i = 0; i < eventPath.length; i++) {
@@ -453,7 +453,7 @@
       }
     }
     this._focused = false;
-  }
+  };
 
   /**
    * Commits the suggestion, optionally firing the commit event.
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.js b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.js
index 329265e..d72007e 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.js
@@ -46,7 +46,7 @@
     ]));
     element.query = queryStub;
     assert.isTrue(element.$.suggestions.isHidden);
-    assert.equal(element.$.suggestions.$.cursor.index, -1);
+    assert.equal(element.$.suggestions.cursor.index, -1);
 
     focusOnInput(element);
     element.text = 'blah';
@@ -64,7 +64,7 @@
         assert.equal(suggestions[i].innerText.trim(), 'blah ' + i);
       }
 
-      assert.notEqual(element.$.suggestions.$.cursor.index, -1);
+      assert.notEqual(element.$.suggestions.cursor.index, -1);
     });
   });
 
@@ -121,7 +121,7 @@
     element.query = queryStub;
 
     assert.isTrue(element.$.suggestions.isHidden);
-    assert.equal(element.$.suggestions.$.cursor.index, -1);
+    assert.equal(element.$.suggestions.cursor.index, -1);
     element._focused = true;
     element.text = 'blah';
 
@@ -131,21 +131,21 @@
       const commitHandler = sinon.spy();
       element.addEventListener('commit', commitHandler);
 
-      assert.equal(element.$.suggestions.$.cursor.index, 0);
+      assert.equal(element.$.suggestions.cursor.index, 0);
 
       MockInteractions.pressAndReleaseKeyOn(element.$.input, 40, null,
           'down');
 
-      assert.equal(element.$.suggestions.$.cursor.index, 1);
+      assert.equal(element.$.suggestions.cursor.index, 1);
 
       MockInteractions.pressAndReleaseKeyOn(element.$.input, 40, null,
           'down');
 
-      assert.equal(element.$.suggestions.$.cursor.index, 2);
+      assert.equal(element.$.suggestions.cursor.index, 2);
 
       MockInteractions.pressAndReleaseKeyOn(element.$.input, 38, null, 'up');
 
-      assert.equal(element.$.suggestions.$.cursor.index, 1);
+      assert.equal(element.$.suggestions.cursor.index, 1);
 
       MockInteractions.pressAndReleaseKeyOn(element.$.input, 13, null,
           'enter');
@@ -215,19 +215,18 @@
   });
 
   test('noDebounce=false debounces the query', () => {
+    const clock = sinon.useFakeTimers();
     const queryStub = sinon.spy(() => Promise.resolve([]));
-    let callback;
-    const debounceStub = sinon.stub(element, 'debounce').callsFake(
-        (name, cb) => { callback = cb; });
     element.query = queryStub;
     element.noDebounce = false;
     focusOnInput(element);
     element.text = 'a';
+
+    // not called right away
     assert.isFalse(queryStub.called);
-    assert.isTrue(debounceStub.called);
-    assert.equal(debounceStub.lastCall.args[2], 200);
-    assert.isFunction(callback);
-    callback();
+
+    // but called after a while
+    clock.tick(1000);
     assert.isTrue(queryStub.called);
   });
 
diff --git a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.ts b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.ts
index 72b47e0..e30e995 100644
--- a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.ts
+++ b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-avatar_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -25,7 +24,7 @@
 import {appContext} from '../../../services/app-context';
 
 @customElement('gr-avatar')
-export class GrAvatar extends LegacyElementMixin(PolymerElement) {
+export class GrAvatar extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -42,8 +41,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     Promise.all([
       this._getConfig(),
       getPluginLoader().awaitPluginsLoaded(),
diff --git a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.js b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.js
index 0eef5a7..df8632f 100644
--- a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.js
@@ -103,9 +103,9 @@
 
   suite('config set', () => {
     setup(() => {
-      stub('gr-avatar', {
-        _getConfig: () => Promise.resolve({plugin: {has_avatars: true}}),
-      });
+      stub('gr-avatar', '_getConfig').callsFake(() =>
+        Promise.resolve({plugin: {has_avatars: true}})
+      );
       element = basicFixture.instantiate();
     });
 
@@ -141,9 +141,9 @@
     let element;
 
     setup(() => {
-      stub('gr-avatar', {
-        _getConfig: () => Promise.resolve({plugin: {has_avatars: true}}),
-      });
+      stub('gr-avatar', '_getConfig').callsFake(() =>
+        Promise.resolve({plugin: {has_avatars: true}})
+      );
 
       element = basicFixture.instantiate();
     });
@@ -169,9 +169,7 @@
     let element;
 
     setup(() => {
-      stub('gr-avatar', {
-        _getConfig: () => Promise.resolve({}),
-      });
+      stub('gr-avatar', '_getConfig').callsFake(() => Promise.resolve({}));
 
       element = basicFixture.instantiate();
     });
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts b/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
index 72b2744..6a7c05b 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
@@ -16,7 +16,6 @@
  */
 import '@polymer/paper-button/paper-button';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement, property, computed, observe} from '@polymer/decorators';
 import {htmlTemplate} from './gr-button_html';
@@ -34,8 +33,8 @@
 }
 
 @customElement('gr-button')
-export class GrButton extends LegacyElementMixin(
-  KeyboardShortcutMixin(TooltipMixin(PolymerElement))
+export class GrButton extends KeyboardShortcutMixin(
+  TooltipMixin(PolymerElement)
 ) {
   static get template() {
     return htmlTemplate;
@@ -82,9 +81,8 @@
 
   private readonly reporting: ReportingService = appContext.reportingService;
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this._initialTabindex = this.getAttribute('tabindex') || '0';
     // TODO(TS): try avoid using unknown
     this.addEventListener('click', e =>
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.js b/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.ts
similarity index 69%
rename from polygerrit-ui/app/elements/shared/gr-button/gr-button_test.js
rename to polygerrit-ui/app/elements/shared/gr-button/gr-button_test.ts
index 242cb28..f0f122a 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.ts
@@ -15,18 +15,21 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import './gr-button.js';
-import {addListener} from '@polymer/polymer/lib/utils/gestures.js';
-import {appContext} from '../../../services/app-context.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
+import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
+import '../../../test/common-test-setup-karma';
+import {addListener} from '@polymer/polymer/lib/utils/gestures';
+import {appContext} from '../../../services/app-context';
+import {html} from '@polymer/polymer/lib/utils/html-tag';
+import {GrButton} from './gr-button';
+import {queryAndAssert} from '../../../test/test-utils';
+import {PaperButtonElement} from '@polymer/paper-button';
 
 const basicFixture = fixtureFromElement('gr-button');
 
 const nestedFixture = fixtureFromTemplate(html`
-<div id="test">
-  <gr-button class="testBtn"></gr-button>
-</div>
+  <div id="test">
+    <gr-button class="testBtn"></gr-button>
+  </div>
 `);
 
 const tabindexFixture = fixtureFromTemplate(html`
@@ -34,11 +37,11 @@
 `);
 
 suite('gr-button tests', () => {
-  let element;
+  let element: GrButton;
 
-  const addSpyOn = function(eventName) {
+  const addSpyOn = function (eventName: string) {
     const spy = sinon.spy();
-    if (eventName == 'tap') {
+    if (eventName === 'tap') {
       addListener(element, eventName, spy);
     } else {
       element.addEventListener(eventName, spy);
@@ -51,7 +54,10 @@
   });
 
   test('disabled is set by disabled', () => {
-    const paperBtn = element.shadowRoot.querySelector('paper-button');
+    const paperBtn = queryAndAssert<PaperButtonElement>(
+      element,
+      'paper-button'
+    );
     assert.isFalse(paperBtn.disabled);
     element.disabled = true;
     assert.isTrue(paperBtn.disabled);
@@ -60,17 +66,21 @@
   });
 
   test('loading set from listener', () => {
-    let resolve;
+    let resolve: Function;
     element.addEventListener('click', e => {
-      e.target.loading = true;
-      resolve = () => e.target.loading = false;
+      const target = e.target as HTMLElement;
+      target.setAttribute('loading', 'true');
+      resolve = () => target.removeAttribute('loading');
     });
-    const paperBtn = element.shadowRoot.querySelector('paper-button');
+    const paperBtn = queryAndAssert<PaperButtonElement>(
+      element,
+      'paper-button'
+    );
     assert.isFalse(paperBtn.disabled);
     MockInteractions.tap(element);
     assert.isTrue(paperBtn.disabled);
     assert.isTrue(element.hasAttribute('loading'));
-    resolve();
+    resolve!();
     flush();
     assert.isFalse(paperBtn.disabled);
     assert.isFalse(element.hasAttribute('loading'));
@@ -92,13 +102,13 @@
   });
 
   test('tabindex should be preserved', () => {
-    element = tabindexFixture.instantiate();
-    element.disabled = false;
-    assert.equal(element.getAttribute('tabindex'), '3');
-    element.disabled = true;
-    assert.equal(element.getAttribute('tabindex'), '-1');
-    element.disabled = false;
-    assert.equal(element.getAttribute('tabindex'), '3');
+    const tabIndexElement = tabindexFixture.instantiate() as GrButton;
+    tabIndexElement.disabled = false;
+    assert.equal(tabIndexElement.getAttribute('tabindex'), '3');
+    tabIndexElement.disabled = true;
+    assert.equal(tabIndexElement.getAttribute('tabindex'), '-1');
+    tabIndexElement.disabled = false;
+    assert.equal(tabIndexElement.getAttribute('tabindex'), '3');
   });
 
   // 'tap' event is tested so we don't loose backward compatibility with older
@@ -123,14 +133,14 @@
 
   // Keycodes: 32 for Space, 13 for Enter.
   for (const key of [32, 13]) {
-    test('dispatches click event on keycode ' + key, () => {
+    test(`dispatches click event on keycode ${key}`, () => {
       const tapSpy = sinon.spy();
       element.addEventListener('click', tapSpy);
       MockInteractions.pressAndReleaseKeyOn(element, key);
       assert.isTrue(tapSpy.calledOnce);
     });
 
-    test('dispatches no click event with modifier on keycode ' + key, () => {
+    test(`dispatches no click event with modifier on keycode ${key}`, () => {
       const tapSpy = sinon.spy();
       element.addEventListener('click', tapSpy);
       MockInteractions.pressAndReleaseKeyOn(element, key, 'shift');
@@ -156,7 +166,7 @@
 
     // Keycodes: 32 for Space, 13 for Enter.
     for (const key of [32, 13]) {
-      test('stops click event on keycode ' + key, () => {
+      test(`stops click event on keycode ${key}`, () => {
         const tapSpy = sinon.spy();
         element.addEventListener('click', tapSpy);
         MockInteractions.pressAndReleaseKeyOn(element, key);
@@ -166,10 +176,9 @@
   });
 
   suite('reporting', () => {
-    let reportStub;
+    let reportStub: sinon.SinonStub;
     setup(() => {
-      reportStub = sinon.stub(appContext.reportingService,
-          'reportInteraction');
+      reportStub = sinon.stub(appContext.reportingService, 'reportInteraction');
       reportStub.reset();
     });
 
@@ -178,20 +187,20 @@
       assert.isTrue(reportStub.calledOnce);
       assert.equal(reportStub.lastCall.args[0], 'button-click');
       assert.deepEqual(reportStub.lastCall.args[1], {
-        path: `html>body>test-fixture#${basicFixture.fixtureId}>gr-button`,
+        path: `html>body>test-fixture#${element.parentElement!.id}>gr-button`,
       });
     });
 
     test('report event after click on nested', () => {
-      element = nestedFixture.instantiate();
-      MockInteractions.click(element.querySelector('gr-button'));
+      const nestedElement = nestedFixture.instantiate() as HTMLDivElement;
+      MockInteractions.click(queryAndAssert(nestedElement, 'gr-button'));
       assert.isTrue(reportStub.calledOnce);
       assert.equal(reportStub.lastCall.args[0], 'button-click');
       assert.deepEqual(reportStub.lastCall.args[1], {
-        path: `html>body>test-fixture#${nestedFixture.fixtureId}` +
-            `>div#test>gr-button.testBtn`,
+        path:
+          `html>body>test-fixture#${nestedElement.parentElement!.id}` +
+          '>div#test>gr-button.testBtn',
       });
     });
   });
 });
-
diff --git a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts
index bafc00f..2b66af8 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts
+++ b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-icons/gr-icons';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-star_html';
 import {customElement, property} from '@polymer/decorators';
@@ -36,9 +35,7 @@
 }
 
 @customElement('gr-change-star')
-export class GrChangeStar extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrChangeStar extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star_test.js b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star_test.js
deleted file mode 100644
index f05ed21..0000000
--- a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star_test.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * @license
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import './gr-change-star.js';
-
-const basicFixture = fixtureFromElement('gr-change-star');
-
-suite('gr-change-star tests', () => {
-  let element;
-
-  setup(() => {
-    element = basicFixture.instantiate();
-    element.change = {
-      _number: 2,
-      starred: true,
-    };
-  });
-
-  test('star visibility states', () => {
-    element.set('change.starred', true);
-    let icon = element.shadowRoot
-        .querySelector('iron-icon');
-    assert.isTrue(icon.classList.contains('active'));
-    assert.equal(icon.icon, 'gr-icons:star');
-
-    element.set('change.starred', false);
-    icon = element.shadowRoot
-        .querySelector('iron-icon');
-    assert.isFalse(icon.classList.contains('active'));
-    assert.equal(icon.icon, 'gr-icons:star-border');
-  });
-
-  test('starring', async () => {
-    let resolve;
-    const promise = new Promise(r => resolve = r);
-    element.addEventListener('toggle-star', resolve);
-    element.set('change.starred', false);
-    MockInteractions.tap(element.shadowRoot
-        .querySelector('button'));
-
-    await promise;
-    assert.equal(element.change.starred, true);
-  });
-
-  test('unstarring', async () => {
-    let resolve;
-    const promise = new Promise(r => resolve = r);
-    element.addEventListener('toggle-star', resolve);
-    element.set('change.starred', true);
-    MockInteractions.tap(element.shadowRoot
-        .querySelector('button'));
-
-    await promise;
-    assert.equal(element.change.starred, false);
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star_test.ts b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star_test.ts
new file mode 100644
index 0000000..8f411ae
--- /dev/null
+++ b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star_test.ts
@@ -0,0 +1,71 @@
+/**
+ * @license
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {IronIconElement} from '@polymer/iron-icon';
+import '../../../test/common-test-setup-karma';
+import {queryAndAssert} from '../../../test/test-utils';
+import {GrChangeStar} from './gr-change-star';
+import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
+import {createChange} from '../../../test/test-data-generators';
+
+const basicFixture = fixtureFromElement('gr-change-star');
+
+suite('gr-change-star tests', () => {
+  let element: GrChangeStar;
+
+  setup(() => {
+    element = basicFixture.instantiate();
+    element.change = {
+      ...createChange(),
+      starred: true,
+    };
+  });
+
+  test('star visibility states', async () => {
+    element.set('change.starred', true);
+    await flush();
+    let icon = queryAndAssert<IronIconElement>(element, 'iron-icon');
+    assert.isTrue(icon.classList.contains('active'));
+    assert.equal(icon.icon, 'gr-icons:star');
+
+    element.set('change.starred', false);
+    await flush();
+    icon = queryAndAssert<IronIconElement>(element, 'iron-icon');
+    assert.isFalse(icon.classList.contains('active'));
+    assert.equal(icon.icon, 'gr-icons:star-border');
+  });
+
+  test('starring', async () => {
+    element.set('change.starred', false);
+    await flush();
+    assert.equal(element.change!.starred, false);
+
+    MockInteractions.tap(queryAndAssert(element, 'button'));
+    await flush();
+    assert.equal(element.change!.starred, true);
+  });
+
+  test('unstarring', async () => {
+    element.set('change.starred', true);
+    await flush();
+    assert.equal(element.change!.starred, true);
+
+    MockInteractions.tap(queryAndAssert(element, 'button'));
+    await flush();
+    assert.equal(element.change!.starred, false);
+  });
+});
diff --git a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.ts b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.ts
index c84344e..1fd019f 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.ts
+++ b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-tooltip-content/gr-tooltip-content';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-change-status_html';
 import {customElement, property} from '@polymer/decorators';
@@ -43,9 +42,8 @@
   'This change is only visible to its owner and ' +
   'current reviewers (or anyone with "View Private Changes" permission).';
 
-/** @extends PolymerElement */
 @customElement('gr-change-status')
-class GrChangeStatus extends LegacyElementMixin(PolymerElement) {
+class GrChangeStatus extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
index a2c2eaa..7e67fb8 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
@@ -15,11 +15,9 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import '../gr-storage/gr-storage';
 import '../gr-comment/gr-comment';
 import '../../diff/gr-diff/gr-diff';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-comment-thread_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -52,7 +50,6 @@
 } from '../../../types/common';
 import {GrComment} from '../gr-comment/gr-comment';
 import {PolymerDeepPropertyChange} from '@polymer/polymer/interfaces';
-import {GrStorage, StorageLocation} from '../gr-storage/gr-storage';
 import {CustomKeyboardEvent} from '../../../types/events';
 import {LineNumber, FILE} from '../../diff/gr-diff/gr-diff-line';
 import {GrButton} from '../gr-button/gr-button';
@@ -62,6 +59,7 @@
 import {check, assertIsDefined} from '../../../utils/common-util';
 import {waitForEventOnce} from '../../../utils/event-util';
 import {GrSyntaxLayer} from '../../diff/gr-syntax-layer/gr-syntax-layer';
+import {StorageLocation} from '../../../services/storage/gr-storage';
 
 const UNRESOLVED_EXPAND_COUNT = 5;
 const NEWLINE_PATTERN = /\n/g;
@@ -74,9 +72,7 @@
 }
 
 @customElement('gr-comment-thread')
-export class GrCommentThread extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrCommentThread extends KeyboardShortcutMixin(PolymerElement) {
   // KeyboardShortcutMixin Not used in this element rather other elements tests
 
   static get template() {
@@ -211,7 +207,7 @@
 
   flagsService = appContext.flagsService;
 
-  readonly storage = new GrStorage();
+  readonly storage = appContext.storageService;
 
   private readonly syntaxLayer = new GrSyntaxLayer();
 
@@ -221,17 +217,16 @@
 
   readonly restApiService = appContext.restApiService;
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('comment-update', e =>
       this._handleCommentUpdate(e as CustomEvent)
     );
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._getLoggedIn().then(loggedIn => {
       this._showActions = loggedIn;
     });
@@ -521,7 +516,7 @@
 
     if (!isEditing) {
       // Allow the reply to render in the dom-repeat.
-      this.async(() => {
+      setTimeout(() => {
         const commentEl = this._commentElWithDraftID(reply.__draftID);
         if (commentEl) commentEl.save();
       }, 1);
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
index 60df799..0c53ec1 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
@@ -204,7 +204,6 @@
           prefs="[[_prefs]]"
           render-prefs="[[_renderPrefs]]"
           highlight-range="[[getHighlightRange(comments)]]"
-          on-render="_handleDiffRender"
         >
         </gr-diff>
         <div class="view-diff-container">
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
index f2df89d..35b0d8c 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
@@ -15,18 +15,18 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import './gr-comment-thread.js';
-import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
-import {SpecialFilePath, Side} from '../../../constants/constants.js';
+import '../../../test/common-test-setup-karma';
+import './gr-comment-thread';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation';
+import {SpecialFilePath, Side} from '../../../constants/constants';
 import {
   sortComments,
   UIComment,
   UIRobot,
   isDraft,
   UIDraft,
-} from '../../../utils/comment-util.js';
-import {GrCommentThread} from './gr-comment-thread.js';
+} from '../../../utils/comment-util';
+import {GrCommentThread} from './gr-comment-thread';
 import {
   PatchSetNum,
   NumericChangeId,
@@ -37,15 +37,15 @@
   RepoName,
   ConfigInfo,
   EmailAddress,
-} from '../../../types/common.js';
-import {GrComment} from '../gr-comment/gr-comment.js';
-import {LineNumber} from '../../diff/gr-diff/gr-diff-line.js';
+} from '../../../types/common';
+import {GrComment} from '../gr-comment/gr-comment';
+import {LineNumber} from '../../diff/gr-diff/gr-diff-line';
 import {
   tap,
   pressAndReleaseKeyOn,
 } from '@polymer/iron-test-helpers/mock-interactions';
 import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-import {stubRestApi} from '../../../test/test-utils';
+import {stubRestApi, stubStorage} from '../../../test/test-utils';
 
 const basicFixture = fixtureFromElement('gr-comment-thread');
 
@@ -652,7 +652,7 @@
           __draft: true,
         },
       ];
-      const storageStub = sinon.stub(element.storage, 'setDraftComment');
+      const storageStub = stubStorage('setDraftComment');
       flush();
 
       const draftEl = element.root?.querySelectorAll('gr-comment')[1];
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index cdb01c3..b7f1bcc 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -24,13 +24,11 @@
 import '../gr-formatted-text/gr-formatted-text';
 import '../gr-icons/gr-icons';
 import '../gr-overlay/gr-overlay';
-import '../gr-storage/gr-storage';
 import '../gr-textarea/gr-textarea';
 import '../gr-tooltip-content/gr-tooltip-content';
 import '../gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog';
 import '../gr-account-label/gr-account-label';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-comment_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -39,7 +37,6 @@
 import {customElement, observe, property} from '@polymer/decorators';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
 import {GrTextarea} from '../gr-textarea/gr-textarea';
-import {GrStorage, StorageLocation} from '../gr-storage/gr-storage';
 import {GrOverlay} from '../gr-overlay/gr-overlay';
 import {
   AccountDetailInfo,
@@ -62,6 +59,8 @@
 import {fireAlert} from '../../../utils/event-util';
 import {pluralize} from '../../../utils/string-util';
 import {assertIsDefined} from '../../../utils/common-util';
+import {debounce, DelayedTask} from '../../../utils/async-util';
+import {StorageLocation} from '../../../services/storage/gr-storage';
 
 const STORAGE_DEBOUNCE_INTERVAL = 400;
 const TOAST_DEBOUNCE_INTERVAL = 200;
@@ -101,16 +100,8 @@
   };
 }
 
-const DEBOUNCER_FIRE_UPDATE = 'fire-update';
-
-const DEBOUNCER_STORE = 'store';
-
-const DEBOUNCER_DRAFT_TOAST = 'draft-toast';
-
 @customElement('gr-comment')
-export class GrComment extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrComment extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -277,13 +268,19 @@
 
   private readonly restApiService = appContext.restApiService;
 
-  private readonly storage = new GrStorage();
+  private readonly storage = appContext.storageService;
 
   reporting = appContext.reportingService;
 
+  private fireUpdateTask?: DelayedTask;
+
+  private storeTask?: DelayedTask;
+
+  private draftToastTask?: DelayedTask;
+
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.restApiService.getAccount().then(account => {
       this._selfAccount = account;
     });
@@ -298,14 +295,14 @@
   }
 
   /** @override */
-  detached() {
-    super.detached();
-    this.cancelDebouncer(DEBOUNCER_FIRE_UPDATE);
-    this.cancelDebouncer(DEBOUNCER_STORE);
-    this.cancelDebouncer(DEBOUNCER_DRAFT_TOAST);
+  disconnectedCallback() {
+    this.fireUpdateTask?.cancel();
+    this.storeTask?.cancel();
+    this.draftToastTask?.cancel();
     if (this.textarea) {
       this.textarea.closeDropdown();
     }
+    super.disconnectedCallback();
   }
 
   _getAuthor(comment: UIComment) {
@@ -495,7 +492,7 @@
   _eraseDraftComment() {
     // Prevents a race condition in which removing the draft comment occurs
     // prior to it being saved.
-    this.cancelDebouncer(DEBOUNCER_STORE);
+    this.storeTask?.cancel();
 
     assertIsDefined(this.comment?.path, 'comment.path');
     assertIsDefined(this.changeNum, 'changeNum');
@@ -545,7 +542,7 @@
   }
 
   _fireUpdate() {
-    this.debounce(DEBOUNCER_FIRE_UPDATE, () => {
+    this.fireUpdateTask = debounce(this.fireUpdateTask, () => {
       this.dispatchEvent(
         new CustomEvent('comment-update', {
           detail: this._getEventPayload(),
@@ -587,7 +584,7 @@
       this._fireUpdate();
     }
     if (editing) {
-      this.async(() => {
+      setTimeout(() => {
         flush();
         this.textarea && this.textarea.putCursorAtEnd();
       }, 1);
@@ -653,8 +650,8 @@
       : this._getPatchNum();
     const {path, line, range} = this.comment;
     if (path) {
-      this.debounce(
-        DEBOUNCER_STORE,
+      this.storeTask = debounce(
+        this.storeTask,
         () => {
           const message = this._messageText;
           if (this.changeNum === undefined) {
@@ -736,7 +733,7 @@
   }
 
   _fireDiscard() {
-    this.cancelDebouncer(DEBOUNCER_FIRE_UPDATE);
+    this.fireUpdateTask?.cancel();
     this.dispatchEvent(
       new CustomEvent('comment-discard', {
         detail: this._getEventPayload(),
@@ -859,7 +856,7 @@
 
     // Cancel the debouncer so that error toasts from the error-manager will
     // not be overridden.
-    this.cancelDebouncer(DEBOUNCER_DRAFT_TOAST);
+    this.draftToastTask?.cancel();
     this._updateRequestToast(
       this._numPendingDraftRequests.number,
       /* requestFailed=*/ true
@@ -868,8 +865,8 @@
 
   _updateRequestToast(numPending: number, requestFailed?: boolean) {
     const message = this._getSavingMessage(numPending, requestFailed);
-    this.debounce(
-      DEBOUNCER_DRAFT_TOAST,
+    this.draftToastTask = debounce(
+      this.draftToastTask,
       () => {
         // Note: the event is fired on the body rather than this element because
         // this element may not be attached by the time this executes, in which
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
index f28a7fe..be647ab 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
@@ -20,7 +20,7 @@
 import {html} from '@polymer/polymer/lib/utils/html-tag.js';
 import {__testOnly_UNSAVED_MESSAGE} from './gr-comment.js';
 import {SpecialFilePath, Side} from '../../../constants/constants.js';
-import {stubRestApi} from '../../../test/test-utils.js';
+import {stubRestApi, stubStorage} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-comment');
 
@@ -115,7 +115,7 @@
     });
 
     test('message is not retrieved from storage when other edits', done => {
-      const storageStub = sinon.stub(element.storage, 'getDraftComment');
+      const storageStub = stubStorage('getDraftComment');
       const loadSpy = sinon.spy(element, '_loadLocalDraft');
 
       element.changeNum = 1;
@@ -135,7 +135,7 @@
     });
 
     test('message is retrieved from storage when no other edits', done => {
-      const storageStub = sinon.stub(element.storage, 'getDraftComment');
+      const storageStub = stubStorage('getDraftComment');
       const loadSpy = sinon.spy(element, '_loadLocalDraft');
 
       element.changeNum = 1;
@@ -768,7 +768,7 @@
       });
       MockInteractions.tap(element.shadowRoot
           .querySelector('.cancel'));
-      element.flushDebouncer('fire-update');
+      element.fireUpdateTask.flush();
       element._messageText = '';
       flush();
       MockInteractions.pressAndReleaseKeyOn(element.textarea, 27); // esc
@@ -867,21 +867,20 @@
 
     test('draft saving/editing', done => {
       const dispatchEventStub = sinon.stub(element, 'dispatchEvent');
-      const cancelDebounce = sinon.stub(element, 'cancelDebouncer');
 
       element.draft = true;
       flush();
       MockInteractions.tap(element.shadowRoot
           .querySelector('.edit'));
       element._messageText = 'good news, everyone!';
-      element.flushDebouncer('fire-update');
-      element.flushDebouncer('store');
+      element.fireUpdateTask.flush();
+      element.storeTask.flush();
       assert.equal(dispatchEventStub.lastCall.args[0].type, 'comment-update');
       assert.isTrue(dispatchEventStub.calledTwice);
 
       element._messageText = 'good news, everyone!';
-      element.flushDebouncer('fire-update');
-      element.flushDebouncer('store');
+      element.fireUpdateTask.flush();
+      element.storeTask.flush();
       assert.isTrue(dispatchEventStub.calledTwice);
 
       MockInteractions.tap(element.shadowRoot
@@ -892,7 +891,7 @@
 
       element._xhrPromise.then(draft => {
         assert.equal(dispatchEventStub.lastCall.args[0].type, 'comment-save');
-        assert(cancelDebounce.calledWith('store'));
+        assert.isFalse(element.storeTask.isActive());
 
         assert.deepEqual(dispatchEventStub.lastCall.args[0].detail, {
           comment: {
@@ -940,8 +939,8 @@
       MockInteractions.tap(element.shadowRoot
           .querySelector('.edit'));
       element._messageText = 'good news, everyone!';
-      element.flushDebouncer('fire-update');
-      element.flushDebouncer('store');
+      element.fireUpdateTask.flush();
+      element.storeTask.flush();
 
       element.disabled = true;
       MockInteractions.tap(element.shadowRoot
@@ -1023,11 +1022,11 @@
 
     test('cancelling an unsaved draft discards, persists in storage', () => {
       const discardSpy = sinon.spy(element, '_fireDiscard');
-      const storeStub = sinon.stub(element.storage, 'setDraftComment');
-      const eraseStub = sinon.stub(element.storage, 'eraseDraftComment');
+      const storeStub = stubStorage('setDraftComment');
+      const eraseStub = stubStorage('eraseDraftComment');
       element._messageText = 'test text';
       flush();
-      element.flushDebouncer('store');
+      element.storeTask.flush();
 
       assert.isTrue(storeStub.called);
       assert.equal(storeStub.lastCall.args[1], 'test text');
@@ -1039,10 +1038,10 @@
     test('cancelling edit on a saved draft does not store', () => {
       element.comment.id = 'foo';
       const discardSpy = sinon.spy(element, '_fireDiscard');
-      const storeStub = sinon.stub(element.storage, 'setDraftComment');
+      const storeStub = stubStorage('setDraftComment');
       element._messageText = 'test text';
       flush();
-      element.flushDebouncer('store');
+      if (element.storeTask) element.storeTask.flush();
 
       assert.isFalse(storeStub.called);
       element._handleCancel({preventDefault: () => {}});
diff --git a/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.ts b/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.ts
index 6a350b0..0f071abb 100644
--- a/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.ts
+++ b/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-dialog/gr-dialog';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-confirm-delete-comment-dialog_html';
 import {property, customElement} from '@polymer/decorators';
@@ -34,9 +33,7 @@
 }
 
 @customElement('gr-confirm-delete-comment-dialog')
-export class GrConfirmDeleteCommentDialog extends LegacyElementMixin(
-  PolymerElement
-) {
+export class GrConfirmDeleteCommentDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts
index 979ed02..110c242 100644
--- a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts
+++ b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts
@@ -19,7 +19,6 @@
 import '../gr-button/gr-button';
 import '../gr-icons/gr-icons';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-copy-clipboard_html';
 import {GrButton} from '../gr-button/gr-button';
@@ -38,9 +37,8 @@
   $: {button: GrButton; icon: IronIconElement; input: HTMLInputElement};
 }
 
-/** @extends PolymerElement */
 @customElement('gr-copy-clipboard')
-export class GrCopyClipboard extends LegacyElementMixin(PolymerElement) {
+export class GrCopyClipboard extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -84,7 +82,7 @@
       this.$.input.style.display = 'none';
     }
     this.$.icon.icon = 'gr-icons:check';
-    this.async(
+    setTimeout(
       () => (this.$.icon.icon = 'gr-icons:content-copy'),
       COPY_TIMEOUT_MS
     );
diff --git a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard_html.ts b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard_html.ts
index 197c94c..cea1d69 100644
--- a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard_html.ts
@@ -59,7 +59,7 @@
       class="copyText"
       type="text"
       bind-value="[[text]]"
-      on-tap="_handleInputClick"
+      on-click="_handleInputClick"
       readonly=""
     >
       <input
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
index 0d60784..8408c78 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
@@ -14,21 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-cursor-manager_html';
+import {BehaviorSubject} from 'rxjs';
 import {ScrollMode} from '../../../constants/constants';
-import {customElement, property, observe} from '@polymer/decorators';
-
-export interface GrCursorManager {
-  $: {};
-}
-
-declare global {
-  interface HTMLElementTagNameMap {
-    'gr-cursor-manager': GrCursorManager;
-  }
-}
 
 /**
  * Return type for cursor moves, that indicate whether a move was possible.
@@ -60,31 +47,33 @@
   return !(stop instanceof AbortStop);
 }
 
-@customElement('gr-cursor-manager')
-export class GrCursorManager extends LegacyElementMixin(PolymerElement) {
-  static get template() {
-    return htmlTemplate;
+export class GrCursorManager {
+  get target(): HTMLElement | null {
+    return this.targetSubject.getValue();
   }
 
-  @property({type: Object, notify: true})
-  target: HTMLElement | null = null;
+  set target(target: HTMLElement | null) {
+    this.targetSubject.next(target);
+    this._scrollToTarget();
+  }
+
+  private targetSubject = new BehaviorSubject<HTMLElement | null>(null);
+
+  target$ = this.targetSubject.asObservable();
 
   /**
    * The height of content intended to be included with the target.
    */
-  @property({type: Number})
   _targetHeight: number | null = null;
 
   /**
    * The index of the current target (if any). -1 otherwise.
    */
-  @property({type: Number, notify: true})
   index = -1;
 
   /**
    * The class to apply to the current target. Use null for no class.
    */
-  @property({type: String})
   cursorTargetClass: string | null = null;
 
   /**
@@ -95,29 +84,29 @@
    *
    * @type {string|undefined}
    */
-  @property({type: String})
   scrollMode: string = ScrollMode.NEVER;
 
   /**
    * When true, will call element.focus() during scrolling.
    */
-  @property({type: Boolean})
   focusOnMove = false;
 
-  @property({type: Array})
-  stops: Stop[] = [];
+  set stops(stops: Stop[]) {
+    this.stopsInternal = stops;
+    this._updateIndex();
+  }
+
+  get stops(): Stop[] {
+    return this.stopsInternal;
+  }
+
+  private stopsInternal: Stop[] = [];
 
   /** Only non-AbortStop stops. */
   get targetableStops(): HTMLElement[] {
     return this.stops.filter(isTargetable);
   }
 
-  /** @override */
-  detached() {
-    super.detached();
-    this.unsetCursor();
-  }
-
   /**
    * Move the cursor forward. Clipped to the ends of the stop list.
    *
@@ -383,7 +372,6 @@
     }
   }
 
-  @observe('stops')
   _updateIndex() {
     if (!this.target) {
       this.index = -1;
@@ -430,7 +418,6 @@
     return top + -dims.innerHeight / 3 + target.offsetHeight / 2;
   }
 
-  @observe('target')
   _scrollToTarget() {
     if (!this.target || this.scrollMode === ScrollMode.NEVER) {
       return;
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_html.ts b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_html.ts
deleted file mode 100644
index 1489006..0000000
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_html.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html``;
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.js b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.js
index 6f74d6b..e51d190 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.js
@@ -18,10 +18,9 @@
 import '../../../test/common-test-setup-karma.js';
 import './gr-cursor-manager.js';
 import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-import {AbortStop, CursorMoveResult} from './gr-cursor-manager.js';
+import {AbortStop, CursorMoveResult, GrCursorManager} from './gr-cursor-manager.js';
 
 const basicTestFixutre = fixtureFromTemplate(html`
-    <gr-cursor-manager cursor-target-class="targeted"></gr-cursor-manager>
     <ul>
       <li>A</li>
       <li>B</li>
@@ -31,180 +30,180 @@
 `);
 
 suite('gr-cursor-manager tests', () => {
-  let element;
+  let cursor;
   let list;
 
   setup(() => {
-    const fixtureElements = basicTestFixutre.instantiate();
-    element = fixtureElements[0];
-    list = fixtureElements[1];
+    list = basicTestFixutre.instantiate();
+    cursor = new GrCursorManager();
+    cursor.cursorTargetClass = 'targeted';
   });
 
   test('core cursor functionality', () => {
     // The element is initialized into the proper state.
-    assert.isArray(element.stops);
-    assert.equal(element.stops.length, 0);
-    assert.equal(element.index, -1);
-    assert.isNotOk(element.target);
+    assert.isArray(cursor.stops);
+    assert.equal(cursor.stops.length, 0);
+    assert.equal(cursor.index, -1);
+    assert.isNotOk(cursor.target);
 
     // Initialize the cursor with its stops.
-    element.stops = [...list.querySelectorAll('li')];
+    cursor.stops = [...list.querySelectorAll('li')];
 
     // It should have the stops but it should not be targeting any of them.
-    assert.isNotNull(element.stops);
-    assert.equal(element.stops.length, 4);
-    assert.equal(element.index, -1);
-    assert.isNotOk(element.target);
+    assert.isNotNull(cursor.stops);
+    assert.equal(cursor.stops.length, 4);
+    assert.equal(cursor.index, -1);
+    assert.isNotOk(cursor.target);
 
     // Select the third stop.
-    element.setCursor(list.children[2]);
+    cursor.setCursor(list.children[2]);
 
     // It should update its internal state and update the element's class.
-    assert.equal(element.index, 2);
-    assert.equal(element.target, list.children[2]);
+    assert.equal(cursor.index, 2);
+    assert.equal(cursor.target, list.children[2]);
     assert.isTrue(list.children[2].classList.contains('targeted'));
-    assert.isFalse(element.isAtStart());
-    assert.isFalse(element.isAtEnd());
+    assert.isFalse(cursor.isAtStart());
+    assert.isFalse(cursor.isAtEnd());
 
     // Progress the cursor.
-    let result = element.next();
+    let result = cursor.next();
 
     // Confirm that the next stop is selected and that the previous stop is
     // unselected.
     assert.equal(result, CursorMoveResult.MOVED);
-    assert.equal(element.index, 3);
-    assert.equal(element.target, list.children[3]);
-    assert.isTrue(element.isAtEnd());
+    assert.equal(cursor.index, 3);
+    assert.equal(cursor.target, list.children[3]);
+    assert.isTrue(cursor.isAtEnd());
     assert.isFalse(list.children[2].classList.contains('targeted'));
     assert.isTrue(list.children[3].classList.contains('targeted'));
 
     // Progress the cursor.
-    result = element.next();
+    result = cursor.next();
 
     // We should still be at the end.
     assert.equal(result, CursorMoveResult.CLIPPED);
-    assert.equal(element.index, 3);
-    assert.equal(element.target, list.children[3]);
-    assert.isTrue(element.isAtEnd());
+    assert.equal(cursor.index, 3);
+    assert.equal(cursor.target, list.children[3]);
+    assert.isTrue(cursor.isAtEnd());
 
     // Wind the cursor all the way back to the first stop.
-    result = element.previous();
+    result = cursor.previous();
     assert.equal(result, CursorMoveResult.MOVED);
-    result = element.previous();
+    result = cursor.previous();
     assert.equal(result, CursorMoveResult.MOVED);
-    result = element.previous();
+    result = cursor.previous();
     assert.equal(result, CursorMoveResult.MOVED);
 
     // The element state should reflect the start of the list.
-    assert.equal(element.index, 0);
-    assert.equal(element.target, list.children[0]);
-    assert.isTrue(element.isAtStart());
+    assert.equal(cursor.index, 0);
+    assert.equal(cursor.target, list.children[0]);
+    assert.isTrue(cursor.isAtStart());
     assert.isTrue(list.children[0].classList.contains('targeted'));
 
     const newLi = document.createElement('li');
     newLi.textContent = 'Z';
     list.insertBefore(newLi, list.children[0]);
-    element.stops = [...list.querySelectorAll('li')];
+    cursor.stops = [...list.querySelectorAll('li')];
 
-    assert.equal(element.index, 1);
+    assert.equal(cursor.index, 1);
 
     // De-select all targets.
-    element.unsetCursor();
+    cursor.unsetCursor();
 
     // There should now be no cursor target.
     assert.isFalse(list.children[1].classList.contains('targeted'));
-    assert.isNotOk(element.target);
-    assert.equal(element.index, -1);
+    assert.isNotOk(cursor.target);
+    assert.equal(cursor.index, -1);
   });
 
   test('isAtStart() returns true when there are no stops', () => {
-    element.stops = [];
-    assert.isTrue(element.isAtStart());
+    cursor.stops = [];
+    assert.isTrue(cursor.isAtStart());
   });
 
   test('isAtEnd() returns true when there are no stops', () => {
-    element.stops = [];
-    assert.isTrue(element.isAtEnd());
+    cursor.stops = [];
+    assert.isTrue(cursor.isAtEnd());
   });
 
   test('next() goes to first element when no cursor is set', () => {
-    element.stops = [...list.querySelectorAll('li')];
-    const result = element.next();
+    cursor.stops = [...list.querySelectorAll('li')];
+    const result = cursor.next();
 
     assert.equal(result, CursorMoveResult.MOVED);
-    assert.equal(element.index, 0);
-    assert.equal(element.target, list.children[0]);
+    assert.equal(cursor.index, 0);
+    assert.equal(cursor.target, list.children[0]);
     assert.isTrue(list.children[0].classList.contains('targeted'));
-    assert.isTrue(element.isAtStart());
-    assert.isFalse(element.isAtEnd());
+    assert.isTrue(cursor.isAtStart());
+    assert.isFalse(cursor.isAtEnd());
   });
 
   test('next() resets the cursor when there are no stops', () => {
-    element.stops = [];
-    const result = element.next();
+    cursor.stops = [];
+    const result = cursor.next();
 
     assert.equal(result, CursorMoveResult.NO_STOPS);
-    assert.equal(element.index, -1);
-    assert.isNotOk(element.target);
+    assert.equal(cursor.index, -1);
+    assert.isNotOk(cursor.target);
     assert.isFalse(list.children[1].classList.contains('targeted'));
   });
 
   test('previous() goes to last element when no cursor is set', () => {
-    element.stops = [...list.querySelectorAll('li')];
-    const result = element.previous();
+    cursor.stops = [...list.querySelectorAll('li')];
+    const result = cursor.previous();
 
     assert.equal(result, CursorMoveResult.MOVED);
     const lastIndex = list.children.length - 1;
-    assert.equal(element.index, lastIndex);
-    assert.equal(element.target, list.children[lastIndex]);
+    assert.equal(cursor.index, lastIndex);
+    assert.equal(cursor.target, list.children[lastIndex]);
     assert.isTrue(list.children[lastIndex].classList.contains('targeted'));
-    assert.isFalse(element.isAtStart());
-    assert.isTrue(element.isAtEnd());
+    assert.isFalse(cursor.isAtStart());
+    assert.isTrue(cursor.isAtEnd());
   });
 
   test('previous() resets the cursor when there are no stops', () => {
-    element.stops = [];
-    const result = element.previous();
+    cursor.stops = [];
+    const result = cursor.previous();
 
     assert.equal(result, CursorMoveResult.NO_STOPS);
-    assert.equal(element.index, -1);
-    assert.isNotOk(element.target);
+    assert.equal(cursor.index, -1);
+    assert.isNotOk(cursor.target);
     assert.isFalse(list.children[1].classList.contains('targeted'));
   });
 
   test('_moveCursor', () => {
     // Initialize the cursor with its stops.
-    element.stops = [...list.querySelectorAll('li')];
+    cursor.stops = [...list.querySelectorAll('li')];
     // Select the first stop.
-    element.setCursor(list.children[0]);
+    cursor.setCursor(list.children[0]);
     const getTargetHeight = sinon.stub();
 
     // Move the cursor without an optional get target height function.
-    element._moveCursor(1);
+    cursor._moveCursor(1);
     assert.isFalse(getTargetHeight.called);
 
     // Move the cursor with an optional get target height function.
-    element._moveCursor(1, {getTargetHeight});
+    cursor._moveCursor(1, {getTargetHeight});
     assert.isTrue(getTargetHeight.called);
   });
 
   test('_moveCursor from for invalid index does not check height', () => {
-    element.stops = [];
+    cursor.stops = [];
     const getTargetHeight = sinon.stub();
-    element._moveCursor(1, () => false, {getTargetHeight});
+    cursor._moveCursor(1, () => false, {getTargetHeight});
     assert.isFalse(getTargetHeight.called);
   });
 
   test('setCursorAtIndex with noScroll', () => {
-    sinon.stub(element, '_targetIsVisible').callsFake(() => false);
+    sinon.stub(cursor, '_targetIsVisible').callsFake(() => false);
     const scrollStub = sinon.stub(window, 'scrollTo');
-    element.stops = [...list.querySelectorAll('li')];
-    element.scrollMode = 'keep-visible';
+    cursor.stops = [...list.querySelectorAll('li')];
+    cursor.scrollMode = 'keep-visible';
 
-    element.setCursorAtIndex(1, true);
+    cursor.setCursorAtIndex(1, true);
     assert.isFalse(scrollStub.called);
 
-    element.setCursorAtIndex(2);
+    cursor.setCursorAtIndex(2);
     assert.isTrue(scrollStub.called);
   });
 
@@ -212,30 +211,30 @@
     const isLetterB = function(row) {
       return row.textContent === 'B';
     };
-    element.stops = [...list.querySelectorAll('li')];
+    cursor.stops = [...list.querySelectorAll('li')];
     // Start cursor at the first stop.
-    element.setCursor(list.children[0]);
+    cursor.setCursor(list.children[0]);
 
     // Move forward to meet the next condition.
-    element.next({filter: isLetterB});
-    assert.equal(element.index, 1);
+    cursor.next({filter: isLetterB});
+    assert.equal(cursor.index, 1);
 
     // Nothing else meets the condition, should be at last stop.
-    element.next({filter: isLetterB});
-    assert.equal(element.index, 3);
+    cursor.next({filter: isLetterB});
+    assert.equal(cursor.index, 3);
 
     // Should stay at last stop if try to proceed.
-    element.next({filter: isLetterB});
-    assert.equal(element.index, 3);
+    cursor.next({filter: isLetterB});
+    assert.equal(cursor.index, 3);
 
     // Go back to the previous condition met. Should be back at.
     // stop 1.
-    element.previous({filter: isLetterB});
-    assert.equal(element.index, 1);
+    cursor.previous({filter: isLetterB});
+    assert.equal(cursor.index, 1);
 
     // Go back. No more meet the condition. Should be at stop 0.
-    element.previous({filter: isLetterB});
-    assert.equal(element.index, 0);
+    cursor.previous({filter: isLetterB});
+    assert.equal(cursor.index, 0);
   });
 
   test('focusOnMove prop', () => {
@@ -243,129 +242,129 @@
     for (let i = 0; i < listEls.length; i++) {
       sinon.spy(listEls[i], 'focus');
     }
-    element.stops = listEls;
-    element.setCursor(list.children[0]);
+    cursor.stops = listEls;
+    cursor.setCursor(list.children[0]);
 
-    element.focusOnMove = false;
-    element.next();
-    assert.isFalse(element.target.focus.called);
+    cursor.focusOnMove = false;
+    cursor.next();
+    assert.isFalse(cursor.target.focus.called);
 
-    element.focusOnMove = true;
-    element.next();
-    assert.isTrue(element.target.focus.called);
+    cursor.focusOnMove = true;
+    cursor.next();
+    assert.isTrue(cursor.target.focus.called);
   });
 
   suite('_scrollToTarget', () => {
     let scrollStub;
     setup(() => {
-      element.stops = [...list.querySelectorAll('li')];
-      element.scrollMode = 'keep-visible';
+      cursor.stops = [...list.querySelectorAll('li')];
+      cursor.scrollMode = 'keep-visible';
 
       // There is a target which has a targetNext
-      element.setCursor(list.children[0]);
-      element._moveCursor(1);
+      cursor.setCursor(list.children[0]);
+      cursor._moveCursor(1);
       scrollStub = sinon.stub(window, 'scrollTo');
       window.innerHeight = 60;
     });
 
     test('Called when top and bottom not visible', () => {
-      sinon.stub(element, '_targetIsVisible').returns(false);
-      element._scrollToTarget();
+      sinon.stub(cursor, '_targetIsVisible').returns(false);
+      cursor._scrollToTarget();
       assert.isTrue(scrollStub.called);
     });
 
     test('Not called when top and bottom visible', () => {
-      sinon.stub(element, '_targetIsVisible').returns(true);
-      element._scrollToTarget();
+      sinon.stub(cursor, '_targetIsVisible').returns(true);
+      cursor._scrollToTarget();
       assert.isFalse(scrollStub.called);
     });
 
     test('Called when top is visible, bottom is not, scroll is lower', () => {
-      const visibleStub = sinon.stub(element, '_targetIsVisible').callsFake(
+      const visibleStub = sinon.stub(cursor, '_targetIsVisible').callsFake(
           () => visibleStub.callCount === 2);
-      sinon.stub(element, '_getWindowDims').returns({
+      sinon.stub(cursor, '_getWindowDims').returns({
         scrollX: 123,
         scrollY: 15,
         innerHeight: 1000,
         pageYOffset: 0,
       });
-      sinon.stub(element, '_calculateScrollToValue').returns(20);
-      element._scrollToTarget();
+      sinon.stub(cursor, '_calculateScrollToValue').returns(20);
+      cursor._scrollToTarget();
       assert.isTrue(scrollStub.called);
       assert.isTrue(scrollStub.calledWithExactly(123, 20));
       assert.equal(visibleStub.callCount, 2);
     });
 
     test('Called when top is visible, bottom not, scroll is higher', () => {
-      const visibleStub = sinon.stub(element, '_targetIsVisible').callsFake(
+      const visibleStub = sinon.stub(cursor, '_targetIsVisible').callsFake(
           () => visibleStub.callCount === 2);
-      sinon.stub(element, '_getWindowDims').returns({
+      sinon.stub(cursor, '_getWindowDims').returns({
         scrollX: 123,
         scrollY: 25,
         innerHeight: 1000,
         pageYOffset: 0,
       });
-      sinon.stub(element, '_calculateScrollToValue').returns(20);
-      element._scrollToTarget();
+      sinon.stub(cursor, '_calculateScrollToValue').returns(20);
+      cursor._scrollToTarget();
       assert.isFalse(scrollStub.called);
       assert.equal(visibleStub.callCount, 2);
     });
 
     test('_calculateScrollToValue', () => {
-      sinon.stub(element, '_getWindowDims').returns({
+      sinon.stub(cursor, '_getWindowDims').returns({
         scrollX: 123,
         scrollY: 25,
         innerHeight: 300,
         pageYOffset: 0,
       });
-      assert.equal(element._calculateScrollToValue(1000, {offsetHeight: 10}),
+      assert.equal(cursor._calculateScrollToValue(1000, {offsetHeight: 10}),
           905);
     });
   });
 
   suite('AbortStops', () => {
     test('next() does not skip AbortStops', () => {
-      element.stops = [
+      cursor.stops = [
         document.createElement('li'),
         new AbortStop(),
         document.createElement('li'),
       ];
-      element.setCursorAtIndex(0);
+      cursor.setCursorAtIndex(0);
 
-      const result = element.next();
+      const result = cursor.next();
 
       assert.equal(result, CursorMoveResult.ABORTED);
-      assert.equal(element.index, 0);
+      assert.equal(cursor.index, 0);
     });
 
     test('setCursorAtIndex() does not target AbortStops', () => {
-      element.stops = [
+      cursor.stops = [
         document.createElement('li'),
         new AbortStop(),
         document.createElement('li'),
       ];
-      element.setCursorAtIndex(1);
-      assert.equal(element.index, -1);
+      cursor.setCursorAtIndex(1);
+      assert.equal(cursor.index, -1);
     });
 
     test('moveToStart() does not target AbortStop', () => {
-      element.stops = [
+      cursor.stops = [
         new AbortStop(),
         document.createElement('li'),
         document.createElement('li'),
       ];
-      element.moveToStart();
-      assert.equal(element.index, -1);
+      cursor.moveToStart();
+      assert.equal(cursor.index, -1);
     });
 
     test('moveToEnd() does not target AbortStop', () => {
-      element.stops = [
+      cursor.stops = [
         document.createElement('li'),
         document.createElement('li'),
         new AbortStop(),
       ];
-      element.moveToEnd();
-      assert.equal(element.index, -1);
+      cursor.moveToEnd();
+      assert.equal(cursor.index, -1);
     });
   });
 });
diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts
index e1134f9..489b489 100644
--- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts
+++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-date-formatter_html';
 import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
@@ -77,9 +76,7 @@
 }
 
 @customElement('gr-date-formatter')
-export class GrDateFormatter extends TooltipMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrDateFormatter extends TooltipMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -133,8 +130,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._loadPreferences();
   }
 
diff --git a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts
index 62a2b82..7022a39 100644
--- a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-button/gr-button';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-dialog_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -35,7 +34,7 @@
 }
 
 @customElement('gr-dialog')
-export class GrDialog extends LegacyElementMixin(PolymerElement) {
+export class GrDialog extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.js b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.ts
similarity index 74%
rename from polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.js
rename to polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.ts
index 1238168..e7b7130 100644
--- a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.ts
@@ -15,14 +15,15 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import './gr-dialog.js';
-import {isHidden} from '../../../test/test-utils.js';
+import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
+import '../../../test/common-test-setup-karma';
+import {GrDialog} from './gr-dialog';
+import {isHidden, queryAndAssert} from '../../../test/test-utils';
 
 const basicFixture = fixtureFromElement('gr-dialog');
 
 suite('gr-dialog tests', () => {
-  let element;
+  let element: GrDialog;
 
   setup(() => {
     element = basicFixture.instantiate();
@@ -34,12 +35,10 @@
     element.addEventListener('confirm', confirm);
     element.addEventListener('cancel', cancel);
 
-    MockInteractions.tap(
-        element.shadowRoot.querySelector('gr-button[primary]'));
+    MockInteractions.tap(queryAndAssert(element, 'gr-button[primary]'));
     assert.equal(confirm.callCount, 1);
 
-    MockInteractions.tap(
-        element.shadowRoot.querySelector('gr-button:not([primary])'));
+    MockInteractions.tap(queryAndAssert(element, 'gr-button:not([primary])'));
     assert.equal(cancel.callCount, 1);
   });
 
@@ -48,7 +47,11 @@
     const handleConfirmStub = sinon.stub(element, '_handleConfirm');
     const handleKeydownSpy = sinon.spy(element, '_handleKeydown');
     MockInteractions.pressAndReleaseKeyOn(
-        element.shadowRoot.querySelector('main'), 13, null, 'enter');
+      queryAndAssert(element, 'main'),
+      13,
+      null,
+      'enter'
+    );
     flush();
 
     assert.isTrue(handleKeydownSpy.called);
@@ -56,7 +59,11 @@
 
     element.confirmOnEnter = true;
     MockInteractions.pressAndReleaseKeyOn(
-        element.shadowRoot.querySelector('main'), 13, null, 'enter');
+      queryAndAssert(element, 'main'),
+      13,
+      null,
+      'enter'
+    );
     flush();
 
     assert.isTrue(handleConfirmStub.called);
@@ -81,11 +88,11 @@
   });
 
   test('empty cancel label hides cancel btn', () => {
-    assert.isFalse(isHidden(element.$.cancel));
+    const cancelButton = queryAndAssert(element, '#cancel');
+    assert.isFalse(isHidden(cancelButton));
     element.cancelLabel = '';
     flush();
 
-    assert.isTrue(isHidden(element.$.cancel));
+    assert.isTrue(isHidden(cancelButton));
   });
 });
-
diff --git a/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.ts b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.ts
index 5664e22..70a7bf3 100644
--- a/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.ts
+++ b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.ts
@@ -18,7 +18,6 @@
 import '../../../styles/shared-styles';
 import '../gr-button/gr-button';
 import '../gr-select/gr-select';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-diff-preferences_html';
 import {customElement, property} from '@polymer/decorators';
@@ -39,7 +38,7 @@
 }
 
 @customElement('gr-diff-preferences')
-export class GrDiffPreferences extends LegacyElementMixin(PolymerElement) {
+export class GrDiffPreferences extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts
index db343c6..19cbb22 100644
--- a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts
+++ b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts
@@ -17,7 +17,6 @@
 import '@polymer/paper-tabs/paper-tabs';
 import '../gr-shell-command/gr-shell-command';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-download-commands_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -42,7 +41,7 @@
 }
 
 @customElement('gr-download-commands')
-export class GrDownloadCommands extends LegacyElementMixin(PolymerElement) {
+export class GrDownloadCommands extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -63,8 +62,8 @@
   private readonly restApiService = appContext.restApiService;
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this._getLoggedIn().then(loggedIn => {
       this._loggedIn = loggedIn;
     });
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
index 006a8de..ef46cec 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
@@ -22,7 +22,6 @@
 import '../gr-date-formatter/gr-date-formatter';
 import '../gr-select/gr-select';
 import '../gr-file-status-chip/gr-file-status-chip';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-dropdown-list_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -63,7 +62,7 @@
 export type DropDownValueChangeEvent = CustomEvent<ValueChangeDetail>;
 
 @customElement('gr-dropdown-list')
-export class GrDropdownList extends LegacyElementMixin(PolymerElement) {
+export class GrDropdownList extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -100,7 +99,7 @@
   _handleDropdownClick() {
     // async is needed so that that the click event is fired before the
     // dropdown closes (This was a bug for touch devices).
-    this.async(() => {
+    setTimeout(() => {
       this.$.dropdown.close();
     }, 1);
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.ts b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.ts
index 9918456..a8d28a5 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.ts
@@ -20,7 +20,6 @@
 import '../gr-tooltip-content/gr-tooltip-content';
 import '../../../styles/shared-styles';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-dropdown_html';
 import {getBaseUrl} from '../../../utils/url-util';
@@ -41,7 +40,6 @@
 export interface GrDropdown {
   $: {
     dropdown: IronDropdownElement;
-    cursor: GrCursorManager;
   };
 }
 
@@ -65,9 +63,7 @@
 }
 
 @customElement('gr-dropdown')
-export class GrDropdown extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrDropdown extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -113,12 +109,6 @@
   @property({type: Array})
   disabledIds: string[] = [];
 
-  /**
-   * The elements of the list.
-   */
-  @property({type: Array})
-  _listElements: Element[] = [];
-
   get keyBindings() {
     return {
       down: '_handleDown',
@@ -128,6 +118,19 @@
     };
   }
 
+  private cursor = new GrCursorManager();
+
+  constructor() {
+    super();
+    this.cursor.cursorTargetClass = 'selected';
+  }
+
+  /** @override */
+  disconnectedCallback() {
+    this.cursor.unsetCursor();
+    super.disconnectedCallback();
+  }
+
   /**
    * Handle the up key.
    */
@@ -135,7 +138,7 @@
     if (this.$.dropdown.opened) {
       e.preventDefault();
       e.stopPropagation();
-      this.$.cursor.previous();
+      this.cursor.previous();
     } else {
       this._open();
     }
@@ -148,7 +151,7 @@
     if (this.$.dropdown.opened) {
       e.preventDefault();
       e.stopPropagation();
-      this.$.cursor.next();
+      this.cursor.next();
     } else {
       this._open();
     }
@@ -175,8 +178,8 @@
       // TODO(milutin): This solution is not particularly robust in general.
       // Since gr-tooltip-content click on shadow dom is not propagated down,
       // we have to target `a` inside it.
-      if (this.$.cursor.target !== null) {
-        const el = this.$.cursor.target.querySelector(':not([hidden]) a');
+      if (this.cursor.target !== null) {
+        const el = this.cursor.target.querySelector(':not([hidden]) a');
         if (el) {
           (el as HTMLElement).click();
         }
@@ -212,14 +215,14 @@
   _open() {
     this.$.dropdown.open();
     this._resetCursorStops();
-    this.$.cursor.setCursorAtIndex(0);
-    if (this.$.cursor.target !== null) this.$.cursor.target.focus();
+    this.cursor.setCursorAtIndex(0);
+    if (this.cursor.target !== null) this.cursor.target.focus();
   }
 
   _close() {
     // async is needed so that that the click event is fired before the
     // dropdown closes (This was a bug for touch devices).
-    this.async(() => {
+    setTimeout(() => {
       this.$.dropdown.close();
     }, 1);
   }
@@ -328,7 +331,7 @@
   _resetCursorStops() {
     if (this.items && this.items.length > 0 && this.$.dropdown.opened) {
       flush();
-      this._listElements =
+      this.cursor.stops =
         this.root !== null ? Array.from(this.root.querySelectorAll('li')) : [];
     }
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts
index c767edd..3d22ed9 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts
@@ -158,11 +158,4 @@
       </ul>
     </div>
   </iron-dropdown>
-  <gr-cursor-manager
-    id="cursor"
-    cursor-target-class="selected"
-    scroll-mode="never"
-    focus-on-move=""
-    stops="[[_listElements]]"
-  ></gr-cursor-manager>
 `;
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.js b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.js
index fea4a08..c271b41 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.js
@@ -153,7 +153,7 @@
     });
 
     test('down', () => {
-      const stub = sinon.stub(element.$.cursor, 'next');
+      const stub = sinon.stub(element.cursor, 'next');
       assert.isFalse(element.$.dropdown.opened);
       MockInteractions.pressAndReleaseKeyOn(element, 40);
       assert.isTrue(element.$.dropdown.opened);
@@ -162,7 +162,7 @@
     });
 
     test('up', () => {
-      const stub = sinon.stub(element.$.cursor, 'previous');
+      const stub = sinon.stub(element.cursor, 'previous');
       assert.isFalse(element.$.dropdown.opened);
       MockInteractions.pressAndReleaseKeyOn(element, 38);
       assert.isTrue(element.$.dropdown.opened);
@@ -177,7 +177,7 @@
       MockInteractions.pressAndReleaseKeyOn(element, 32); // Space
       assert.isTrue(element.$.dropdown.opened);
 
-      const el = element.$.cursor.target.querySelector(':not([hidden]) a');
+      const el = element.cursor.target.querySelector(':not([hidden]) a');
       const stub = sinon.stub(el, 'click');
       MockInteractions.pressAndReleaseKeyOn(element, 32); // Space
       assert.isTrue(stub.called);
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.ts b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.ts
index 1ecf3d5..096697f 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.ts
+++ b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.ts
@@ -16,16 +16,14 @@
  */
 import '@polymer/iron-autogrow-textarea/iron-autogrow-textarea';
 import '../../../styles/shared-styles';
-import '../gr-storage/gr-storage';
 import '../gr-button/gr-button';
-import {GrStorage} from '../gr-storage/gr-storage';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement, property} from '@polymer/decorators';
 import {htmlTemplate} from './gr-editable-content_html';
 import {fireAlert, fireEvent} from '../../../utils/event-util';
 import {appContext} from '../../../services/app-context';
 import {KnownExperimentId} from '../../../services/flags/flags';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 
 const RESTORED_MESSAGE = 'Content restored from a previous edit.';
 const STORAGE_DEBOUNCE_INTERVAL_MS = 400;
@@ -36,10 +34,8 @@
   }
 }
 
-const DEBOUNCER_STORE = 'store';
-
 @customElement('gr-editable-content')
-export class GrEditableContent extends LegacyElementMixin(PolymerElement) {
+export class GrEditableContent extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -113,12 +109,14 @@
   @property({type: Boolean})
   _isNewChangeSummaryUiEnabled = false;
 
-  private readonly storage = new GrStorage();
+  private readonly storage = appContext.storageService;
 
   private readonly flagsService = appContext.flagsService;
 
   private readonly reporting = appContext.reportingService;
 
+  private storeTask?: DelayedTask;
+
   /** @override */
   ready() {
     super.ready();
@@ -128,8 +126,9 @@
   }
 
   /** @override */
-  detached() {
-    this.cancelDebouncer(DEBOUNCER_STORE);
+  disconnectedCallback() {
+    this.storeTask?.cancel();
+    super.disconnectedCallback();
   }
 
   _contentChanged() {
@@ -148,8 +147,8 @@
     if (!this.storageKey) return;
     const storageKey = this.storageKey;
 
-    this.debounce(
-      DEBOUNCER_STORE,
+    this.storeTask = debounce(
+      this.storeTask,
       () => {
         if (newContent.length) {
           this.storage.setEditableContentItem(storageKey, newContent);
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content_test.js b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content_test.js
index b99b119..7977f4d 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content_test.js
@@ -126,7 +126,7 @@
 
       element._newContent = 'new content';
       flush();
-      element.flushDebouncer('store');
+      element.storeTask.flush();
 
       assert.isTrue(storeStub.called);
       assert.deepEqual(
@@ -135,7 +135,7 @@
 
       element._newContent = '';
       flush();
-      element.flushDebouncer('store');
+      element.storeTask.flush();
 
       assert.isTrue(eraseStub.called);
       assert.deepEqual([element.storageKey], eraseStub.lastCall.args);
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts
index c84828c..c758455 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts
+++ b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts
@@ -19,7 +19,6 @@
 import '../../../styles/shared-styles';
 import '../gr-button/gr-button';
 import '../../shared/gr-autocomplete/gr-autocomplete';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
 import {customElement, property} from '@polymer/decorators';
@@ -49,9 +48,7 @@
 }
 
 @customElement('gr-editable-label')
-export class GrEditableLabel extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrEditableLabel extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -158,7 +155,7 @@
   _awaitOpen(fn: () => void) {
     let iters = 0;
     const step = () => {
-      this.async(() => {
+      setTimeout(() => {
         if (this.$.dropdown.style.display !== 'none') {
           fn.call(this);
         } else if (iters++ < AWAIT_MAX_ITERS) {
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts
index d7b6df8..a227482 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts
@@ -73,8 +73,8 @@
       --iron-icon-height: 18px;
       --iron-icon-width: 18px;
     }
-    gr-button.new-change-summary-true {
-      --padding: 1px 4px;
+    gr-button.pencil {
+      --padding: 0px 0px;
     }
   </style>
   <template is="dom-if" if="[[!showAsEditPencil]]">
@@ -89,7 +89,7 @@
   <template is="dom-if" if="[[showAsEditPencil]]">
     <gr-button
       link=""
-      class$="new-change-summary-true [[_computeLabelClass(readOnly, value, placeholder)]]"
+      class$="pencil [[_computeLabelClass(readOnly, value, placeholder)]]"
       on-click="_showDropdown"
       title="[[_computeLabel(value, placeholder)]]"
       ><iron-icon icon="gr-icons:edit"></iron-icon
diff --git a/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts b/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts
index 0e9c0fa..cfa67fd 100644
--- a/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {htmlTemplate} from './gr-file-status-chip_html';
 import {customElement, property} from '@polymer/decorators';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
@@ -34,7 +33,7 @@
 };
 
 @customElement('gr-file-status-chip')
-export class GrFileStatusChip extends LegacyElementMixin(PolymerElement) {
+export class GrFileStatusChip extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
index 82ed264..17b659f 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-linked-text/gr-linked-text';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement, property} from '@polymer/decorators';
 import {htmlTemplate} from './gr-formatted-text_html';
@@ -44,7 +43,7 @@
 }
 
 @customElement('gr-formatted-text')
-export class GrFormattedText extends LegacyElementMixin(PolymerElement) {
+export class GrFormattedText extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts
index 9a2f966..7bff441 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts
@@ -20,7 +20,6 @@
 import '../gr-avatar/gr-avatar';
 import '../gr-button/gr-button';
 import {hovercardBehaviorMixin} from '../gr-hovercard/gr-hovercard-behavior';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-hovercard-account_html';
 import {appContext} from '../../../services/app-context';
@@ -47,9 +46,7 @@
 import {assertIsDefined} from '../../../utils/common-util';
 
 @customElement('gr-hovercard-account')
-export class GrHovercardAccount extends hovercardBehaviorMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrHovercardAccount extends hovercardBehaviorMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -95,8 +92,8 @@
     this.reporting = appContext.reportingService;
   }
 
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     this.restApiService.getConfig().then(config => {
       this._config = config;
     });
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
index b8f0161..7ad7223 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
@@ -16,19 +16,17 @@
  */
 import '../../../styles/shared-styles';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {Debouncer} from '@polymer/polymer/lib/utils/debounce';
-import {timeOut} from '@polymer/polymer/lib/utils/async';
 import {getRootElement} from '../../../scripts/rootElement';
 import {Constructor} from '../../../utils/common-util';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {dedupingMixin} from '@polymer/polymer/lib/utils/mixin';
 import {property, observe} from '@polymer/decorators';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {
   pushScrollLock,
   removeScrollLock,
 } from '@polymer/iron-overlay-behavior/iron-scroll-manager';
 import {ShowAlertEventDetail} from '../../../types/events';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 interface ReloadEventDetail {
   clearPatchset?: boolean;
 }
@@ -55,11 +53,8 @@
  *
  * @example
  *
- * // LegacyElementMixin is still needed to support the old lifecycles
- * // TODO: Replace old life cycles with new ones.
- *
  * class YourComponent extends hovercardBehaviorMixin(
- *  LegacyElementMixin(PolymerElement)
+ *  PolymerElement
  *
  * @see gr-hovercard.ts
  *
@@ -68,7 +63,7 @@
  * @mixinFunction
  */
 export const hovercardBehaviorMixin = dedupingMixin(
-  <T extends Constructor<PolymerElement & LegacyElementMixin>>(
+  <T extends Constructor<PolymerElement>>(
     superClass: T
   ): T & Constructor<GrHovercardBehaviorInterface> => {
     /**
@@ -77,7 +72,7 @@
      */
     class Mixin extends superClass {
       @property({type: Object})
-      _target: Element | null = null;
+      _target: HTMLElement | null = null;
 
       // Determines whether or not the hovercard is visible.
       @property({type: Boolean})
@@ -110,42 +105,42 @@
       @property({type: String})
       containerId = 'gr-hovercard-container';
 
-      private hideDebouncer: Debouncer | null = null;
+      private hideTask?: DelayedTask;
 
-      private showDebouncer: Debouncer | null = null;
+      private showTask?: DelayedTask;
 
       private isScheduledToShow?: boolean;
 
       private isScheduledToHide?: boolean;
 
       /** @override */
-      attached() {
-        super.attached();
+      connectedCallback() {
+        super.connectedCallback();
         if (!this._target) {
           this._target = this.target;
         }
-        this.listen(this._target, 'mouseenter', 'debounceShow');
-        this.listen(this._target, 'focus', 'debounceShow');
-        this.listen(this._target, 'mouseleave', 'debounceHide');
-        this.listen(this._target, 'blur', 'debounceHide');
+        this._target.addEventListener('mouseenter', this.debounceShow);
+        this._target.addEventListener('focus', this.debounceShow);
+        this._target.addEventListener('mouseleave', this.debounceHide);
+        this._target.addEventListener('blur', this.debounceHide);
 
         // when click, dismiss immediately
-        this.listen(this._target, 'click', 'hide');
+        this._target.addEventListener('click', this.hide);
 
         // show the hovercard if mouse moves to hovercard
         // this will cancel pending hide as well
-        this.listen(this, 'mouseenter', 'show');
-        this.listen(this, 'mouseenter', 'lock');
+        this.addEventListener('mouseenter', this.show);
+        this.addEventListener('mouseenter', this.lock);
         // when leave hovercard, hide it immediately
-        this.listen(this, 'mouseleave', 'hide');
-        this.listen(this, 'mouseleave', 'unlock');
+        this.addEventListener('mouseleave', this.hide);
+        this.addEventListener('mouseleave', this.unlock);
       }
 
-      detached() {
-        super.detached();
-        this.cancelShowDebouncer();
-        this.cancelHideDebouncer();
+      disconnectedCallback() {
+        this.cancelShowTask();
+        this.cancelHideTask();
         this.unlock();
+        super.disconnectedCallback();
       }
 
       /** @override */
@@ -165,32 +160,32 @@
       }
 
       removeListeners() {
-        this.unlisten(this._target, 'mouseenter', 'debounceShow');
-        this.unlisten(this._target, 'focus', 'debounceShow');
-        this.unlisten(this._target, 'mouseleave', 'debounceHide');
-        this.unlisten(this._target, 'blur', 'debounceHide');
-        this.unlisten(this._target, 'click', 'hide');
+        this._target?.removeEventListener('mouseenter', this.debounceShow);
+        this._target?.removeEventListener('focus', this.debounceShow);
+        this._target?.removeEventListener('mouseleave', this.debounceHide);
+        this._target?.removeEventListener('blur', this.debounceHide);
+        this._target?.removeEventListener('click', this.hide);
       }
 
-      debounceHide() {
-        this.cancelShowDebouncer();
+      readonly debounceHide = () => {
+        this.cancelShowTask();
         if (!this._isShowing || this.isScheduledToHide) return;
         this.isScheduledToHide = true;
-        this.hideDebouncer = Debouncer.debounce(
-          this.hideDebouncer,
-          timeOut.after(HIDE_DELAY_MS),
+        this.hideTask = debounce(
+          this.hideTask,
           () => {
             // This happens when hide immediately through click or mouse leave
             // on the hovercard
             if (!this.isScheduledToHide) return;
             this.hide();
-          }
+          },
+          HIDE_DELAY_MS
         );
-      }
+      };
 
-      cancelHideDebouncer() {
-        if (this.hideDebouncer) {
-          this.hideDebouncer.cancel();
+      cancelHideTask() {
+        if (this.hideTask) {
+          this.hideTask.cancel();
           this.isScheduledToHide = false;
         }
       }
@@ -228,7 +223,7 @@
        * Returns the target element that the hovercard is anchored to (the `id` of
        * the `for` property).
        */
-      get target(): Element {
+      get target(): HTMLElement {
         const parentNode = this.parentNode;
         // If the parentNode is a document fragment, then we need to use the host.
         const ownerRoot = this.getRootNode() as ShadowRoot;
@@ -241,15 +236,15 @@
               ? ownerRoot.host
               : parentNode;
         }
-        return target as Element;
+        return target as HTMLElement;
       }
 
       /**
        * unlock scroll, this will resume the scroll outside of the hovercard.
        */
-      unlock() {
+      readonly unlock = () => {
         removeScrollLock(this);
-      }
+      };
 
       /**
        * Hides/closes the hovercard. This occurs when the user triggers the
@@ -257,9 +252,9 @@
        * user is not hovering over the hovercard).
        *
        */
-      hide(e?: MouseEvent) {
-        this.cancelHideDebouncer();
-        this.cancelShowDebouncer();
+      readonly hide = (e?: MouseEvent) => {
+        this.cancelHideTask();
+        this.cancelShowTask();
         if (!this._isShowing) {
           return;
         }
@@ -291,36 +286,36 @@
         if (this.container?.contains(this)) {
           this.container.removeChild(this);
         }
-      }
+      };
 
       /**
        * Shows/opens the hovercard with a fixed delay.
        */
-      debounceShow() {
+      readonly debounceShow = () => {
         this.debounceShowBy(SHOW_DELAY_MS);
-      }
+      };
 
       /**
        * Shows/opens the hovercard with the given delay.
        */
       debounceShowBy(delayMs: number) {
-        this.cancelHideDebouncer();
+        this.cancelHideTask();
         if (this._isShowing || this.isScheduledToShow) return;
         this.isScheduledToShow = true;
-        this.showDebouncer = Debouncer.debounce(
-          this.showDebouncer,
-          timeOut.after(delayMs),
+        this.showTask = debounce(
+          this.showTask,
           () => {
             // This happens when the mouse leaves the target before the delay is over.
             if (!this.isScheduledToShow) return;
             this.show();
-          }
+          },
+          delayMs
         );
       }
 
-      cancelShowDebouncer() {
-        if (this.showDebouncer) {
-          this.showDebouncer.cancel();
+      cancelShowTask() {
+        if (this.showTask) {
+          this.showTask.cancel();
           this.isScheduledToShow = false;
         }
       }
@@ -328,17 +323,17 @@
       /**
        * Lock background scroll but enable scroll inside of current hovercard.
        */
-      lock() {
+      readonly lock = () => {
         pushScrollLock(this);
-      }
+      };
 
       /**
        * Shows/opens the hovercard. This occurs when the user triggers the
        * `mousenter` event on the hovercard's `target` element.
        */
-      show() {
-        this.cancelHideDebouncer();
-        this.cancelShowDebouncer();
+      readonly show = () => {
+        this.cancelHideTask();
+        this.cancelShowTask();
         if (this._isShowing || !this.container) {
           return;
         }
@@ -359,7 +354,7 @@
         flush();
         this.updatePosition();
         this.classList.remove(HIDE_CLASS);
-      }
+      };
 
       updatePosition() {
         const positionsToTry = new Set([
@@ -479,16 +474,15 @@
 );
 
 export interface GrHovercardBehaviorInterface {
-  attached(): void;
   ready(): void;
   removeListeners(): void;
   debounceHide(): void;
-  cancelHideDebouncer(): void;
+  cancelHideTask(): void;
   dispatchEventThroughTarget(eventName: string, detail?: unknown): void;
   hide(e?: MouseEvent): void;
   debounceShow(): void;
   debounceShowBy(delayMs: number): void;
-  cancelShowDebouncer(): void;
+  cancelShowTask(): void;
   show(): void;
   updatePosition(): void;
   updatePositionTo(position: string): void;
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.ts b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.ts
index a5f23ba..8857d36 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.ts
@@ -19,14 +19,11 @@
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-hovercard_html';
 import {hovercardBehaviorMixin} from './gr-hovercard-behavior';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import './gr-hovercard-shared-style';
 import {customElement} from '@polymer/decorators';
 
 @customElement('gr-hovercard')
-export class GrHovercard extends hovercardBehaviorMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrHovercard extends hovercardBehaviorMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
index 628b1e9..27ef23f 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
@@ -121,7 +121,7 @@
 
     await enterPromise;
     assert.isTrue(element.isScheduledToShow);
-    element.showDebouncer.flush();
+    element.showTask.flush();
     assert.isTrue(element._isShowing);
     assert.isFalse(element.isScheduledToShow);
 
@@ -130,7 +130,7 @@
     await leavePromise;
     assert.isTrue(element.isScheduledToHide);
     assert.isTrue(element._isShowing);
-    element.hideDebouncer.flush();
+    element.hideTask.flush();
     assert.isFalse(element.isScheduledToShow);
     assert.isFalse(element._isShowing);
 
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-context.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-context.ts
deleted file mode 100644
index 9f9ba6a..0000000
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-context.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {GrAnnotation} from '../../diff/gr-diff-highlight/gr-annotation';
-import {GrStyleObject} from '../../plugins/gr-styles-api/gr-styles-api';
-import {GrDiffLine} from '../../diff/gr-diff/gr-diff-line';
-import {appContext} from '../../../services/app-context';
-import {AnnotationContext} from '../../../api/annotation';
-
-/**
- * Used to create a context for GrAnnotationActionsInterface.
- *
- * @param contentEl The DIV.contentText element of the line
- * content to apply the annotation to using annotateRange.
- * @param lineNumberEl The TD element of the line number to
- * apply the annotation to using annotateLineNumber.
- * @param line The line object.
- * @param path The file path (eg: '/COMMIT_MSG').
- * @param changeNum The Gerrit change number.
- */
-export class GrAnnotationActionsContext implements AnnotationContext {
-  contentEl: HTMLElement;
-
-  lineNumberEl: HTMLElement;
-
-  line: GrDiffLine;
-
-  path: string;
-
-  changeNum: number;
-
-  private readonly reporting = appContext.reportingService;
-
-  constructor(
-    contentEl: HTMLElement,
-    lineNumberEl: HTMLElement,
-    line: GrDiffLine,
-    path: string,
-    changeNum: string | number
-  ) {
-    this.contentEl = contentEl;
-    this.lineNumberEl = lineNumberEl;
-    this.line = line;
-    this.path = path;
-    this.changeNum = Number(changeNum);
-    if (isNaN(this.changeNum)) {
-      this.reporting.error(
-        new Error(`GrAnnotationActionsContext: Invalid changeNum: ${changeNum}`)
-      );
-    }
-  }
-
-  /**
-   * Method to add annotations to a content line.
-   *
-   * @param offset The char offset where the update starts.
-   * @param length The number of chars that the update covers.
-   * @param styleObject The style object for the range.
-   * @param side The side of the update. ('left' or 'right')
-   */
-  annotateRange(
-    offset: number,
-    length: number,
-    styleObject: GrStyleObject,
-    side: string
-  ) {
-    if (this.contentEl?.getAttribute('data-side') === side) {
-      GrAnnotation.annotateElement(
-        this.contentEl,
-        offset,
-        length,
-        styleObject.getClassName(this.contentEl)
-      );
-    }
-  }
-
-  /**
-   * Method to add a CSS class to the line number TD element.
-   *
-   * @param styleObject The style object for the range.
-   * @param side The side of the update. ('left' or 'right')
-   */
-  annotateLineNumber(styleObject: GrStyleObject, side: string) {
-    if (this.lineNumberEl?.classList.contains(side)) {
-      styleObject.apply(this.lineNumberEl);
-    }
-  }
-}
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-context_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-context_test.js
deleted file mode 100644
index b46a3b0..0000000
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-context_test.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import './gr-js-api-interface.js';
-import {GrAnnotation} from '../../diff/gr-diff-highlight/gr-annotation.js';
-import {GrAnnotationActionsContext} from './gr-annotation-actions-context.js';
-import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
-
-const pluginApi = _testOnly_initGerritPluginApi();
-
-suite('gr-annotation-actions-context tests', () => {
-  let instance;
-
-  let el;
-  let lineNumberEl;
-  let plugin;
-
-  setup(() => {
-    pluginApi.install(p => { plugin = p; }, '0.1',
-        'http://test.com/plugins/testplugin/static/test.js');
-
-    const str = 'lorem ipsum blah blah';
-    const line = {text: str};
-    el = document.createElement('div');
-    el.textContent = str;
-    el.setAttribute('data-side', 'right');
-    lineNumberEl = document.createElement('td');
-    lineNumberEl.classList.add('right');
-    document.body.appendChild(el);
-    instance = new GrAnnotationActionsContext(
-        el, lineNumberEl, line, 'dummy/path', '123', '1');
-  });
-
-  teardown(() => {
-    el.remove();
-  });
-
-  test('test annotateRange', () => {
-    const annotateElementSpy = sinon.spy(GrAnnotation, 'annotateElement');
-    const start = 0;
-    const end = 100;
-    const cssStyleObject = plugin.styles().css('background-color: #000000');
-
-    // Assert annotateElement is not called when side is different.
-    instance.annotateRange(start, end, cssStyleObject, 'left');
-    assert.equal(annotateElementSpy.callCount, 0);
-
-    // Assert annotateElement is called once when side is the same.
-    instance.annotateRange(start, end, cssStyleObject, 'right');
-    assert.equal(annotateElementSpy.callCount, 1);
-    const args = annotateElementSpy.getCalls()[0].args;
-    assert.equal(args[0], el);
-    assert.equal(args[1], start);
-    assert.equal(args[2], end);
-    assert.equal(args[3], cssStyleObject.getClassName(el));
-  });
-
-  test('test annotateLineNumber', () => {
-    const cssStyleObject = plugin.styles().css('background-color: #000000');
-
-    const className = cssStyleObject.getClassName(lineNumberEl);
-
-    // Assert that css class is *not* applied when side is different.
-    instance.annotateLineNumber(cssStyleObject, 'left');
-    assert.isFalse(lineNumberEl.classList.contains(className));
-
-    // Assert that css class is applied when side is the same.
-    instance.annotateLineNumber(cssStyleObject, 'right');
-    assert.isTrue(lineNumberEl.classList.contains(className));
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.ts
index 857d079..3f75970 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.ts
@@ -14,17 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {GrAnnotationActionsContext} from './gr-annotation-actions-context';
-import {GrDiffLine} from '../../diff/gr-diff/gr-diff-line';
 import {DiffLayer, DiffLayerListener} from '../../../types/types';
 import {Side} from '../../../constants/constants';
 import {EventType, PluginApi} from '../../../api/plugin';
 import {appContext} from '../../../services/app-context';
-import {
-  AnnotationCallback,
-  AnnotationPluginApi,
-  CoverageProvider,
-} from '../../../api/annotation';
+import {AnnotationPluginApi, CoverageProvider} from '../../../api/annotation';
 
 export class GrAnnotationActionsInterface implements AnnotationPluginApi {
   /**
@@ -36,8 +30,6 @@
 
   private coverageProvider?: CoverageProvider;
 
-  private annotationCallback?: AnnotationCallback;
-
   private readonly reporting = appContext.reportingService;
 
   constructor(private readonly plugin: PluginApi) {
@@ -45,15 +37,6 @@
     plugin.on(EventType.ANNOTATE_DIFF, this);
   }
 
-  setLayer(annotationCallback: AnnotationCallback) {
-    this.reporting.trackApi(this.plugin, 'annotation', 'setLayer');
-    if (this.annotationCallback) {
-      console.warn('Overwriting an existing plugin annotation layer.');
-    }
-    this.annotationCallback = annotationCallback;
-    return this;
-  }
-
   setCoverageProvider(
     coverageProvider: CoverageProvider
   ): GrAnnotationActionsInterface {
@@ -73,40 +56,6 @@
     return this.coverageProvider;
   }
 
-  enableToggleCheckbox(
-    checkboxLabel: string,
-    onAttached: (checkboxEl: Element | null) => void
-  ) {
-    this.reporting.trackApi(this.plugin, 'annotation', 'enableToggleCheckbox');
-    this.plugin.hook('annotation-toggler').onAttached(element => {
-      if (!element.content) {
-        this.reporting.error(new Error('plugin endpoint without content.'));
-        return;
-      }
-      if (!element.content.hidden) {
-        this.reporting.error(
-          new Error(
-            `${element.content.id} is already enabled. Cannot re-enable.`
-          )
-        );
-        return;
-      }
-      element.content.removeAttribute('hidden');
-
-      const label = element.content.querySelector('#annotation-label');
-      if (label) {
-        if (checkboxLabel) {
-          label.textContent = checkboxLabel;
-        } else {
-          label.textContent = 'Enable';
-        }
-      }
-      const checkbox = element.content.querySelector('#annotation-checkbox');
-      onAttached(checkbox);
-    });
-    return this;
-  }
-
   notify(path: string, start: number, end: number, side: Side) {
     this.reporting.trackApi(this.plugin, 'annotation', 'notify');
     for (const annotationLayer of this.annotationLayers) {
@@ -124,9 +73,8 @@
    *
    * Don't forget to also call disposeLayer().
    */
-  createLayer(path: string, changeNum: number) {
-    const callbackFn = this.annotationCallback || (() => {});
-    const annotationLayer = new AnnotationLayer(path, changeNum, callbackFn);
+  createLayer(path: string) {
+    const annotationLayer = new AnnotationLayer(path);
     this.annotationLayers.push(annotationLayer);
     return annotationLayer;
   }
@@ -152,15 +100,8 @@
    * Used to create an instance of the Annotation Layer interface.
    *
    * @param path The file path (eg: /COMMIT_MSG').
-   * @param changeNum The Gerrit change number.
-   * @param annotationCallback The function
-   * that will be called when the AnnotationLayer is ready to annotate.
    */
-  constructor(
-    readonly path: string,
-    private readonly changeNum: number,
-    private readonly annotationCallback: AnnotationCallback
-  ) {
+  constructor(readonly path: string) {
     this.listeners = [];
   }
 
@@ -180,30 +121,7 @@
     this.listeners = this.listeners.filter(f => f !== listener);
   }
 
-  /**
-   * Called by Gerrit during diff rendering for each line. Delegates to the
-   * plugin provided callback for potentially annotating this line.
-   *
-   * @param contentEl The DIV.contentText element of the line
-   * content to apply the annotation to using annotateRange.
-   * @param lineNumberEl The TD element of the line number to
-   * apply the annotation to using annotateLineNumber.
-   * @param line The line object.
-   */
-  annotate(
-    contentEl: HTMLElement,
-    lineNumberEl: HTMLElement,
-    line: GrDiffLine
-  ) {
-    const context = new GrAnnotationActionsContext(
-      contentEl,
-      lineNumberEl,
-      line,
-      this.path,
-      this.changeNum
-    );
-    this.annotationCallback(context);
-  }
+  annotate() {}
 
   /**
    * Notify layer listeners (which typically is just Gerrit's diff renderer) of
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api_test.js
index 9811f99..996edf3 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api_test.js
@@ -18,16 +18,6 @@
 import '../../../test/common-test-setup-karma.js';
 import '../../change/gr-change-actions/gr-change-actions.js';
 import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-
-const basicFixture = fixtureFromTemplate(html`
-  <span hidden id="annotation-span">
-    <label for="annotation-checkbox" id="annotation-label"></label>
-    <iron-input type="checkbox" disabled>
-      <input is="iron-input" type="checkbox" id="annotation-checkbox" disabled>
-    </iron-input>
-  </span>
-`);
 
 const pluginApi = _testOnly_initGerritPluginApi();
 
@@ -46,33 +36,9 @@
     annotationActions = null;
   });
 
-  test('add/get layer', () => {
-    const str = 'lorem ipsum blah blah';
-    const line = {text: str};
-    const el = document.createElement('div');
-    el.textContent = str;
-    const changeNum = 1234;
-    let testLayerFuncCalled = false;
-
-    const testLayerFunc = context => {
-      testLayerFuncCalled = true;
-      assert.equal(context.line, line);
-      assert.equal(context.changeNum, changeNum);
-    };
-    annotationActions.setLayer(testLayerFunc);
-
-    const annotationLayer = annotationActions.createLayer(
-        '/dummy/path', changeNum);
-
-    const lineNumberEl = document.createElement('td');
-    annotationLayer.annotate(el, lineNumberEl, line);
-    assert.isTrue(testLayerFuncCalled);
-  });
-
   test('add notifier', () => {
     const path1 = '/dummy/path1';
     const path2 = '/dummy/path2';
-    annotationActions.setLayer(context => {});
     const annotationLayer1 = annotationActions.createLayer(path1, 1);
     const annotationLayer2 = annotationActions.createLayer(path2, 1);
     const layer1Spy = sinon.spy(annotationLayer1, 'notifyListeners');
@@ -98,44 +64,7 @@
     assert.isTrue(layer2Spy.called);
   });
 
-  test('toggle checkbox', () => {
-    const fakeEl = {content: basicFixture.instantiate()};
-    const hookStub = {onAttached: sinon.stub()};
-    sinon.stub(plugin, 'hook').returns(hookStub);
-
-    let checkbox;
-    let onAttachedFuncCalled = false;
-    const onAttachedFunc = c => {
-      checkbox = c;
-      onAttachedFuncCalled = true;
-    };
-    annotationActions.enableToggleCheckbox('test label', onAttachedFunc);
-    const emulateAttached = () => hookStub.onAttached.callArgWith(0, fakeEl);
-    emulateAttached();
-
-    // Assert that onAttachedFunc is called and HTML elements have the
-    // expected state.
-    assert.isTrue(onAttachedFuncCalled);
-    assert.equal(checkbox.id, 'annotation-checkbox');
-    assert.isTrue(checkbox.disabled);
-    assert.equal(document.getElementById('annotation-label').textContent,
-        'test label');
-    assert.isFalse(document.getElementById('annotation-span').hidden);
-
-    // Assert that error is shown if we try to enable checkbox again.
-    onAttachedFuncCalled = false;
-    annotationActions.enableToggleCheckbox('test label2', onAttachedFunc);
-    const errorStub = sinon.stub(annotationActions.reporting, 'error');
-    emulateAttached();
-    assert.isTrue(errorStub.called);
-    // Assert that onAttachedFunc is not called and the label has not changed.
-    assert.isFalse(onAttachedFuncCalled);
-    assert.equal(document.getElementById('annotation-label').textContent,
-        'test label');
-  });
-
   test('layer notify listeners', () => {
-    annotationActions.setLayer(context => {});
     const annotationLayer = annotationActions.createLayer('/dummy/path', 1);
     let listenerCalledTimes = 0;
     const startRange = 10;
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts
index 979b86e..db127f3 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts
@@ -59,9 +59,9 @@
   }
 
   // Pathname should normally look like this:
-  // /plugins/PLUGINNAME/static/SCRIPTNAME.html
+  // /plugins/PLUGINNAME/static/SCRIPTNAME.js
   // Or, for app/samples:
-  // /plugins/PLUGINNAME.html
+  // /plugins/PLUGINNAME.js
   // TODO(taoalpha): guard with a regex
   return pathname.split('/')[2].split('.')[0];
 }
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js
index 85c62cb..a09d887 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js
@@ -34,18 +34,18 @@
     test('with random invalid url', () => {
       assert.equal(getPluginNameFromUrl('http://example.com'), null);
       assert.equal(
-          getPluginNameFromUrl('http://example.com/static/a.html'),
+          getPluginNameFromUrl('http://example.com/static/a.js'),
           null
       );
     });
 
     test('with valid urls', () => {
       assert.equal(
-          getPluginNameFromUrl('http://example.com/plugins/a.html'),
+          getPluginNameFromUrl('http://example.com/plugins/a.js'),
           'a'
       );
       assert.equal(
-          getPluginNameFromUrl('http://example.com/plugins/a/static/t.html'),
+          getPluginNameFromUrl('http://example.com/plugins/a/static/t.js'),
           'a'
       );
     });
@@ -56,7 +56,7 @@
 
     test('with gerrit-theme override', () => {
       assert.equal(
-          getPluginNameFromUrl('http://example.com/static/gerrit-theme.html'),
+          getPluginNameFromUrl('http://example.com/static/gerrit-theme.js'),
           'gerrit-theme'
       );
     });
@@ -64,7 +64,7 @@
     test('with ASSETS_PATH', () => {
       window.ASSETS_PATH = 'http://cdn.com/2';
       assert.equal(
-          getPluginNameFromUrl(`${window.ASSETS_PATH}/plugins/a.html`),
+          getPluginNameFromUrl(`${window.ASSETS_PATH}/plugins/a.js`),
           'a'
       );
       window.ASSETS_PATH = undefined;
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.ts
index de57794..fc5a4aa 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api.ts
@@ -56,11 +56,6 @@
     this._el.setLabelValue(label, value);
   }
 
-  send(includeComments?: boolean) {
-    this.reporting.trackApi(this.plugin, 'reply', 'send');
-    this._el.send(includeComments);
-  }
-
   addReplyTextChangedCallback(handler: ReplyChangedCallback) {
     this.reporting.trackApi(this.plugin, 'reply', 'addReplyTextChangedCb');
     const hookApi = this.plugin.hook('reply-text');
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js
index d6d4ce5..2324588 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js
@@ -55,10 +55,6 @@
       assert.isTrue(
           element.setLabelValue.calledWithExactly('My-Label', '+1337'));
 
-      sinon.stub(element, 'send');
-      changeReply.send(false);
-      assert.isTrue(element.send.calledWithExactly(false));
-
       sinon.stub(element, 'setPluginMessage');
       changeReply.showMessage('foobar');
       assert.isTrue(element.setPluginMessage.calledWithExactly('foobar'));
@@ -86,10 +82,6 @@
       assert.isTrue(
           element.setLabelValue.calledWithExactly('My-Label', '+1337'));
 
-      sinon.stub(element, 'send');
-      changeReply.send(false);
-      assert.isTrue(element.send.calledWithExactly(false));
-
       sinon.stub(element, 'setPluginMessage');
       changeReply.showMessage('foobar');
       assert.isTrue(element.setPluginMessage.calledWithExactly('foobar'));
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
index 7f9218a..7afdd20 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
@@ -19,11 +19,7 @@
  * This defines the Gerrit instance. All methods directly attached to Gerrit
  * should be defined or linked here.
  */
-import {
-  getPluginLoader,
-  PluginOptionMap,
-  PluginLoader,
-} from './gr-plugin-loader';
+import {getPluginLoader, PluginOptionMap} from './gr-plugin-loader';
 import {send} from './gr-api-utils';
 import {appContext} from '../../../services/app-context';
 import {PluginApi} from '../../../api/plugin';
@@ -34,15 +30,8 @@
   EventEmitterService,
 } from '../../../services/gr-event-interface/gr-event-interface';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
-import {getRootElement} from '../../../scripts/rootElement';
-import {GrPluginEndpoints} from './gr-plugin-endpoints';
-import {rangesEqual} from '../../diff/gr-diff/gr-diff-utils';
-import {SUGGESTIONS_PROVIDERS_USERS_TYPES} from '../../../scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider';
-import {CoverageType} from '../../../types/types';
-import {RevisionInfo} from '../revision-info/revision-info';
 
 export interface GerritGlobal extends EventEmitterService {
-  flushPreinstalls?(): void;
   css(rule: string): string;
   install(
     callback: (plugin: PluginApi) => void,
@@ -75,31 +64,10 @@
   // exposed methods
   Nav: typeof GerritNav;
   Auth: typeof appContext.authService;
-  getRootElement: typeof getRootElement;
-  _pluginLoader: PluginLoader;
-  _endpoints: GrPluginEndpoints;
-  slotToContent(slot: unknown): unknown;
-  rangesEqual: typeof rangesEqual;
-  SUGGESTIONS_PROVIDERS_USERS_TYPES: typeof SUGGESTIONS_PROVIDERS_USERS_TYPES;
-  CoverageType: typeof CoverageType;
-  RevisionInfo: typeof RevisionInfo;
 }
 
-/**
- * Trigger the preinstalls for bundled plugins.
- * This needs to happen before Gerrit as plugin bundle overrides the Gerrit.
- */
-function flushPreinstalls() {
-  const Gerrit = window.Gerrit;
-  if (Gerrit?.flushPreinstalls) {
-    Gerrit.flushPreinstalls();
-  }
-}
-export const _testOnly_flushPreinstalls = flushPreinstalls;
-
 export function initGerritPluginApi() {
   window.Gerrit = window.Gerrit || {};
-  flushPreinstalls();
   initGerritPluginsMethods(window.Gerrit as GerritGlobal);
   // Preloaded plugins should be installed after Gerrit.install() is set,
   // since plugin preloader substitutes Gerrit.install() temporarily.
@@ -135,12 +103,17 @@
     });
 }
 
+const fakeApi = {
+  getPluginName: () => 'global',
+};
+
 function initGerritPluginsMethods(globalGerritObj: GerritGlobal) {
   /**
    * @deprecated Use plugin.styles().css(rulesStr) instead. Please, consult
    * the documentation how to replace it accordingly.
    */
   globalGerritObj.css = (rulesStr: string) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'css');
     console.warn(
       'Gerrit.css(rulesStr) is deprecated!',
       'Use plugin.styles().css(rulesStr)'
@@ -164,6 +137,7 @@
   };
 
   globalGerritObj.getLoggedIn = () => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'getLoggedIn');
     console.warn(
       'Gerrit.getLoggedIn() is deprecated! ' +
         'Use plugin.restApi().getLoggedIn()'
@@ -175,6 +149,7 @@
     url: string,
     callback?: (response: unknown) => void
   ) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'get');
     console.warn('.get() is deprecated! Use plugin.restApi().get()');
     send(HttpMethod.GET, url, callback);
   };
@@ -184,6 +159,7 @@
     payload?: RequestPayload,
     callback?: (response: unknown) => void
   ) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'post');
     console.warn('.post() is deprecated! Use plugin.restApi().post()');
     send(HttpMethod.POST, url, callback, payload);
   };
@@ -193,6 +169,7 @@
     payload?: RequestPayload,
     callback?: (response: unknown) => void
   ) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'put');
     console.warn('.put() is deprecated! Use plugin.restApi().put()');
     send(HttpMethod.PUT, url, callback, payload);
   };
@@ -201,32 +178,51 @@
     url: string,
     callback?: (response: Response) => void
   ) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'delete');
     deprecatedDelete(url, callback);
   };
 
   globalGerritObj.awaitPluginsLoaded = () => {
+    appContext.reportingService.trackApi(
+      fakeApi,
+      'global',
+      'awaitPluginsLoaded'
+    );
     return getPluginLoader().awaitPluginsLoaded();
   };
 
   // TODO(taoalpha): consider removing these proxy methods
   // and using getPluginLoader() directly
-  globalGerritObj._loadPlugins = (plugins, opt_option) => {
-    getPluginLoader().loadPlugins(plugins, opt_option);
+  globalGerritObj._loadPlugins = plugins => {
+    appContext.reportingService.trackApi(fakeApi, 'global', '_loadPlugins');
+    getPluginLoader().loadPlugins(plugins);
   };
 
   globalGerritObj._arePluginsLoaded = () => {
+    appContext.reportingService.trackApi(
+      fakeApi,
+      'global',
+      '_arePluginsLoaded'
+    );
     return getPluginLoader().arePluginsLoaded();
   };
 
   globalGerritObj._isPluginPreloaded = url => {
+    appContext.reportingService.trackApi(
+      fakeApi,
+      'global',
+      '_isPluginPreloaded'
+    );
     return getPluginLoader().isPluginPreloaded(url);
   };
 
   globalGerritObj._isPluginEnabled = pathOrUrl => {
+    appContext.reportingService.trackApi(fakeApi, 'global', '_isPluginEnabled');
     return getPluginLoader().isPluginEnabled(pathOrUrl);
   };
 
   globalGerritObj._isPluginLoaded = pathOrUrl => {
+    appContext.reportingService.trackApi(fakeApi, 'global', '_isPluginLoaded');
     return getPluginLoader().isPluginLoaded(pathOrUrl);
   };
 
@@ -257,22 +253,42 @@
    *   });
    * });
    */
-  globalGerritObj.addListener = (eventName: string, cb: EventCallback) =>
-    eventEmitter.addListener(eventName, cb);
+  globalGerritObj.addListener = (eventName: string, cb: EventCallback) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'addListener');
+    return eventEmitter.addListener(eventName, cb);
+  };
   // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  globalGerritObj.dispatch = (eventName: string, detail: any) =>
-    eventEmitter.dispatch(eventName, detail);
+  globalGerritObj.dispatch = (eventName: string, detail: any) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'dispatch');
+    return eventEmitter.dispatch(eventName, detail);
+  };
   // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  globalGerritObj.emit = (eventName: string, detail: any) =>
-    eventEmitter.emit(eventName, detail);
-  globalGerritObj.off = (eventName: string, cb: EventCallback) =>
-    eventEmitter.off(eventName, cb);
-  globalGerritObj.on = (eventName: string, cb: EventCallback) =>
-    eventEmitter.on(eventName, cb);
-  globalGerritObj.once = (eventName: string, cb: EventCallback) =>
-    eventEmitter.once(eventName, cb);
-  globalGerritObj.removeAllListeners = (eventName: string) =>
-    eventEmitter.removeAllListeners(eventName);
-  globalGerritObj.removeListener = (eventName: string, cb: EventCallback) =>
-    eventEmitter.removeListener(eventName, cb);
+  globalGerritObj.emit = (eventName: string, detail: any) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'emit');
+    return eventEmitter.emit(eventName, detail);
+  };
+  globalGerritObj.off = (eventName: string, cb: EventCallback) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'off');
+    return eventEmitter.off(eventName, cb);
+  };
+  globalGerritObj.on = (eventName: string, cb: EventCallback) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'on');
+    return eventEmitter.on(eventName, cb);
+  };
+  globalGerritObj.once = (eventName: string, cb: EventCallback) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'once');
+    return eventEmitter.once(eventName, cb);
+  };
+  globalGerritObj.removeAllListeners = (eventName: string) => {
+    appContext.reportingService.trackApi(
+      fakeApi,
+      'global',
+      'removeAllListeners'
+    );
+    return eventEmitter.removeAllListeners(eventName);
+  };
+  globalGerritObj.removeListener = (eventName: string, cb: EventCallback) => {
+    appContext.reportingService.trackApi(fakeApi, 'global', 'removeListener');
+    return eventEmitter.removeListener(eventName, cb);
+  };
 }
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface-element.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface-element.ts
index 8689ad2..95d2e7f 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface-element.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface-element.ts
@@ -247,12 +247,12 @@
     return revertSubmissionMsg;
   }
 
-  getDiffLayers(path: string, changeNum: number) {
+  getDiffLayers(path: string) {
     const layers: DiffLayer[] = [];
     for (const cb of this._getEventCallbacks(EventType.ANNOTATE_DIFF)) {
       const annotationApi = (cb as unknown) as GrAnnotationActionsInterface;
       try {
-        const layer = annotationApi.createLayer(path, changeNum);
+        const layer = annotationApi.createLayer(path);
         if (layer) layers.push(layer);
       } catch (err) {
         this.reporting.error(err);
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
index 12a4056..a9bb8ae 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
@@ -18,7 +18,6 @@
 import '../../../test/common-test-setup-karma.js';
 import './gr-js-api-interface.js';
 import {GrPopupInterface} from '../../plugins/gr-popup-interface/gr-popup-interface.js';
-import {GrSettingsApi} from '../../plugins/gr-settings-api/gr-settings-api.js';
 import {EventType} from '../../../api/plugin.js';
 import {PLUGIN_LOADING_TIMEOUT_MS} from './gr-api-utils.js';
 import {getPluginLoader} from './gr-plugin-loader.js';
@@ -35,7 +34,6 @@
   let plugin;
   let errorStub;
 
-  let getResponseObjectStub;
   let sendStub;
   let clock;
 
@@ -47,8 +45,6 @@
     clock = sinon.useFakeTimers();
 
     stubRestApi('getAccount').returns(Promise.resolve({name: 'Judy Hopps'}));
-    getResponseObjectStub = stubRestApi('getResponseObject').returns(
-        Promise.resolve());
     sendStub = stubRestApi('send').returns(Promise.resolve({status: 200}));
     element = appContext.jsApiService;
     errorStub = sinon.stub(element.reporting, 'error');
@@ -107,76 +103,6 @@
     });
   });
 
-  test('get', () => {
-    const response = {foo: 'foo'};
-    getResponseObjectStub.returns(Promise.resolve(response));
-    return plugin.get('/url', r => {
-      assert.isTrue(sendStub.calledWith(
-          'GET', 'http://test.com/plugins/testplugin/url'));
-      assert.strictEqual(r, response);
-    });
-  });
-
-  test('get using Promise', () => {
-    const response = {foo: 'foo'};
-    getResponseObjectStub.returns(Promise.resolve(response));
-    return plugin.get('/url', r => 'rubbish').then(r => {
-      assert.isTrue(sendStub.calledWith(
-          'GET', 'http://test.com/plugins/testplugin/url'));
-      assert.strictEqual(r, response);
-    });
-  });
-
-  test('post', () => {
-    const payload = {foo: 'foo'};
-    const response = {bar: 'bar'};
-    getResponseObjectStub.returns(Promise.resolve(response));
-    return plugin.post('/url', payload, r => {
-      assert.isTrue(sendStub.calledWith(
-          'POST', 'http://test.com/plugins/testplugin/url', payload));
-      assert.strictEqual(r, response);
-    });
-  });
-
-  test('put', () => {
-    const payload = {foo: 'foo'};
-    const response = {bar: 'bar'};
-    getResponseObjectStub.returns(Promise.resolve(response));
-    return plugin.put('/url', payload, r => {
-      assert.isTrue(sendStub.calledWith(
-          'PUT', 'http://test.com/plugins/testplugin/url', payload));
-      assert.strictEqual(r, response);
-    });
-  });
-
-  test('delete works', () => {
-    const response = {status: 204};
-    sendStub.returns(Promise.resolve(response));
-    return plugin.delete('/url', r => {
-      assert.equal(sendStub.lastCall.args[0], 'DELETE');
-      assert.equal(
-          sendStub.lastCall.args[1],
-          'http://test.com/plugins/testplugin/url'
-      );
-      assert.strictEqual(r, response);
-    });
-  });
-
-  test('delete fails', () => {
-    sendStub.returns(Promise.resolve(
-        {status: 400, text() { return Promise.resolve('text'); }}));
-    return plugin.delete('/url', r => {
-      throw new Error('Should not resolve');
-    }).catch(err => {
-      assert.equal(sendStub.lastCall.args[0], 'DELETE');
-      assert.equal(
-          sendStub.lastCall.args[1],
-          'http://test.com/plugins/testplugin/url'
-      );
-      assert.equal('text', err.message);
-    });
-  });
-
   test('history event', async () => {
     let resolve;
     const promise = new Promise(r => resolve = r);
@@ -236,7 +162,7 @@
       revisions: {def: {_number: 2}, abc: {_number: 1}},
     };
     const spy = sinon.spy();
-    getPluginLoader().loadPlugins(['plugins/test.html']);
+    getPluginLoader().loadPlugins(['plugins/test.js']);
     plugin.on(EventType.SHOW_CHANGE, spy);
     element.handleEvent(EventType.SHOW_CHANGE,
         {change: testChange, patchNum: 1});
@@ -453,12 +379,5 @@
           'testplugin-screen-foo', 'some-module'));
     });
   });
-
-  suite('settingsScreen', () => {
-    test('plugin.settings() returns GrSettingsApi', () => {
-      assert.isOk(plugin.settings());
-      assert.isTrue(plugin.settings() instanceof GrSettingsApi);
-    });
-  });
 });
 
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-types.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-types.ts
index 0b28c5e..9644ef3 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-types.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-types.ts
@@ -56,7 +56,7 @@
     origMsg: string
   ): string;
   addElement(key: TargetElement, el: HTMLElement): void;
-  getDiffLayers(path: string, changeNum: number): DiffLayer[];
+  getDiffLayers(path: string): DiffLayer[];
   disposeDiffLayers(path: string): void;
   getCoverageAnnotationApis(): Promise<GrAnnotationActionsInterface[]>;
   getAdminMenuLinks(): MenuLink[];
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
index 540d29e..0cc95a3 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
@@ -14,12 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-import {importHref} from '../../../scripts/import-href';
 import {PluginApi} from '../../../api/plugin';
 import {notUndefined} from '../../../types/types';
 import {HookApi} from '../../../api/hook';
-import {appContext} from '../../../services/app-context';
 
 // eslint-disable-next-line @typescript-eslint/no-explicit-any
 type Callback = (value: any) => void;
@@ -50,10 +47,6 @@
 
   private readonly _dynamicPlugins = new Map<string, Set<string>>();
 
-  private readonly _importedUrls = new Set<string>();
-
-  private readonly reporting = appContext.reportingService;
-
   private pluginLoaded = false;
 
   setPluginsReady() {
@@ -182,44 +175,6 @@
       notUndefined
     );
   }
-
-  importUrl(pluginUrl: URL) {
-    this.reporting.reportExecution('import-href-endpoints', {pluginUrl});
-    // eslint-disable-next-line @typescript-eslint/no-explicit-any
-    let timerId: any;
-    return Promise.race([
-      new Promise((resolve, reject) => {
-        this._importedUrls.add(pluginUrl.href);
-        importHref(pluginUrl.href, resolve, reject);
-      }),
-      // Timeout after 3s
-      new Promise(r => (timerId = setTimeout(r, 3000))),
-    ]).finally(() => {
-      if (timerId) clearTimeout(timerId);
-    });
-  }
-
-  /**
-   * Get plugin URLs with element and module definitions.
-   */
-  getAndImportPlugins(name: string, options?: Options) {
-    return Promise.all(
-      this.getPlugins(name, options).map(pluginUrl => {
-        if (this._importedUrls.has(pluginUrl.href)) {
-          return Promise.resolve();
-        }
-
-        // TODO: we will deprecate html plugins entirely
-        // for now, keep the original behavior and import
-        // only for html ones
-        if (pluginUrl?.pathname.endsWith('.html')) {
-          return this.importUrl(pluginUrl);
-        } else {
-          return Promise.resolve();
-        }
-      })
-    );
-  }
 }
 
 // TODO(dmfilippov): Convert to service and add to appContext
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js
index 5b931b4..e3475ad 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js
@@ -33,7 +33,7 @@
     domHook = {};
     instance = new GrPluginEndpoints();
     pluginApi.install(p => { pluginFoo = p; }, '0.1',
-        'http://test.com/plugins/testplugin/static/foo.html');
+        'http://test.com/plugins/testplugin/static/foo.js');
     instance.registerModule(
         pluginFoo,
         {
@@ -44,7 +44,7 @@
         }
     );
     pluginApi.install(p => { pluginBar = p; }, '0.1',
-        'http://test.com/plugins/testplugin/static/bar.html');
+        'http://test.com/plugins/testplugin/static/bar.js');
     instance.registerModule(
         pluginBar,
         {
@@ -54,7 +54,6 @@
           domHook,
         }
     );
-    sinon.spy(instance, 'importUrl');
   });
 
   teardown(() => {
@@ -120,14 +119,6 @@
         instance.getPlugins('a-place'), [pluginFoo._url]);
   });
 
-  test('getAndImportPlugins', () => {
-    instance.getAndImportPlugins('a-place');
-    assert.isTrue(instance.importUrl.called);
-    assert.isTrue(instance.importUrl.calledOnce);
-    instance.getAndImportPlugins('a-place');
-    assert.isTrue(instance.importUrl.calledOnce);
-  });
-
   test('onNewEndpoint', () => {
     const newModuleStub = sinon.stub();
     instance.setPluginsReady();
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
index e03b41c..85b6747 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import {appContext} from '../../../services/app-context';
-import {importHref} from '../../../scripts/import-href';
 import {
   PLUGIN_LOADING_TIMEOUT_MS,
   PRELOADED_PROTOCOL,
@@ -69,8 +68,8 @@
 
 // Prefix for any unrecognized plugin urls.
 // Url should match following patterns:
-// /plugins/PLUGINNAME/static/SCRIPTNAME.(html|js)
-// /plugins/PLUGINNAME.(js|html)
+// /plugins/PLUGINNAME/static/SCRIPTNAME.js
+// /plugins/PLUGINNAME.js
 const UNKNOWN_PLUGIN_PREFIX = '__$$__';
 
 // Current API version for Plugin,
@@ -116,7 +115,7 @@
   /**
    * Load multiple plugins with certain options.
    */
-  loadPlugins(plugins: string[] = [], opts: PluginOptionMap = {}) {
+  loadPlugins(plugins: string[] = []) {
     this._pluginListLoaded = true;
 
     plugins.forEach(path => {
@@ -134,9 +133,7 @@
         plugin: null,
       });
 
-      if (this._isPathEndsWith(url, '.html')) {
-        this._importHtmlPlugin(path, opts && opts[path]);
-      } else if (this._isPathEndsWith(url, '.js')) {
+      if (this._isPathEndsWith(url, '.js')) {
         this._loadJsPlugin(path);
       } else {
         this._failToLoad(`Unrecognized plugin path ${path}`, path);
@@ -336,28 +333,6 @@
       : false;
   }
 
-  _importHtmlPlugin(pluginUrl: string, opts: PluginOption = {}) {
-    const urlWithAP = this._urlFor(pluginUrl, window.ASSETS_PATH);
-    const urlWithoutAP = this._urlFor(pluginUrl);
-    let onerror = undefined;
-    this._getReporting().reportExecution('html-plugin', {pluginUrl});
-    if (urlWithAP !== urlWithoutAP) {
-      onerror = () => this._loadHtmlPlugin(urlWithoutAP, opts.sync);
-    }
-    this._loadHtmlPlugin(urlWithAP, opts.sync, onerror);
-  }
-
-  _loadHtmlPlugin(url: string, sync?: boolean, onerror?: (e: Event) => void) {
-    if (!onerror) {
-      onerror = () => {
-        this._failToLoad(`${url} import error`, url);
-      };
-    }
-
-    this._getReporting().reportExecution('import-href-loader', {url});
-    importHref(url, () => {}, onerror, !sync);
-  }
-
   _loadJsPlugin(pluginUrl: string) {
     const urlWithAP = this._urlFor(pluginUrl, window.ASSETS_PATH);
     const urlWithoutAP = this._urlFor(pluginUrl);
@@ -387,9 +362,7 @@
 
   _urlFor(pathOrUrl: string, assetsPath?: string): string {
     // theme is per host, should always load from assetsPath
-    const isThemeFile =
-      pathOrUrl.endsWith('static/gerrit-theme.html') ||
-      pathOrUrl.endsWith('static/gerrit-theme.js');
+    const isThemeFile = pathOrUrl.endsWith('static/gerrit-theme.js');
     const shouldTryLoadFromAssetsPathFirst = !isThemeFile && assetsPath;
     if (
       pathOrUrl.startsWith(PRELOADED_PROTOCOL) ||
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
index f5b1fca..1ca7e75 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
@@ -19,7 +19,6 @@
 import {PRELOADED_PROTOCOL, PLUGIN_LOADING_TIMEOUT_MS} from './gr-api-utils.js';
 import {_testOnly_resetPluginLoader} from './gr-plugin-loader.js';
 import {resetPlugins, stubBaseUrl} from '../../../test/test-utils.js';
-import {_testOnly_flushPreinstalls} from './gr-gerrit.js';
 import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
 import {addListenerForTest, stubRestApi} from '../../../test/test-utils.js';
 
@@ -57,16 +56,6 @@
     assert.strictEqual(plugin, otherPlugin);
   });
 
-  test('flushes preinstalls if provided', () => {
-    assert.doesNotThrow(() => {
-      _testOnly_flushPreinstalls();
-    });
-    window.Gerrit.flushPreinstalls = sinon.stub();
-    _testOnly_flushPreinstalls();
-    assert.isTrue(window.Gerrit.flushPreinstalls.calledOnce);
-    delete window.Gerrit.flushPreinstalls;
-  });
-
   test('versioning', () => {
     const callback = sinon.spy();
     pluginApi.install(callback, '0.0pre-alpha');
@@ -270,13 +259,8 @@
   });
 
   suite('plugin path and url', () => {
-    let importHtmlPluginStub;
     let loadJsPluginStub;
     setup(() => {
-      importHtmlPluginStub = sinon.stub();
-      sinon.stub(pluginLoader, '_loadHtmlPlugin').callsFake( url => {
-        importHtmlPluginStub(url);
-      });
       loadJsPluginStub = sinon.stub();
       sinon.stub(pluginLoader, '_createScriptTag').callsFake( url => {
         loadJsPluginStub(url);
@@ -303,13 +287,8 @@
     test('relative path for plugins', () => {
       pluginLoader.loadPlugins([
         'foo/bar.js',
-        'foo/bar.html',
       ]);
 
-      assert.isTrue(importHtmlPluginStub.calledOnce);
-      assert.isTrue(
-          importHtmlPluginStub.calledWithExactly(`${url}/foo/bar.html`)
-      );
       assert.isTrue(loadJsPluginStub.calledOnce);
       assert.isTrue(
           loadJsPluginStub.calledWithExactly(`${url}/foo/bar.js`)
@@ -322,17 +301,10 @@
 
       pluginLoader.loadPlugins([
         'foo/bar.js',
-        'foo/bar.html',
       ]);
 
-      assert.isTrue(importHtmlPluginStub.calledOnce);
       assert.isTrue(loadJsPluginStub.calledOnce);
       assert.isTrue(
-          importHtmlPluginStub.calledWithExactly(
-              `${url}${testUrl}/foo/bar.html`
-          )
-      );
-      assert.isTrue(
           loadJsPluginStub.calledWithExactly(`${url}${testUrl}/foo/bar.js`)
       );
     });
@@ -340,13 +312,8 @@
     test('absolute path for plugins', () => {
       pluginLoader.loadPlugins([
         'http://e.com/foo/bar.js',
-        'http://e.com/foo/bar.html',
       ]);
 
-      assert.isTrue(importHtmlPluginStub.calledOnce);
-      assert.isTrue(
-          importHtmlPluginStub.calledWithExactly(`http://e.com/foo/bar.html`)
-      );
       assert.isTrue(loadJsPluginStub.calledOnce);
       assert.isTrue(
           loadJsPluginStub.calledWithExactly(`http://e.com/foo/bar.js`)
@@ -355,14 +322,9 @@
   });
 
   suite('With ASSETS_PATH', () => {
-    let importHtmlPluginStub;
     let loadJsPluginStub;
     setup(() => {
       window.ASSETS_PATH = 'https://cdn.com';
-      importHtmlPluginStub = sinon.stub();
-      sinon.stub(pluginLoader, '_loadHtmlPlugin').callsFake( url => {
-        importHtmlPluginStub(url);
-      });
       loadJsPluginStub = sinon.stub();
       sinon.stub(pluginLoader, '_createScriptTag').callsFake( url => {
         loadJsPluginStub(url);
@@ -376,13 +338,8 @@
     test('Should try load plugins from assets path instead', () => {
       pluginLoader.loadPlugins([
         'foo/bar.js',
-        'foo/bar.html',
       ]);
 
-      assert.isTrue(importHtmlPluginStub.calledOnce);
-      assert.isTrue(
-          importHtmlPluginStub.calledWithExactly(`https://cdn.com/foo/bar.html`)
-      );
       assert.isTrue(loadJsPluginStub.calledOnce);
       assert.isTrue(
           loadJsPluginStub.calledWithExactly(`https://cdn.com/foo/bar.js`));
@@ -390,14 +347,9 @@
 
     test('Should honor original path if exists', () => {
       pluginLoader.loadPlugins([
-        'http://e.com/foo/bar.html',
         'http://e.com/foo/bar.js',
       ]);
 
-      assert.isTrue(importHtmlPluginStub.calledOnce);
-      assert.isTrue(
-          importHtmlPluginStub.calledWithExactly(`http://e.com/foo/bar.html`)
-      );
       assert.isTrue(loadJsPluginStub.calledOnce);
       assert.isTrue(
           loadJsPluginStub.calledWithExactly(`http://e.com/foo/bar.js`));
@@ -406,14 +358,9 @@
     test('Should try replace current host with assetsPath', () => {
       const host = window.location.origin;
       pluginLoader.loadPlugins([
-        `${host}/foo/bar.html`,
         `${host}/foo/bar.js`,
       ]);
 
-      assert.isTrue(importHtmlPluginStub.calledOnce);
-      assert.isTrue(
-          importHtmlPluginStub.calledWithExactly(`https://cdn.com/foo/bar.html`)
-      );
       assert.isTrue(loadJsPluginStub.calledOnce);
       assert.isTrue(
           loadJsPluginStub.calledWithExactly(`https://cdn.com/foo/bar.js`));
@@ -456,10 +403,6 @@
       window.Gerrit._preloadedPlugins = null;
     });
     test('skips preloaded plugins when load plugins', () => {
-      const importHtmlPluginStub = sinon.stub();
-      sinon.stub(pluginLoader, '_importHtmlPlugin').callsFake( url => {
-        importHtmlPluginStub(url);
-      });
       const loadJsPluginStub = sinon.stub();
       sinon.stub(pluginLoader, '_loadJsPlugin').callsFake( url => {
         loadJsPluginStub(url);
@@ -472,11 +415,9 @@
 
       pluginLoader.loadPlugins([
         'http://e.com/plugins/foo.js',
-        'plugins/bar.html',
         'http://e.com/plugins/test/foo.js',
       ]);
 
-      assert.isTrue(importHtmlPluginStub.notCalled);
       assert.isTrue(loadJsPluginStub.calledOnce);
     });
 
@@ -502,8 +443,8 @@
       let plugin;
       pluginApi.install(p => { plugin = p; }, '0.1', 'preloaded:foo');
       assert.strictEqual(plugin.getPluginName(), 'foo');
-      assert.strictEqual(plugin.url('/some/thing.html'),
-          `${window.location.origin}/plugins/foo/some/thing.html`);
+      assert.strictEqual(plugin.url('/some/thing.js'),
+          `${window.location.origin}/plugins/foo/some/thing.js`);
     });
   });
 });
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
index 68fb96b..6ff9a50 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
@@ -14,24 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 import {getBaseUrl} from '../../../utils/url-util';
 import {GrAttributeHelper} from '../../plugins/gr-attribute-helper/gr-attribute-helper';
 import {GrChangeActionsInterface} from './gr-change-actions-js-api';
 import {GrChangeReplyInterface} from './gr-change-reply-js-api';
 import {GrDomHooksManager} from '../../plugins/gr-dom-hooks/gr-dom-hooks';
-import {GrThemeApi} from '../../plugins/gr-theme-api/gr-theme-api';
 import {GrPopupInterface} from '../../plugins/gr-popup-interface/gr-popup-interface';
 import {GrAdminApi} from '../../plugins/gr-admin-api/gr-admin-api';
 import {GrAnnotationActionsInterface} from './gr-annotation-actions-js-api';
-import {GrChangeMetadataApi} from '../../plugins/gr-change-metadata-api/gr-change-metadata-api';
 import {GrEventHelper} from '../../plugins/gr-event-helper/gr-event-helper';
 import {GrPluginRestApi} from './gr-plugin-rest-api';
-import {GrRepoApi} from '../../plugins/gr-repo-api/gr-repo-api';
-import {GrSettingsApi} from '../../plugins/gr-settings-api/gr-settings-api';
-import {GrStylesApi} from '../../plugins/gr-styles-api/gr-styles-api';
 import {getPluginEndpoints} from './gr-plugin-endpoints';
-
 import {getPluginNameFromUrl, PRELOADED_PROTOCOL, send} from './gr-api-utils';
 import {GrReportingJsApi} from './gr-reporting-js-api';
 import {EventType, PluginApi, TargetElement} from '../../../api/plugin';
@@ -42,15 +35,10 @@
 import {appContext} from '../../../services/app-context';
 import {AdminPluginApi} from '../../../api/admin';
 import {AnnotationPluginApi} from '../../../api/annotation';
-import {StylesPluginApi} from '../../../api/styles';
-import {ThemePluginApi} from '../../../api/theme';
 import {EventHelperPluginApi} from '../../../api/event-helper';
 import {PopupPluginApi} from '../../../api/popup';
-import {SettingsPluginApi} from '../../../api/settings';
 import {ReportingPluginApi} from '../../../api/reporting';
 import {ChangeActionsPluginApi} from '../../../api/change-actions';
-import {ChangeMetadataPluginApi} from '../../../api/change-metadata';
-import {RepoPluginApi} from '../../../api/repo';
 import {ChangeReplyPluginApi} from '../../../api/change-reply';
 import {RestPluginApi} from '../../../api/rest';
 import {HookApi, RegisterOptions} from '../../../api/hook';
@@ -227,35 +215,6 @@
     return send(method, this.url(url), callback, payload);
   }
 
-  get(url: string, callback?: SendCallback) {
-    this.report.trackApi(this, 'plugin', 'get');
-    console.warn('.get() is deprecated! Use .restApi().get()');
-    return this._send(HttpMethod.GET, url, callback);
-  }
-
-  post(url: string, payload: RequestPayload, callback?: SendCallback) {
-    this.report.trackApi(this, 'plugin', 'post');
-    console.warn('.post() is deprecated! Use .restApi().post()');
-    return this._send(HttpMethod.POST, url, callback, payload);
-  }
-
-  put(url: string, payload: RequestPayload, callback?: SendCallback) {
-    this.report.trackApi(this, 'plugin', 'put');
-    console.warn('.put() is deprecated! Use .restApi().put()');
-    return this._send(HttpMethod.PUT, url, callback, payload);
-  }
-
-  delete(url: string, callback?: SendCallback) {
-    this.report.trackApi(this, 'plugin', 'delete');
-    console.warn('.delete() is deprecated! Use plugin.restApi().delete()');
-    return this.restApi()
-      .delete(this.url(url))
-      .then(res => {
-        if (callback) callback(res);
-        return res;
-      });
-  }
-
   annotationApi(): AnnotationPluginApi {
     return new GrAnnotationActionsInterface(this);
   }
@@ -281,30 +240,10 @@
     return new GrReportingJsApi(this);
   }
 
-  theme(): ThemePluginApi {
-    return new GrThemeApi(this);
-  }
-
-  project(): RepoPluginApi {
-    return new GrRepoApi(this);
-  }
-
-  changeMetadata(): ChangeMetadataPluginApi {
-    return new GrChangeMetadataApi(this);
-  }
-
   admin(): AdminPluginApi {
     return new GrAdminApi(this);
   }
 
-  settings(): SettingsPluginApi {
-    return new GrSettingsApi(this);
-  }
-
-  styles(): StylesPluginApi {
-    return new GrStylesApi(this);
-  }
-
   restApi(prefix?: string): RestPluginApi {
     return new GrPluginRestApi(this, prefix);
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts
index 8dc42fc..db22ce5 100644
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts
+++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts
@@ -22,7 +22,6 @@
 import '../gr-icons/gr-icons';
 import '../gr-label/gr-label';
 import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-label-info_html';
 import {GerritNav} from '../../core/gr-navigation/gr-navigation';
@@ -60,7 +59,7 @@
 }
 
 @customElement('gr-label-info')
-export class GrLabelInfo extends LegacyElementMixin(PolymerElement) {
+export class GrLabelInfo extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.js b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.js
index b2365aa..e8a38ec 100644
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.js
@@ -17,8 +17,7 @@
 
 import '../../../test/common-test-setup-karma.js';
 import './gr-label-info.js';
-import {isHidden} from '../../../test/test-utils.js';
-import {stubRestApi} from '../../../test/test-utils.js';
+import {isHidden, stubRestApi} from '../../../test/test-utils.js';
 
 const basicFixture = fixtureFromElement('gr-label-info');
 
diff --git a/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts b/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts
index d3c08f4..c13ca6e 100644
--- a/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts
+++ b/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts
@@ -21,7 +21,6 @@
  * used in gr-label-info.
  */
 
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement} from '@polymer/decorators';
 import {htmlTemplate} from './gr-label_html';
@@ -34,7 +33,7 @@
 }
 
 @customElement('gr-label')
-export class GrLabel extends TooltipMixin(LegacyElementMixin(PolymerElement)) {
+export class GrLabel extends TooltipMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.ts b/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.ts
index 84467ee..4be79e2 100644
--- a/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.ts
+++ b/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.ts
@@ -16,7 +16,6 @@
  */
 import '../gr-autocomplete/gr-autocomplete';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-labeled-autocomplete_html';
 import {customElement, property} from '@polymer/decorators';
@@ -31,7 +30,7 @@
   };
 }
 @customElement('gr-labeled-autocomplete')
-export class GrLabeledAutocomplete extends LegacyElementMixin(PolymerElement) {
+export class GrLabeledAutocomplete extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts
index 607f75d..f76f8d7 100644
--- a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts
+++ b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-limited-text_html';
 import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
@@ -33,9 +32,7 @@
  * and a tooltip containing the full text is enabled.
  */
 @customElement('gr-limited-text')
-export class GrLimitedText extends TooltipMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrLimitedText extends TooltipMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts
index 36a360b..615eac8 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts
@@ -19,7 +19,6 @@
 import '../gr-icons/gr-icons';
 import '../gr-limited-text/gr-limited-text';
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {customElement, property} from '@polymer/decorators';
 import {htmlTemplate} from './gr-linked-chip_html';
@@ -32,7 +31,7 @@
 }
 
 @customElement('gr-linked-chip')
-export class GrLinkedChip extends LegacyElementMixin(PolymerElement) {
+export class GrLinkedChip extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.ts b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.ts
index 44e740d..2812b47 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.ts
+++ b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-linked-text_html';
 import {GrLinkTextParser, LinkTextParserConfig} from './link-text-parser';
@@ -35,7 +34,7 @@
 }
 
 @customElement('gr-linked-text')
-export class GrLinkedText extends LegacyElementMixin(PolymerElement) {
+export class GrLinkedText extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
index f364c01..f586f48 100644
--- a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
+++ b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
@@ -18,13 +18,13 @@
 import '@polymer/iron-icon/iron-icon';
 import '../../../styles/shared-styles';
 import '../gr-button/gr-button';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-list-view_html';
 import {encodeURL, getBaseUrl} from '../../../utils/url-util';
 import {page} from '../../../utils/page-wrapper-utils';
 import {property, customElement} from '@polymer/decorators';
 import {fireEvent} from '../../../utils/event-util';
+import {debounce, DelayedTask} from '../../../utils/async-util';
 
 const REQUEST_DEBOUNCE_INTERVAL_MS = 200;
 
@@ -34,10 +34,8 @@
   }
 }
 
-const DEBOUNCER_RELOAD = 'reload';
-
 @customElement('gr-list-view')
-class GrListView extends LegacyElementMixin(PolymerElement) {
+class GrListView extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -63,10 +61,12 @@
   @property({type: String})
   path?: string;
 
+  private reloadTask?: DelayedTask;
+
   /** @override */
-  detached() {
-    super.detached();
-    this.cancelDebouncer(DEBOUNCER_RELOAD);
+  disconnectedCallback() {
+    this.reloadTask?.cancel();
+    super.disconnectedCallback();
   }
 
   _filterChanged(newFilter?: string, oldFilter?: string) {
@@ -79,8 +79,8 @@
   }
 
   _debounceReload(filter?: string) {
-    this.debounce(
-      DEBOUNCER_RELOAD,
+    this.reloadTask = debounce(
+      this.reloadTask,
       () => {
         if (this.path) {
           if (filter) {
diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
index 402263d9..100d5cc 100644
--- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
+++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-overlay_html';
 import {IronOverlayMixin} from '../../../mixins/iron-overlay-mixin/iron-overlay-mixin';
@@ -36,7 +35,7 @@
 
 @customElement('gr-overlay')
 export class GrOverlay extends IronOverlayMixin(
-  LegacyElementMixin(PolymerElement),
+  PolymerElement,
   IronOverlayBehavior as IronOverlayBehavior
 ) {
   static get template() {
@@ -78,13 +77,11 @@
     // once the type contains the exported member,
     // should replace with:
     // import {IronFocusablesHelper} from '@polymer/iron-overlay-behavior/iron-focusables-helper';
-    // eslint-disable-next-line @typescript-eslint/no-explicit-any
-    return (window.Polymer as any).IronFocusablesHelper.getTabbableNodes(this);
+    return window.Polymer.IronFocusablesHelper.getTabbableNodes(this);
   }
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('iron-overlay-closed', () => this._overlayClosed());
     this.addEventListener('iron-overlay-cancelled', () =>
       this._overlayClosed()
@@ -135,7 +132,7 @@
   _awaitOpen(fn: (this: GrOverlay) => void, reject: (error: Error) => void) {
     let iters = 0;
     const step = () => {
-      this.async(() => {
+      setTimeout(() => {
         if (this.style.display !== 'none') {
           fn.call(this);
         } else if (iters++ < AWAIT_MAX_ITERS) {
diff --git a/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts b/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts
index 57f38df..9a9dc03 100644
--- a/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts
+++ b/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-page-nav_html';
 import {customElement, property} from '@polymer/decorators';
@@ -33,7 +32,7 @@
 }
 
 @customElement('gr-page-nav')
-export class GrPageNav extends LegacyElementMixin(PolymerElement) {
+export class GrPageNav extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -48,14 +47,14 @@
     this.bodyScrollHandler = () => this._handleBodyScroll();
   }
 
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     window.addEventListener('scroll', this.bodyScrollHandler);
   }
 
-  detached() {
-    super.detached();
+  disconnectedCallback() {
     window.removeEventListener('scroll', this.bodyScrollHandler);
+    super.disconnectedCallback();
   }
 
   _handleBodyScroll() {
diff --git a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.ts b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.ts
index c49427a..31566a8 100644
--- a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.ts
+++ b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.ts
@@ -18,7 +18,6 @@
 import '../../../styles/shared-styles';
 import '../gr-icons/gr-icons';
 import '../gr-labeled-autocomplete/gr-labeled-autocomplete';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-repo-branch-picker_html';
 import {singleDecodeURL} from '../../../utils/url-util';
@@ -43,7 +42,7 @@
   };
 }
 @customElement('gr-repo-branch-picker')
-export class GrRepoBranchPicker extends LegacyElementMixin(PolymerElement) {
+export class GrRepoBranchPicker extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
@@ -72,8 +71,8 @@
   }
 
   /** @override */
-  attached() {
-    super.attached();
+  connectedCallback() {
+    super.connectedCallback();
     if (this.repo) {
       this.$.repoInput.setText(this.repo);
     }
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.js
index 4eef8a2f..3a5a587 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.js
@@ -16,8 +16,7 @@
  */
 
 import '../../../../test/common-test-setup-karma.js';
-import {SiteBasedCache} from './gr-rest-api-helper.js';
-import {FetchPromisesCache, GrRestApiHelper} from './gr-rest-api-helper.js';
+import {SiteBasedCache, FetchPromisesCache, GrRestApiHelper} from './gr-rest-api-helper.js';
 import {appContext} from '../../../../services/app-context.js';
 
 suite('gr-rest-api-helper tests', () => {
diff --git a/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts b/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts
index e08dab2..861381f 100644
--- a/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts
+++ b/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {html} from '@polymer/polymer/lib/utils/html-tag';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -29,7 +28,7 @@
  * GrSelect `gr-select` component.
  */
 @customElement('gr-select')
-export class GrSelect extends LegacyElementMixin(PolymerElement) {
+export class GrSelect extends PolymerElement {
   static get template() {
     return html` <slot></slot> `;
   }
@@ -54,7 +53,7 @@
       // Async needed for firefox to populate value. It was trying to do it
       // before options from a dom-repeat were rendered previously.
       // See https://bugs.chromium.org/p/gerrit/issues/detail?id=7735
-      this.async(() => {
+      setTimeout(() => {
         // TODO(TS): maybe should check for undefined before assigning
         // or fallback to ''
         this.nativeSelect.value = this.bindValue!;
@@ -70,9 +69,8 @@
     this.nativeSelect.focus();
   }
 
-  /** @override */
-  created() {
-    super.created();
+  constructor() {
+    super();
     this.addEventListener('change', () => this._valueChanged());
     this.addEventListener('dom-change', () => this._updateValue());
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.ts b/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.ts
index 133c6d5..a23cb1a 100644
--- a/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.ts
+++ b/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.ts
@@ -16,7 +16,6 @@
  */
 import '../../../styles/shared-styles';
 import '../gr-copy-clipboard/gr-copy-clipboard';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-shell-command_html';
 import {customElement, property} from '@polymer/decorators';
@@ -28,7 +27,7 @@
 }
 
 @customElement('gr-shell-command')
-class GrShellCommand extends LegacyElementMixin(PolymerElement) {
+class GrShellCommand extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
index 45e0b9a..bf10121 100644
--- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
+++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
@@ -21,7 +21,6 @@
 import '@polymer/iron-autogrow-textarea/iron-autogrow-textarea';
 import '../../../styles/shared-styles';
 import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-textarea_html';
 import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -76,13 +75,9 @@
     hiddenText: HTMLDivElement;
   };
 }
-/**
- * @extends PolymerElement
- */
+
 @customElement('gr-textarea')
-export class GrTextarea extends KeyboardShortcutMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrTextarea extends KeyboardShortcutMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
@@ -185,7 +180,7 @@
     // Put the cursor at the end always.
     textarea.selectionStart = textarea.value.length;
     textarea.selectionEnd = textarea.selectionStart;
-    this.async(() => {
+    setTimeout(() => {
       textarea.focus();
     });
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts
index ab3b5c5..feed8a6 100644
--- a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts
+++ b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../gr-icons/gr-icons';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-tooltip-content_html';
 import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
@@ -31,9 +30,7 @@
  * Transclude anything inside and wrap them to support tooltip functionality.
  */
 @customElement('gr-tooltip-content')
-export class GrTooltipContent extends TooltipMixin(
-  LegacyElementMixin(PolymerElement)
-) {
+export class GrTooltipContent extends TooltipMixin(PolymerElement) {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.ts b/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.ts
index 8652df0..cab05b4 100644
--- a/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 import '../../../styles/shared-styles';
-import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
 import {PolymerElement} from '@polymer/polymer/polymer-element';
 import {htmlTemplate} from './gr-tooltip_html';
 import {customElement, property, observe} from '@polymer/decorators';
@@ -31,7 +30,7 @@
 }
 
 @customElement('gr-tooltip')
-export class GrTooltip extends LegacyElementMixin(PolymerElement) {
+export class GrTooltip extends PolymerElement {
   static get template() {
     return htmlTemplate;
   }
diff --git a/polygerrit-ui/app/embed/gr-diff.ts b/polygerrit-ui/app/embed/gr-diff.ts
index 405d22e..6999ef8 100644
--- a/polygerrit-ui/app/embed/gr-diff.ts
+++ b/polygerrit-ui/app/embed/gr-diff.ts
@@ -25,16 +25,10 @@
 import '../elements/diff/gr-diff/gr-diff';
 import '../elements/diff/gr-diff-cursor/gr-diff-cursor';
 import {initDiffAppContext} from './gr-diff-app-context-init';
-import {
-  GrDiffLine,
-  GrDiffLineType,
-} from '../elements/diff/gr-diff/gr-diff-line';
 import {GrAnnotation} from '../elements/diff/gr-diff-highlight/gr-annotation';
 
 // Setup appContext for diff.
 // TODO (dmfilippov): find a better solution
 initDiffAppContext();
 // Setup global variables for existing usages of this component
-window.GrDiffLine = GrDiffLine;
-window.GrDiffLineType = GrDiffLineType;
 window.GrAnnotation = GrAnnotation;
diff --git a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts b/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
index 75ad608..e60c614 100644
--- a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
+++ b/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
@@ -88,7 +88,6 @@
 
       /** @override */
       disconnectedCallback() {
-        super.disconnectedCallback();
         // NOTE: if you define your own `detached` in your component
         // then this won't take affect (as its not a class yet)
         this._handleHideTooltip();
@@ -96,6 +95,7 @@
           this.removeEventListener('mouseenter', this.mouseenterHandler);
         }
         window.removeEventListener('scroll', this.windowScrollHandler);
+        super.disconnectedCallback();
       }
 
       @observe('hasTooltip')
diff --git a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
index ab85b87..85931b4 100644
--- a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
+++ b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
@@ -960,10 +960,10 @@
 
       /** @override */
       disconnectedCallback() {
-        super.disconnectedCallback();
         if (shortcutManager.detachHost(this)) {
           this.removeOwnKeyBindings();
         }
+        super.disconnectedCallback();
       }
 
       keyboardShortcuts() {
diff --git a/polygerrit-ui/app/scripts/bundled-polymer.ts b/polygerrit-ui/app/scripts/bundled-polymer.ts
index a52cc6b..75c99d5 100644
--- a/polygerrit-ui/app/scripts/bundled-polymer.ts
+++ b/polygerrit-ui/app/scripts/bundled-polymer.ts
@@ -26,8 +26,3 @@
 // of the polymer.html file.
 
 import './js/bundled-polymer-bridges';
-
-import {importHref} from './import-href';
-
-window.Polymer = window.Polymer || {};
-window.Polymer.importHref = importHref;
diff --git a/polygerrit-ui/app/scripts/import-href.ts b/polygerrit-ui/app/scripts/import-href.ts
deleted file mode 100644
index 3249c56..0000000
--- a/polygerrit-ui/app/scripts/import-href.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This file is a replacement for the
-// polymer-bridges/polymer/lib/utils/import-href.html file. The html
-// file contains code inside <script>...</script> and can't be imported
-// in es6 modules.
-
-interface ImportHrefElement extends HTMLLinkElement {
-  __dynamicImportLoaded?: boolean;
-}
-
-// run a callback when HTMLImports are ready or immediately if
-// this api is not available.
-function whenImportsReady(cb: () => void) {
-  const win = window as Window;
-  if (win.HTMLImports) {
-    win.HTMLImports.whenReady(cb);
-  } else {
-    cb();
-  }
-}
-
-/**
- * Convenience method for importing an HTML document imperatively.
- *
- * This method creates a new `<link rel="import">` element with
- * the provided URL and appends it to the document to start loading.
- * In the `onload` callback, the `import` property of the `link`
- * element will contain the imported document contents.
- *
- * @memberof Polymer
- * @param href URL to document to load.
- * @param onload Callback to notify when an import successfully
- *   loaded.
- * @param onerror Callback to notify when an import
- *   unsuccessfully loaded.
- * @param async True if the import should be loaded `async`.
- *   Defaults to `false`.
- * @return The link element for the URL to be loaded.
- */
-export function importHref(
-  href: string,
-  onload: (e: Event) => void,
-  onerror: (e: Event) => void,
-  async = false
-): HTMLLinkElement {
-  let link = document.head.querySelector(
-    'link[href="' + href + '"][import-href]'
-  ) as ImportHrefElement;
-  if (!link) {
-    link = document.createElement('link') as ImportHrefElement;
-    link.setAttribute('rel', 'import');
-    link.setAttribute('href', href);
-    link.setAttribute('import-href', '');
-  }
-  // always ensure link has `async` attribute if user specified one,
-  // even if it was previously not async. This is considered less confusing.
-  if (async) {
-    link.setAttribute('async', '');
-  }
-  // NOTE: the link may now be in 3 states: (1) pending insertion,
-  // (2) inflight, (3) already loaded. In each case, we need to add
-  // event listeners to process callbacks.
-  const cleanup = function () {
-    link.removeEventListener('load', loadListener);
-    link.removeEventListener('error', errorListener);
-  };
-  const loadListener = function (event: Event) {
-    cleanup();
-    // In case of a successful load, cache the load event on the link so
-    // that it can be used to short-circuit this method in the future when
-    // it is called with the same href param.
-    link.__dynamicImportLoaded = true;
-    if (onload) {
-      whenImportsReady(() => {
-        onload(event);
-      });
-    }
-  };
-  const errorListener = function (event: Event) {
-    cleanup();
-    // In case of an error, remove the link from the document so that it
-    // will be automatically created again the next time `importHref` is
-    // called.
-    if (link.parentNode) {
-      link.parentNode.removeChild(link);
-    }
-    if (onerror) {
-      whenImportsReady(() => {
-        onerror(event);
-      });
-    }
-  };
-  link.addEventListener('load', loadListener);
-  link.addEventListener('error', errorListener);
-  if (link.parentNode === null) {
-    document.head.appendChild(link);
-    // if the link already loaded, dispatch a fake load event
-    // so that listeners are called and get a proper event argument.
-  } else if (link.__dynamicImportLoaded) {
-    link.dispatchEvent(new Event('load'));
-  }
-  return link;
-}
diff --git a/polygerrit-ui/app/services/app-context-init.ts b/polygerrit-ui/app/services/app-context-init.ts
index 0369ccf..479ab88 100644
--- a/polygerrit-ui/app/services/app-context-init.ts
+++ b/polygerrit-ui/app/services/app-context-init.ts
@@ -23,6 +23,7 @@
 import {ChangeService} from './change/change-service';
 import {ChecksService} from './checks/checks-service';
 import {GrJsApiInterface} from '../elements/shared/gr-js-api-interface/gr-js-api-interface-element';
+import {GrStorageService} from './storage/gr-storage_impl';
 
 type ServiceName = keyof AppContext;
 type ServiceCreator<T> = () => T;
@@ -73,5 +74,6 @@
     changeService: () => new ChangeService(),
     checksService: () => new ChecksService(),
     jsApiService: () => new GrJsApiInterface(),
+    storageService: () => new GrStorageService(),
   });
 }
diff --git a/polygerrit-ui/app/services/app-context.ts b/polygerrit-ui/app/services/app-context.ts
index 1f618fd..cf186f0 100644
--- a/polygerrit-ui/app/services/app-context.ts
+++ b/polygerrit-ui/app/services/app-context.ts
@@ -22,6 +22,7 @@
 import {ChangeService} from './change/change-service';
 import {ChecksService} from './checks/checks-service';
 import {JsApiService} from '../elements/shared/gr-js-api-interface/gr-js-api-types';
+import {StorageService} from './storage/gr-storage';
 
 export interface AppContext {
   flagsService: FlagsService;
@@ -32,6 +33,7 @@
   changeService: ChangeService;
   checksService: ChecksService;
   jsApiService: JsApiService;
+  storageService: StorageService;
 }
 
 /**
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
index a017a7c..4f68311 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
@@ -18,7 +18,7 @@
 import {NumericChangeId} from '../../types/common';
 import {EventDetails} from '../../api/reporting';
 import {PluginApi} from '../../api/plugin';
-import {LifeCycle} from '../../constants/reporting';
+import {Execution, LifeCycle} from '../../constants/reporting';
 
 export type EventValue = string | number | {error?: Error};
 
@@ -94,12 +94,16 @@
    * Use this method, if you want to check/count how often a certain code path
    * is executed. For example you can use this method to prove that certain code
    * paths are dead: Add reportExecution(), check the logs a week later, then
-   * safely remove the coe.
+   * safely remove the code.
    *
    * Every execution is only reported once per session.
    */
-  reportExecution(id: string, details?: EventDetails): void;
-  trackApi(plugin: PluginApi, object: string, method: string): void;
+  reportExecution(id: Execution, details?: EventDetails): void;
+  trackApi(
+    plugin: Pick<PluginApi, 'getPluginName'>,
+    object: string,
+    method: string
+  ): void;
   reportInteraction(eventName: string, details?: EventDetails): void;
   /**
    * A draft interaction was started. Update the time-between-draft-actions
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
index 946966f..2bb4a1a 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
@@ -21,7 +21,7 @@
 import {NumericChangeId} from '../../types/common';
 import {EventDetails} from '../../api/reporting';
 import {PluginApi} from '../../api/plugin';
-import {LifeCycle} from '../../constants/reporting';
+import {Execution, LifeCycle} from '../../constants/reporting';
 
 // Latency reporting constants.
 
@@ -805,23 +805,27 @@
     );
   }
 
-  reportExecution(id: string, details?: EventDetails) {
+  reportExecution(name: Execution, details?: EventDetails) {
+    const id = `${name}${JSON.stringify(details)}`;
     if (this.executionReported.has(id)) return;
     this.executionReported.add(id);
     this.reporter(
       LIFECYCLE.TYPE,
       LIFECYCLE.CATEGORY.EXECUTION,
-      id,
+      name,
       undefined,
       details,
       true // skip console log
     );
   }
 
-  trackApi(pluginApi: PluginApi, object: string, method: string) {
+  trackApi(
+    pluginApi: Pick<PluginApi, 'getPluginName'>,
+    object: string,
+    method: string
+  ) {
     const plugin = pluginApi?.getPluginName() ?? 'unknown';
-    const id = `plugin-api-${plugin}-${object}-${method}`;
-    this.reportExecution(id, {plugin, object, method});
+    this.reportExecution(Execution.PLUGIN_API, {plugin, object, method});
   }
 
   /**
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
index 047bb4e..c4030c9 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
@@ -17,6 +17,7 @@
 import {ReportingService, Timer} from './gr-reporting';
 import {EventDetails} from '../../api/reporting';
 import {PluginApi} from '../../api/plugin';
+import {Execution} from '../../constants/reporting';
 
 export class MockTimer implements Timer {
   end(): this {
@@ -65,10 +66,11 @@
   error: () => {
     log('error');
   },
-  reportExecution: (id: string, details?: EventDetails) => {
+  reportExecution: (id: Execution, details?: EventDetails) => {
     log(`reportExecution '${id}': ${JSON.stringify(details)}`);
   },
-  trackApi: (plugin: PluginApi, object: string, method: string) => {
+  trackApi: (pluginApi: PluginApi, object: string, method: string) => {
+    const plugin = pluginApi?.getPluginName() ?? 'unknown';
     log(`trackApi '${plugin}', ${object}, ${method}`);
   },
   reportExtension: () => {},
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_test.js b/polygerrit-ui/app/services/gr-reporting/gr-reporting_test.js
index 2831db3..9b71908 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_test.js
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_test.js
@@ -341,6 +341,16 @@
     ));
   });
 
+  test('trackApi reports same event only once', () => {
+    sinon.spy(service, '_reportEvent');
+    const pluginApi = {getPluginName: () => 'test'};
+    service.trackApi(pluginApi, 'object', 'method');
+    service.trackApi(pluginApi, 'object', 'method');
+    assert.isTrue(service.reporter.calledOnce);
+    service.trackApi(pluginApi, 'object', 'method2');
+    assert.isTrue(service.reporter.calledTwice);
+  });
+
   test('report start time', () => {
     service.reporter.restore();
     sinon.stub(window.performance, 'now').returns(42);
diff --git a/polygerrit-ui/app/services/storage/gr-storage.ts b/polygerrit-ui/app/services/storage/gr-storage.ts
new file mode 100644
index 0000000..08a3387
--- /dev/null
+++ b/polygerrit-ui/app/services/storage/gr-storage.ts
@@ -0,0 +1,49 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {CommentRange, PatchSetNum} from '../../types/common';
+
+export interface StorageLocation {
+  changeNum: number;
+  patchNum: PatchSetNum | '@change';
+  path?: string;
+  line?: number;
+  range?: CommentRange;
+}
+
+export interface StorageObject {
+  message?: string;
+  updated: number;
+}
+
+export interface StorageService {
+  getDraftComment(location: StorageLocation): StorageObject | null;
+
+  setDraftComment(location: StorageLocation, message: string): void;
+
+  eraseDraftComment(location: StorageLocation): void;
+
+  getEditableContentItem(key: string): StorageObject | null;
+
+  setEditableContentItem(key: string, message: string): void;
+
+  getRespectfulTipVisibility(): StorageObject | null;
+
+  setRespectfulTipVisibility(delayDays?: number): void;
+
+  eraseEditableContentItem(key: string): void;
+}
diff --git a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.ts b/polygerrit-ui/app/services/storage/gr-storage_impl.ts
similarity index 72%
rename from polygerrit-ui/app/elements/shared/gr-storage/gr-storage.ts
rename to polygerrit-ui/app/services/storage/gr-storage_impl.ts
index a86d8f2..0c0d151 100644
--- a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.ts
+++ b/polygerrit-ui/app/services/storage/gr-storage_impl.ts
@@ -14,22 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {CommentRange, PatchSetNum} from '../../../types/common';
 
-export interface StorageLocation {
-  changeNum: number;
-  patchNum: PatchSetNum | '@change';
-  path?: string;
-  line?: number;
-  range?: CommentRange;
-}
+import {StorageLocation, StorageObject, StorageService} from './gr-storage';
 
-export interface StorageObject {
-  message?: string;
-  updated: number;
-}
-
-const DURATION_DAY = 24 * 60 * 60 * 1000;
+export const DURATION_DAY = 24 * 60 * 60 * 1000;
 
 // Clean up old entries no more frequently than one day.
 const CLEANUP_THROTTLE_INTERVAL = DURATION_DAY;
@@ -39,7 +27,7 @@
 CLEANUP_PREFIXES_MAX_AGE_MAP.set('draft', DURATION_DAY);
 CLEANUP_PREFIXES_MAX_AGE_MAP.set('editablecontent', DURATION_DAY);
 
-export class GrStorage {
+export class GrStorageService implements StorageService {
   private lastCleanup = 0;
 
   private readonly storage = window.localStorage;
@@ -47,49 +35,49 @@
   private exceededQuota = false;
 
   getDraftComment(location: StorageLocation): StorageObject | null {
-    this._cleanupItems();
-    return this._getObject(this._getDraftKey(location));
+    this.cleanupItems();
+    return this.getObject(this.getDraftKey(location));
   }
 
   setDraftComment(location: StorageLocation, message: string) {
-    const key = this._getDraftKey(location);
-    this._setObject(key, {message, updated: Date.now()});
+    const key = this.getDraftKey(location);
+    this.setObject(key, {message, updated: Date.now()});
   }
 
   eraseDraftComment(location: StorageLocation) {
-    const key = this._getDraftKey(location);
+    const key = this.getDraftKey(location);
     this.storage.removeItem(key);
   }
 
   getEditableContentItem(key: string): StorageObject | null {
-    this._cleanupItems();
-    return this._getObject(this._getEditableContentKey(key));
+    this.cleanupItems();
+    return this.getObject(this.getEditableContentKey(key));
   }
 
   setEditableContentItem(key: string, message: string) {
-    this._setObject(this._getEditableContentKey(key), {
+    this.setObject(this.getEditableContentKey(key), {
       message,
       updated: Date.now(),
     });
   }
 
   getRespectfulTipVisibility(): StorageObject | null {
-    this._cleanupItems();
-    return this._getObject('respectfultip:visibility');
+    this.cleanupItems();
+    return this.getObject('respectfultip:visibility');
   }
 
   setRespectfulTipVisibility(delayDays = 0) {
-    this._cleanupItems();
-    this._setObject('respectfultip:visibility', {
+    this.cleanupItems();
+    this.setObject('respectfultip:visibility', {
       updated: Date.now() + delayDays * DURATION_DAY,
     });
   }
 
   eraseEditableContentItem(key: string) {
-    this.storage.removeItem(this._getEditableContentKey(key));
+    this.storage.removeItem(this.getEditableContentKey(key));
   }
 
-  _getDraftKey(location: StorageLocation): string {
+  private getDraftKey(location: StorageLocation): string {
     const range = location.range
       ? `${location.range.start_line}-${location.range.start_character}` +
         `-${location.range.end_character}-${location.range.end_line}`
@@ -107,11 +95,11 @@
     return key;
   }
 
-  _getEditableContentKey(key: string): string {
+  private getEditableContentKey(key: string): string {
     return `editablecontent:${key}`;
   }
 
-  _cleanupItems() {
+  private cleanupItems() {
     // Throttle cleanup to the throttle interval.
     if (
       this.lastCleanup &&
@@ -125,7 +113,7 @@
       const entries = CLEANUP_PREFIXES_MAX_AGE_MAP.entries();
       for (const [prefix, expiration] of entries) {
         if (key.startsWith(prefix)) {
-          const item = this._getObject(key);
+          const item = this.getObject(key);
           if (!item || Date.now() - item.updated > expiration) {
             this.storage.removeItem(key);
           }
@@ -134,7 +122,7 @@
     });
   }
 
-  _getObject(key: string): StorageObject | null {
+  private getObject(key: string): StorageObject | null {
     const serial = this.storage.getItem(key);
     if (!serial) {
       return null;
@@ -142,7 +130,7 @@
     return JSON.parse(serial) as StorageObject;
   }
 
-  _setObject(key: string, obj: StorageObject) {
+  private setObject(key: string, obj: StorageObject) {
     if (this.exceededQuota) {
       return;
     }
diff --git a/polygerrit-ui/app/services/storage/gr-storage_mock.ts b/polygerrit-ui/app/services/storage/gr-storage_mock.ts
new file mode 100644
index 0000000..02215a8
--- /dev/null
+++ b/polygerrit-ui/app/services/storage/gr-storage_mock.ts
@@ -0,0 +1,91 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {StorageLocation, StorageObject, StorageService} from './gr-storage';
+import {DURATION_DAY} from './gr-storage_impl';
+
+const storage = new Map();
+
+const getDraftKey = (location: StorageLocation): string => {
+  const range = location.range
+    ? `${location.range.start_line}-${location.range.start_character}` +
+      `-${location.range.end_character}-${location.range.end_line}`
+    : null;
+  let key = [
+    'draft',
+    location.changeNum,
+    location.patchNum,
+    location.path,
+    location.line || '',
+  ].join(':');
+  if (range) {
+    key = key + ':' + range;
+  }
+  return key;
+};
+
+const getEditableContentKey = (key: string): string => {
+  return `editablecontent:${key}`;
+};
+
+export function cleanUpStorage() {
+  storage.clear();
+}
+
+export const grStorageMock: StorageService = {
+  getDraftComment(location: StorageLocation): StorageObject | null {
+    return storage.get(getDraftKey(location));
+  },
+
+  setDraftComment(location: StorageLocation, message: string) {
+    const key = getDraftKey(location);
+    storage.set(key, {message, updated: Date.now()});
+  },
+
+  eraseDraftComment(location: StorageLocation) {
+    const key = getDraftKey(location);
+    storage.delete(key);
+  },
+
+  getEditableContentItem(key: string): StorageObject | null {
+    return storage.get(getEditableContentKey(key));
+  },
+
+  setEditableContentItem(key: string, message: string): void {
+    storage.set(
+      getEditableContentKey(key),
+      JSON.stringify({
+        message,
+        updated: Date.now(),
+      })
+    );
+  },
+
+  getRespectfulTipVisibility(): StorageObject | null {
+    return storage.get('respectfultip:visibility');
+  },
+
+  setRespectfulTipVisibility(delayDays = 0): void {
+    storage.set('respectfultip:visibility', {
+      updated: Date.now() + delayDays * DURATION_DAY,
+    });
+  },
+
+  eraseEditableContentItem(key: string): void {
+    storage.delete(getEditableContentKey(key));
+  },
+};
diff --git a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage_test.js b/polygerrit-ui/app/services/storage/gr-storage_test.js
similarity index 87%
rename from polygerrit-ui/app/elements/shared/gr-storage/gr-storage_test.js
rename to polygerrit-ui/app/services/storage/gr-storage_test.js
index 64d3750..6cbfacf 100644
--- a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage_test.js
+++ b/polygerrit-ui/app/services/storage/gr-storage_test.js
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-import '../../../test/common-test-setup-karma.js';
-import {GrStorage} from './gr-storage.js';
+import '../../test/common-test-setup-karma.js';
+import {GrStorageService} from './gr-storage_impl.js';
 
 suite('gr-storage tests', () => {
   let grStorage;
@@ -34,7 +34,7 @@
   }
 
   setup(() => {
-    grStorage = new GrStorage();
+    grStorage = new GrStorageService();
     grStorage.storage = mockStorage();
   });
 
@@ -51,7 +51,7 @@
     };
 
     // The key is in the expected format.
-    const key = grStorage._getDraftKey(location);
+    const key = grStorage.getDraftKey(location);
     assert.equal(key, ['draft', changeNum, patchNum, path, line].join(':'));
 
     // There should be no draft initially.
@@ -82,12 +82,12 @@
       line,
     };
 
-    const key = grStorage._getDraftKey(location);
+    const key = grStorage.getDraftKey(location);
 
     // Make sure that the call to cleanup doesn't get throttled.
     grStorage.lastCleanup = 0;
 
-    const cleanupSpy = sinon.spy(grStorage, '_cleanupItems');
+    const cleanupSpy = sinon.spy(grStorage, 'cleanupItems');
 
     // Create a message with a timestamp that is a second behind the max age.
     grStorage.storage.setItem(key, JSON.stringify({
@@ -103,7 +103,7 @@
     assert.isNotOk(grStorage.storage.getItem(key));
   });
 
-  test('_getDraftKey', () => {
+  test('getDraftKey', () => {
     const changeNum = 1234;
     const patchNum = 5;
     const path = 'my_source_file.js';
@@ -115,7 +115,7 @@
       line,
     };
     let expectedResult = 'draft:1234:5:my_source_file.js:123';
-    assert.equal(grStorage._getDraftKey(location), expectedResult);
+    assert.equal(grStorage.getDraftKey(location), expectedResult);
     location.range = {
       start_character: 1,
       start_line: 1,
@@ -123,7 +123,7 @@
       end_line: 2,
     };
     expectedResult = 'draft:1234:5:my_source_file.js:123:1-1-1-2';
-    assert.equal(grStorage._getDraftKey(location), expectedResult);
+    assert.equal(grStorage.getDraftKey(location), expectedResult);
   });
 
   test('exceeded quota disables storage', () => {
@@ -140,16 +140,16 @@
       path,
       line,
     };
-    const key = grStorage._getDraftKey(location);
+    const key = grStorage.getDraftKey(location);
     grStorage.setDraftComment(location, 'my comment');
     assert.isTrue(grStorage.exceededQuota);
     assert.isNotOk(grStorage.storage.getItem(key));
   });
 
   test('editable content items', () => {
-    const cleanupStub = sinon.stub(grStorage, '_cleanupItems');
+    const cleanupStub = sinon.stub(grStorage, 'cleanupItems');
     const key = 'testKey';
-    const computedKey = grStorage._getEditableContentKey(key);
+    const computedKey = grStorage.getEditableContentKey(key);
     // Key correctly computed.
     assert.equal(computedKey, 'editablecontent:testKey');
 
diff --git a/polygerrit-ui/app/styles/themes/dark-theme_test.js b/polygerrit-ui/app/styles/themes/dark-theme_test.ts
similarity index 78%
rename from polygerrit-ui/app/styles/themes/dark-theme_test.js
rename to polygerrit-ui/app/styles/themes/dark-theme_test.ts
index 4f6466f..16e609e 100644
--- a/polygerrit-ui/app/styles/themes/dark-theme_test.js
+++ b/polygerrit-ui/app/styles/themes/dark-theme_test.ts
@@ -15,14 +15,14 @@
  * limitations under the License.
  */
 
-import '../../test/common-test-setup-karma.js';
-import {applyTheme, removeTheme} from './dark-theme.js';
+import '../../test/common-test-setup-karma';
+import {applyTheme, removeTheme} from './dark-theme';
 
-suite('dark-theme_test.js', () => {
+suite('dark-theme test', () => {
   test('apply and remove theme', () => {
     applyTheme();
     assert.equal(document.head.querySelectorAll('#dark-theme').length, 1);
     removeTheme();
-    assert.equal(document.head.querySelectorAll('#dark-theme').length, 0);
+    assert.isEmpty(document.head.querySelectorAll('#dark-theme'));
   });
 });
diff --git a/polygerrit-ui/app/test/common-test-setup.ts b/polygerrit-ui/app/test/common-test-setup.ts
index 4e1662c..641e4b3 100644
--- a/polygerrit-ui/app/test/common-test-setup.ts
+++ b/polygerrit-ui/app/test/common-test-setup.ts
@@ -32,9 +32,8 @@
   removeIronOverlayBackdropStyleEl,
   TestKeyboardShortcutBinder,
 } from './test-utils';
-import {flushDebouncers} from '@polymer/polymer/lib/utils/debounce';
 import {_testOnly_getShortcutManagerInstance} from '../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
-import sinon, {SinonSpy} from 'sinon/pkg/sinon-esm';
+import sinon from 'sinon/pkg/sinon-esm';
 import {safeTypesBridge} from '../utils/safe-types-util';
 import {_testOnly_initGerritPluginApi} from '../elements/shared/gr-js-api-interface/gr-gerrit';
 import {initGlobalVariables} from '../elements/gr-app-global-var-init';
@@ -43,6 +42,8 @@
   _testOnly_defaultResinReportHandler,
   installPolymerResin,
 } from '../scripts/polymer-resin-install';
+import {_testOnly_allTasks} from '../utils/async-util';
+import {cleanUpStorage} from '../services/storage/gr-storage_mock';
 
 declare global {
   interface Window {
@@ -126,22 +127,18 @@
 
 // For karma always set our implementation
 // (karma doesn't provide the stub method)
-function stubImpl<T extends keyof HTMLElementTagNameMap>(
-  tagName: T,
-  implementation: Partial<HTMLElementTagNameMap[T]>
-) {
+function stubImpl<
+  T extends keyof HTMLElementTagNameMap,
+  K extends keyof HTMLElementTagNameMap[T]
+>(tagName: T, method: K) {
   // This method is inspired by web-component-tester method
   const proto = document.createElement(tagName).constructor
     .prototype as HTMLElementTagNameMap[T];
-  const stubs: SinonSpy[] = [];
-  for (const [key, value] of Object.entries(implementation)) {
-    stubs.push(sinon.stub(proto, key).callsFake(value));
-  }
+  const stub = sinon.stub(proto, method);
   registerTestCleanup(() => {
-    stubs.forEach(stub => {
-      stub.restore();
-    });
+    stub.restore();
   });
+  return stub;
 }
 
 window.stub = stubImpl;
@@ -190,19 +187,21 @@
   }
 }
 
+function cancelAllTasks() {
+  for (const task of _testOnly_allTasks.values()) {
+    console.warn('ATTENTION! A task was still active at the end of the test!');
+    task.cancel();
+  }
+}
+
 teardown(() => {
   sinon.restore();
   cleanupTestUtils();
   TestKeyboardShortcutBinder.pop();
   checkGlobalSpace();
   removeIronOverlayBackdropStyleEl();
-  // Clean Polymer debouncer queue, so next tests will not be affected.
-  // WARNING! This will most likely not do what you expect. `flushDebouncers()`
-  // will only flush debouncers that were added using `enqueueDebouncer()`. So
-  // this will not affect "normal" debouncers that were added using
-  // `this.debounce()`. For those please be careful and cancel them using
-  // `this.cancelDebouncer()` in the `detached()` lifecycle hook.
-  flushDebouncers();
+  cancelAllTasks();
+  cleanUpStorage();
   const testTeardownTimestampMs = new Date().getTime();
   const elapsedMs = testTeardownTimestampMs - testSetupTimestampMs;
   if (elapsedMs > 1000) {
diff --git a/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts b/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts
index ea960f0..395c9f67 100644
--- a/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts
+++ b/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts
@@ -78,6 +78,7 @@
   createConfig,
   createPreferences,
   createServerInfo,
+  createSubmittedTogetherInfo,
 } from '../test-data-generators';
 import {
   createDefaultDiffPrefs,
@@ -253,7 +254,7 @@
     return Promise.resolve([]);
   },
   getChangesSubmittedTogether(): Promise<SubmittedTogetherInfo | undefined> {
-    throw new Error('getChangesSubmittedTogether() not implemented by mock.');
+    return Promise.resolve(createSubmittedTogetherInfo());
   },
   getChangesWithSameTopic(): Promise<ChangeInfo[] | undefined> {
     return Promise.resolve([]);
diff --git a/polygerrit-ui/app/test/test-app-context-init.ts b/polygerrit-ui/app/test/test-app-context-init.ts
index 57afd8a..d74a9c1 100644
--- a/polygerrit-ui/app/test/test-app-context-init.ts
+++ b/polygerrit-ui/app/test/test-app-context-init.ts
@@ -20,6 +20,7 @@
 import {grReportingMock} from '../services/gr-reporting/gr-reporting_mock';
 import {AppContext, appContext} from '../services/app-context';
 import {grRestApiMock} from './mocks/gr-rest-api_mock';
+import {grStorageMock} from '../services/storage/gr-storage_mock';
 
 export function _testOnlyInitAppContext() {
   initAppContext();
@@ -36,4 +37,5 @@
   }
   setMock('reportingService', grReportingMock);
   setMock('restApiService', grRestApiMock);
+  setMock('storageService', grStorageMock);
 }
diff --git a/polygerrit-ui/app/test/test-data-generators.ts b/polygerrit-ui/app/test/test-data-generators.ts
index d56e440..8dcf2f1 100644
--- a/polygerrit-ui/app/test/test-data-generators.ts
+++ b/polygerrit-ui/app/test/test-data-generators.ts
@@ -62,6 +62,8 @@
   RequirementType,
   UrlEncodedCommentId,
   BasePatchSetNum,
+  RelatedChangeAndCommitInfo,
+  SubmittedTogetherInfo,
 } from '../types/common';
 import {
   AccountsVisibility,
@@ -90,6 +92,7 @@
 import {GerritView} from '../services/router/router-model';
 import {ChangeComments} from '../elements/diff/gr-comment-api/gr-comment-api';
 import {EditRevisionInfo, ParsedChangeInfo} from '../types/types';
+import {ChangeMessage} from '../elements/change/gr-message/gr-message';
 
 export function dateToTimestamp(date: Date): Timestamp {
   const nanosecondSuffix = '.000000000';
@@ -201,10 +204,12 @@
   };
 }
 
-export function createCommitInfoWithRequiredCommit(): CommitInfoWithRequiredCommit {
+export function createCommitInfoWithRequiredCommit(
+  commit = 'commit'
+): CommitInfoWithRequiredCommit {
   return {
     ...createCommit(),
-    commit: 'commit' as CommitId,
+    commit: commit as CommitId,
   };
 }
 
@@ -227,7 +232,7 @@
   };
 }
 
-export function createChangeMessage(id = 'cm_id_1'): ChangeMessageInfo {
+export function createChangeMessageInfo(id = 'cm_id_1'): ChangeMessageInfo {
   return {
     id: id as ChangeMessageId,
     date: dateToTimestamp(TEST_CHANGE_CREATED),
@@ -235,6 +240,15 @@
   };
 }
 
+export function createChangeMessage(id = 'cm_id_1'): ChangeMessage {
+  return {
+    ...createChangeMessageInfo(id),
+    type: '',
+    expanded: false,
+    commentThreads: [],
+  };
+}
+
 export function createRevisions(
   count: number
 ): {[revisionId: string]: RevisionInfo} {
@@ -266,7 +280,7 @@
   const messageDate = TEST_CHANGE_CREATED;
   for (let i = 0; i < count; i++) {
     messages.push({
-      ...createChangeMessage((i + messageIdStart).toString(16)),
+      ...createChangeMessageInfo((i + messageIdStart).toString(16)),
       date: dateToTimestamp(messageDate),
     });
     messageDate.setDate(messageDate.getDate() + 1);
@@ -359,7 +373,6 @@
   return {
     has_avatars: false,
     js_resource_paths: [],
-    html_resource_paths: [],
   };
 }
 
@@ -580,3 +593,17 @@
   const threads = createCommentThreads(comments);
   return threads[0];
 }
+
+export function createRelatedChangeAndCommitInfo(): RelatedChangeAndCommitInfo {
+  return {
+    project: TEST_PROJECT_NAME,
+    commit: createCommitInfoWithRequiredCommit(),
+  };
+}
+
+export function createSubmittedTogetherInfo(): SubmittedTogetherInfo {
+  return {
+    changes: [],
+    non_visible_changes: 0,
+  };
+}
diff --git a/polygerrit-ui/app/test/test-utils.ts b/polygerrit-ui/app/test/test-utils.ts
index 50f465f..26b99ac 100644
--- a/polygerrit-ui/app/test/test-utils.ts
+++ b/polygerrit-ui/app/test/test-utils.ts
@@ -24,6 +24,7 @@
 import {appContext} from '../services/app-context';
 import {RestApiService} from '../services/gr-rest-api/gr-rest-api';
 import {SinonSpy} from 'sinon/pkg/sinon-esm';
+import {StorageService} from '../services/storage/gr-storage';
 
 export interface MockPromise extends Promise<unknown> {
   resolve: (value?: unknown) => void;
@@ -165,6 +166,10 @@
   return sinon.spy(appContext.restApiService, method);
 }
 
+export function stubStorage<K extends keyof StorageService>(method: K) {
+  return sinon.stub(appContext.storageService, method);
+}
+
 export type SinonSpyMember<F extends (...args: any) => any> = SinonSpy<
   Parameters<F>,
   ReturnType<F>
diff --git a/polygerrit-ui/app/types/common.ts b/polygerrit-ui/app/types/common.ts
index 0649002..3183510 100644
--- a/polygerrit-ui/app/types/common.ts
+++ b/polygerrit-ui/app/types/common.ts
@@ -77,9 +77,10 @@
 
 export type PatchSetNum = BrandType<'PARENT' | 'edit' | number, '_patchSet'>;
 export type BasePatchSetNum = BrandType<'PARENT' | number, '_patchSet'>;
+export type RevisionPatchSetNum = BrandType<'edit' | number, '_patchSet'>;
 export type PatchSetNumber = BrandType<number, '_patchSet'>;
 
-export const EditPatchSetNum = 'edit' as PatchSetNum;
+export const EditPatchSetNum = 'edit' as RevisionPatchSetNum;
 // TODO(TS): This is not correct, it is better to have a separate ApiPatchSetNum
 // without 'parent'.
 export const ParentPatchSetNum = 'PARENT' as BasePatchSetNum;
@@ -1023,9 +1024,8 @@
  */
 export interface PluginConfigInfo {
   has_avatars: boolean;
-  // The following 2 properties exists in Java class, but don't mention in docs
+  // Exists in Java class, but not mentioned in docs.
   js_resource_paths: string[];
-  html_resource_paths: string[];
 }
 
 /**
@@ -1621,7 +1621,7 @@
  * doesn't exist in Rest API
  */
 export interface PatchRange {
-  patchNum: PatchSetNum;
+  patchNum: RevisionPatchSetNum;
   basePatchNum: BasePatchSetNum;
 }
 
diff --git a/polygerrit-ui/app/types/events.ts b/polygerrit-ui/app/types/events.ts
index 5965453..11155c1 100644
--- a/polygerrit-ui/app/types/events.ts
+++ b/polygerrit-ui/app/types/events.ts
@@ -20,68 +20,86 @@
 import {FetchRequest} from './types';
 import {MovedLinkClickedEventDetail} from '../api/diff';
 import {Category, RunStatus} from '../api/checks';
+import {ChangeMessage} from '../elements/change/gr-message/gr-message';
 
-export interface TitleChangeEventDetail {
-  title: string;
+export enum EventType {
+  CHANGE_MESSAGE_DELETED = 'change-message-deleted',
+  DIALOG_CHANGE = 'dialog-change',
+  EDITABLE_CONTENT_SAVE = 'editable-content-save',
+  GR_RPC_LOG = 'gr-rpc-log',
+  LOCATION_CHANGE = 'location-change',
+  IRON_ANNOUNCE = 'iron-announce',
+  MOVED_LINK_CLICKED = 'moved-link-clicked',
+  NETWORK_ERROR = 'network-error',
+  OPEN_FIX_PREVIEW = 'open-fix-preview',
+  PAGE_ERROR = 'page-error',
+  RELOAD = 'reload',
+  REPLY = 'reply',
+  SERVER_ERROR = 'server-error',
+  SHORTCUT_TRIGGERERD = 'shortcut-triggered',
+  SHOW_ALERT = 'show-alert',
+  SHOW_ERROR = 'show-error',
+  SHOW_PRIMARY_TAB = 'show-primary-tab',
+  SHOW_SECONDARY_TAB = 'show-secondary-tab',
+  THREAD_LIST_MODIFIED = 'thread-list-modified',
+  TITLE_CHANGE = 'title-change',
 }
 
-export type TitleChangeEvent = CustomEvent<TitleChangeEventDetail>;
-
 declare global {
   interface HTMLElementEventMap {
+    'change-message-deleted': ChangeMessageDeletedEvent;
+    'dialog-change': DialogChangeEvent;
+    'editable-content-save': EditableContentSaveEvent;
+    'location-change': LocationChangeEvent;
+    'iron-announce': IronAnnounceEvent;
+    'moved-link-clicked': MovedLinkClickedEvent;
+    'open-fix-preview': OpenFixPreviewEvent;
+    /* prettier-ignore */
+    'reload': ReloadEvent;
+    /* prettier-ignore */
+    'reply': ReplyEvent;
+    'shortcut-triggered': ShortcutTriggeredEvent;
+    'show-alert': ShowAlertEvent;
+    'show-error': ShowErrorEvent;
+    'show-primary-tab': SwitchTabEvent;
+    'show-secondary-tab': SwitchTabEvent;
+    'thread-list-modified': ThreadListModifiedEvent;
     'title-change': TitleChangeEvent;
   }
 }
 
-export interface PageErrorEventDetail {
-  response: Response;
-}
-
-export type PageErrorEvent = CustomEvent<PageErrorEventDetail>;
-
 declare global {
   interface DocumentEventMap {
-    'page-error': PageErrorEvent;
-  }
-}
-
-export interface ServerErrorEventDetail {
-  request?: FetchRequest;
-  response: Response;
-}
-
-export type ServerErrorEvent = CustomEvent<ServerErrorEventDetail>;
-
-declare global {
-  interface DocumentEventMap {
-    'server-error': ServerErrorEvent;
-  }
-}
-
-export interface NetworkErrorEventDetail {
-  error: Error;
-}
-
-export type NetworkErrorEvent = CustomEvent<NetworkErrorEventDetail>;
-
-declare global {
-  interface DocumentEventMap {
+    'gr-rpc-log': RpcLogEvent;
     'network-error': NetworkErrorEvent;
+    'page-error': PageErrorEvent;
+    'server-error': ServerErrorEvent;
+    'show-alert': ShowAlertEvent;
+    'show-error': ShowErrorEvent;
   }
 }
 
-export interface LocationChangeEventDetail {
-  hash: string;
-  pathname: string;
+export interface ChangeMessageDeletedEventDetail {
+  message: ChangeMessage;
 }
+export type ChangeMessageDeletedEvent = CustomEvent<
+  ChangeMessageDeletedEventDetail
+>;
 
-export type LocationChangeEvent = CustomEvent<LocationChangeEventDetail>;
-
-declare global {
-  interface HTMLElementEventMap {
-    'location-change': LocationChangeEvent;
-  }
+// TODO(milutin) - remove once new gr-dialog will do it out of the box
+// This informs gr-app-element to remove footer, header from a11y tree
+export interface DialogChangeEventDetail {
+  canceled?: boolean;
+  opened?: boolean;
 }
+export type DialogChangeEvent = CustomEvent<DialogChangeEventDetail>;
+
+export interface EditableContentSaveEventDetail {
+  content: string;
+}
+export type EditableContentSaveEvent = CustomEvent<
+  EditableContentSaveEventDetail
+>;
 
 export interface RpcLogEventDetail {
   status: number | null;
@@ -89,58 +107,76 @@
   elapsed: number;
   anonymizedUrl: string;
 }
-
 export type RpcLogEvent = CustomEvent<RpcLogEventDetail>;
 
-declare global {
-  interface DocumentEventMap {
-    'gr-rpc-log': RpcLogEvent;
-  }
+export interface IronAnnounceEventDetail {
+  text: string;
 }
+export type IronAnnounceEvent = CustomEvent<IronAnnounceEventDetail>;
+
+export interface LocationChangeEventDetail {
+  hash: string;
+  pathname: string;
+}
+export type LocationChangeEvent = CustomEvent<LocationChangeEventDetail>;
+
+export type MovedLinkClickedEvent = CustomEvent<MovedLinkClickedEventDetail>;
+
+export interface NetworkErrorEventDetail {
+  error: Error;
+}
+export type NetworkErrorEvent = CustomEvent<NetworkErrorEventDetail>;
+
+export interface OpenFixPreviewEventDetail {
+  patchNum?: PatchSetNum;
+  comment?: UIComment;
+}
+export type OpenFixPreviewEvent = CustomEvent<OpenFixPreviewEventDetail>;
+
+export interface PageErrorEventDetail {
+  response?: Response;
+}
+export type PageErrorEvent = CustomEvent<PageErrorEventDetail>;
+
+export interface ReloadEventDetail {
+  clearPatchset: boolean;
+}
+export type ReloadEvent = CustomEvent<ReloadEventDetail>;
+
+export interface ReplyEventDetail {
+  message: ChangeMessage;
+}
+export type ReplyEvent = CustomEvent<ReplyEventDetail>;
+
+export interface ServerErrorEventDetail {
+  request?: FetchRequest;
+  response: Response;
+}
+export type ServerErrorEvent = CustomEvent<ServerErrorEventDetail>;
 
 export interface ShortcutTriggeredEventDetail {
   event: CustomKeyboardEvent;
   goKey: boolean;
   vKey: boolean;
 }
-
 export type ShortcutTriggeredEvent = CustomEvent<ShortcutTriggeredEventDetail>;
 
-declare global {
-  interface HTMLElementEventMap {
-    'shortcut-triggered': ShortcutTriggeredEvent;
-  }
+export interface ShowAlertEventDetail {
+  message: string;
+  dismissOnNavigation?: boolean;
+  showDismiss?: boolean;
+  action?: string;
+  callback?: () => void;
 }
+export type ShowAlertEvent = CustomEvent<ShowAlertEventDetail>;
 
-export interface EditableContentSaveEventDetail {
-  content: string;
+export interface ShowErrorEventDetail {
+  message: string;
 }
-
-export type EditableContentSaveEvent = CustomEvent<
-  EditableContentSaveEventDetail
->;
-
-declare global {
-  interface HTMLElementEventMap {
-    'editable-content-save': EditableContentSaveEvent;
-  }
-}
-
-export interface OpenFixPreviewEventDetail {
-  patchNum?: PatchSetNum;
-  comment?: UIComment;
-}
-
-export type OpenFixPreviewEvent = CustomEvent<OpenFixPreviewEventDetail>;
-
-declare global {
-  interface HTMLElementEventMap {
-    'open-fix-preview': OpenFixPreviewEvent;
-  }
-}
+export type ShowErrorEvent = CustomEvent<ShowErrorEventDetail>;
 
 // Type for the custom event to switch tab.
-interface SwitchTabEventDetail {
+export interface SwitchTabEventDetail {
   // name of the tab to set as active, from custom event
   tab?: string;
   // index of tab to set as active, from paper-tabs event
@@ -150,68 +186,31 @@
   // define state of tab after opening
   tabState?: TabState;
 }
-
 export interface TabState {
   commentTab?: CommentTabState;
   checksTab?: ChecksTabState;
 }
-
 export enum CommentTabState {
   UNRESOLVED = 'unresolved',
   DRAFTS = 'drafts',
   SHOW_ALL = 'show all',
 }
-
 export interface ChecksTabState {
   statusOrCategory?: RunStatus | Category;
   checkName?: string;
 }
-
 export type SwitchTabEvent = CustomEvent<SwitchTabEventDetail>;
 
-declare global {
-  interface HTMLElementEventMap {
-    'show-primary-tab': SwitchTabEvent;
-    'show-secondary-tab': SwitchTabEvent;
-  }
+export interface ThreadListModifiedDetail {
+  rootId: UrlEncodedCommentId;
+  path: string;
 }
+export type ThreadListModifiedEvent = CustomEvent<ThreadListModifiedDetail>;
 
-export interface ReloadEventDetail {
-  clearPatchset: boolean;
+export interface TitleChangeEventDetail {
+  title: string;
 }
-
-export type ReloadEvent = CustomEvent<ReloadEventDetail>;
-
-export type MovedLinkClickedEvent = CustomEvent<MovedLinkClickedEventDetail>;
-
-declare global {
-  interface HTMLElementEventMap {
-    'moved-link-clicked': MovedLinkClickedEvent;
-  }
-}
-
-declare global {
-  interface HTMLElementEventMap {
-    /* prettier-ignore */
-    'reload': ReloadEvent;
-  }
-}
-
-export interface ShowAlertEventDetail {
-  message: string;
-  dismissOnNavigation?: boolean;
-  showDismiss?: boolean;
-  action?: string;
-  callback?: () => void;
-}
-
-export type ShowAlertEvent = CustomEvent<ShowAlertEventDetail>;
-
-declare global {
-  interface HTMLElementEventMap {
-    'show-alert': ShowAlertEvent;
-  }
-}
+export type TitleChangeEvent = CustomEvent<TitleChangeEventDetail>;
 
 /**
  * Keyboard events emitted from polymer elements.
@@ -231,25 +230,3 @@
   readonly keyCode: number;
   readonly repeat: boolean;
 }
-
-export interface ThreadListModifiedDetail {
-  rootId: UrlEncodedCommentId;
-  path: string;
-}
-
-export type ThreadListModifiedEvent = CustomEvent<ThreadListModifiedDetail>;
-
-// TODO(milutin) - remove once new gr-dialog will do it out of the box
-// This informs gr-app-element to remove footer, header from a11y tree
-export interface DialogChangeEventDetail {
-  canceled?: boolean;
-  opened?: boolean;
-}
-
-export type DialogChangeEvent = CustomEvent<DialogChangeEventDetail>;
-
-declare global {
-  interface HTMLElementEventMap {
-    'thread-list-modified': ThreadListModifiedEvent;
-  }
-}
diff --git a/polygerrit-ui/app/types/globals.ts b/polygerrit-ui/app/types/globals.ts
index 628cee4..267ea12 100644
--- a/polygerrit-ui/app/types/globals.ts
+++ b/polygerrit-ui/app/types/globals.ts
@@ -32,15 +32,14 @@
     // TODO(TS): define gerrit type
     Gerrit?: {
       Nav?: unknown;
-      getRootElement?: unknown;
       Auth?: unknown;
-      _pluginLoader?: unknown;
-      _endpoints?: unknown;
-      RevisionInfo?: unknown;
-      flushPreinstalls?: () => void;
     };
     // TODO(TS): define polymer type
-    Polymer?: {importHref?: unknown};
+    Polymer: {
+      IronFocusablesHelper: {
+        getTabbableNodes: (el: Element) => Node[];
+      };
+    };
     // TODO(TS): remove page when better workaround is found
     // page shouldn't be exposed in window and it shouldn't be used
     // it's defined because of limitations from typescript, which don't import .mjs
@@ -65,17 +64,8 @@
     // TODO(TS): as @brohlfs suggested, to avoid importing anything from elements/ to types/
     // use any for them for now
     GrAnnotation: unknown;
-    GrDiffLine: unknown;
-    GrDiffLineType: unknown;
-    GrDiffGroup: unknown;
-    GrDiffGroupType: unknown;
-    util: unknown;
-    Auth: unknown;
-    EventEmitter: unknown;
-    PluginLoader: unknown;
     // Heads up! There is a known plugin dependency on GrPluginActionContext.
     GrPluginActionContext: unknown;
-    _apiUtils: {};
   }
 
   interface Performance {
diff --git a/polygerrit-ui/app/utils/async-util.ts b/polygerrit-ui/app/utils/async-util.ts
index 119b09b..2b36fee 100644
--- a/polygerrit-ui/app/utils/async-util.ts
+++ b/polygerrit-ui/app/utils/async-util.ts
@@ -42,3 +42,71 @@
     return asyncForeach(array.slice(1), fn);
   });
 }
+
+export const _testOnly_allTasks = new Map<number, DelayedTask>();
+
+/**
+ * This is just a very simple and small wrapper around setTimeout(). Instead of
+ * the usual:
+ *
+ * const timer = window.setTimeout(() => {...do stuff...}, 123);
+ * window.clearTimeout(timer);
+ *
+ * With this class you can do:
+ *
+ * const task = new Task(() => {...do stuff...}, 123);
+ * task.cancel();
+ *
+ * It is just nicer to have an object for this instead of a number as a handle.
+ */
+export class DelayedTask {
+  private timer?: number;
+
+  constructor(private callback: () => void, waitMs = 0) {
+    this.timer = window.setTimeout(() => {
+      if (this.timer) _testOnly_allTasks.delete(this.timer);
+      this.timer = undefined;
+      if (this.callback) this.callback();
+    }, waitMs);
+    _testOnly_allTasks.set(this.timer, this);
+  }
+
+  cancel() {
+    if (this.isActive()) {
+      window.clearTimeout(this.timer);
+      if (this.timer) _testOnly_allTasks.delete(this.timer);
+      this.timer = undefined;
+    }
+  }
+
+  flush() {
+    if (this.isActive()) {
+      this.cancel();
+      if (this.callback) this.callback();
+    }
+  }
+
+  isActive() {
+    return this.timer !== undefined;
+  }
+}
+
+/**
+ * The usage pattern is:
+ *
+ * this.myDebouncedTask = debounce(this.myDebouncedTask, () => {...}, 123);
+ *
+ * It is identical to:
+ *
+ * this.myTask = new DelayedTask(() => {...}, 123);
+ *
+ * But it would cancel a potentially scheduled task beforehand.
+ */
+export function debounce(
+  existingTask: DelayedTask | undefined,
+  callback: () => void,
+  waitMs = 0
+) {
+  existingTask?.cancel();
+  return new DelayedTask(callback, waitMs);
+}
diff --git a/polygerrit-ui/app/utils/change-util.ts b/polygerrit-ui/app/utils/change-util.ts
index 018d70d..d7fb5d0 100644
--- a/polygerrit-ui/app/utils/change-util.ts
+++ b/polygerrit-ui/app/utils/change-util.ts
@@ -227,10 +227,6 @@
   );
 }
 
-export function changeStatusString(change: ChangeInfo) {
-  return changeStatuses(change).join(', ');
-}
-
 export function isRemovableReviewer(
   change?: ChangeInfo,
   reviewer?: AccountInfo
diff --git a/polygerrit-ui/app/utils/change-util_test.js b/polygerrit-ui/app/utils/change-util_test.js
index fd181fe..f348239 100644
--- a/polygerrit-ui/app/utils/change-util_test.js
+++ b/polygerrit-ui/app/utils/change-util_test.js
@@ -20,7 +20,6 @@
   changeBaseURL,
   changePath,
   changeStatuses,
-  changeStatusString,
   isRemovableReviewer,
 } from './change-util.js';
 
@@ -59,9 +58,7 @@
       mergeable: true,
     };
     let statuses = changeStatuses(change);
-    const statusString = changeStatusString(change);
     assert.deepEqual(statuses, []);
-    assert.equal(statusString, '');
 
     change.submittable = false;
     statuses = changeStatuses(change,
@@ -109,9 +106,7 @@
       mergeable: false,
     };
     const statuses = changeStatuses(change);
-    const statusString = changeStatusString(change);
     assert.deepEqual(statuses, ['Merge Conflict']);
-    assert.equal(statusString, 'Merge Conflict');
   });
 
   test('mergeable prop undefined', () => {
@@ -125,9 +120,7 @@
       labels: {},
     };
     const statuses = changeStatuses(change);
-    const statusString = changeStatusString(change);
     assert.deepEqual(statuses, []);
-    assert.equal(statusString, '');
   });
 
   test('Merged status', () => {
@@ -141,9 +134,7 @@
       labels: {},
     };
     const statuses = changeStatuses(change);
-    const statusString = changeStatusString(change);
     assert.deepEqual(statuses, ['Merged']);
-    assert.equal(statusString, 'Merged');
   });
 
   test('Abandoned status', () => {
@@ -157,9 +148,7 @@
       labels: {},
     };
     const statuses = changeStatuses(change);
-    const statusString = changeStatusString(change);
     assert.deepEqual(statuses, ['Abandoned']);
-    assert.equal(statusString, 'Abandoned');
   });
 
   test('Open status with private and wip', () => {
@@ -176,9 +165,7 @@
       mergeable: true,
     };
     const statuses = changeStatuses(change);
-    const statusString = changeStatusString(change);
     assert.deepEqual(statuses, ['WIP', 'Private']);
-    assert.equal(statusString, 'WIP, Private');
   });
 
   test('Merge conflict with private and wip', () => {
@@ -195,9 +182,7 @@
       mergeable: false,
     };
     const statuses = changeStatuses(change);
-    const statusString = changeStatusString(change);
     assert.deepEqual(statuses, ['Merge Conflict', 'WIP', 'Private']);
-    assert.equal(statusString, 'Merge Conflict, WIP, Private');
   });
 
   test('isRemovableReviewer', () => {
diff --git a/polygerrit-ui/app/utils/comment-util.ts b/polygerrit-ui/app/utils/comment-util.ts
index 110832d..048206b 100644
--- a/polygerrit-ui/app/utils/comment-util.ts
+++ b/polygerrit-ui/app/utils/comment-util.ts
@@ -26,6 +26,7 @@
   ParentPatchSetNum,
   ContextLine,
   BasePatchSetNum,
+  RevisionPatchSetNum,
 } from '../types/common';
 import {CommentSide, Side} from '../constants/constants';
 import {parseDate} from './date-util';
@@ -266,14 +267,16 @@
 
 export function getPatchRangeForCommentUrl(
   comment: UIComment,
-  latestPatchNum: PatchSetNum
+  latestPatchNum: RevisionPatchSetNum
 ) {
   if (!comment.patch_set) throw new Error('Missing comment.patch_set');
 
   // TODO(dhruvsri): Add handling for comment left on parents of merge commits
   if (comment.side === CommentSide.PARENT) {
+    if (comment.patch_set === ParentPatchSetNum)
+      throw new Error('diffSide cannot be PARENT');
     return {
-      patchNum: comment.patch_set,
+      patchNum: comment.patch_set as RevisionPatchSetNum,
       basePatchNum: ParentPatchSetNum,
     };
   } else if (latestPatchNum === comment.patch_set) {
@@ -283,7 +286,7 @@
     };
   } else {
     return {
-      patchNum: latestPatchNum,
+      patchNum: latestPatchNum as RevisionPatchSetNum,
       basePatchNum: comment.patch_set as BasePatchSetNum,
     };
   }
diff --git a/polygerrit-ui/app/utils/comment-util_test.ts b/polygerrit-ui/app/utils/comment-util_test.ts
index 29eb5b7..3c8f26d 100644
--- a/polygerrit-ui/app/utils/comment-util_test.ts
+++ b/polygerrit-ui/app/utils/comment-util_test.ts
@@ -15,25 +15,23 @@
  * limitations under the License.
  */
 
-import '../test/common-test-setup-karma.js';
+import '../test/common-test-setup-karma';
 import {
   isUnresolved,
   getPatchRangeForCommentUrl,
   createCommentThreads,
   sortComments,
-} from './comment-util.js';
-import {
-  createComment,
-  createCommentThread,
-} from '../test/test-data-generators.js';
-import {CommentSide, Side} from '../constants/constants.js';
+} from './comment-util';
+import {createComment, createCommentThread} from '../test/test-data-generators';
+import {CommentSide, Side} from '../constants/constants';
 import {
   BasePatchSetNum,
   ParentPatchSetNum,
   PatchSetNum,
+  RevisionPatchSetNum,
   Timestamp,
   UrlEncodedCommentId,
-} from '../types/common.js';
+} from '../types/common';
 
 suite('comment-util', () => {
   test('isUnresolved', () => {
@@ -84,10 +82,13 @@
         side: CommentSide.PARENT,
         path: '/COMMIT_MSG',
       };
-      assert.deepEqual(getPatchRangeForCommentUrl(comment, 11 as PatchSetNum), {
-        basePatchNum: ParentPatchSetNum,
-        patchNum: 4 as PatchSetNum,
-      });
+      assert.deepEqual(
+        getPatchRangeForCommentUrl(comment, 11 as RevisionPatchSetNum),
+        {
+          basePatchNum: ParentPatchSetNum,
+          patchNum: 4 as PatchSetNum,
+        }
+      );
     });
   });
 
@@ -154,7 +155,7 @@
 
       const actualThreads = createCommentThreads(comments, {
         basePatchNum: 1 as BasePatchSetNum,
-        patchNum: 4 as PatchSetNum,
+        patchNum: 4 as RevisionPatchSetNum,
       });
 
       assert.equal(actualThreads.length, 2);
@@ -228,7 +229,7 @@
       assert.deepEqual(
         createCommentThreads(comments, {
           basePatchNum: 5 as BasePatchSetNum,
-          patchNum: 10 as PatchSetNum,
+          patchNum: 10 as RevisionPatchSetNum,
         }),
         expectedThreads
       );
diff --git a/polygerrit-ui/app/utils/dom-util.ts b/polygerrit-ui/app/utils/dom-util.ts
index 7f9ef72..3affef7 100644
--- a/polygerrit-ui/app/utils/dom-util.ts
+++ b/polygerrit-ui/app/utils/dom-util.ts
@@ -278,3 +278,17 @@
   );
   observer.observe(element);
 }
+
+/**
+ * Toggles a CSS class on or off for an element.
+ */
+export function toggleClass(el: Element, className: string, bool?: boolean) {
+  if (bool === undefined) {
+    bool = !el.classList.contains(className);
+  }
+  if (bool) {
+    el.classList.add(className);
+  } else {
+    el.classList.remove(className);
+  }
+}
diff --git a/polygerrit-ui/app/utils/event-util.ts b/polygerrit-ui/app/utils/event-util.ts
index 46b1b49..080955f 100644
--- a/polygerrit-ui/app/utils/event-util.ts
+++ b/polygerrit-ui/app/utils/event-util.ts
@@ -17,18 +17,19 @@
 
 import {UrlEncodedCommentId} from '../types/common';
 import {FetchRequest} from '../types/types';
-import {DialogChangeEventDetail, TabState} from '../types/events';
-
-export enum EventType {
-  SHOW_ALERT = 'show-alert',
-  PAGE_ERROR = 'page-error',
-  SERVER_ERROR = 'server-error',
-  NETWORK_ERROR = 'network-error',
-  TITLE_CHANGE = 'title-change',
-  THREAD_LIST_MODIFIED = 'thread-list-modified',
-  DIALOG_CHANGE = 'dialog-change',
-  SHOW_PRIMARY_TAB = 'show-primary-tab',
-}
+import {
+  DialogChangeEventDetail,
+  EventType,
+  IronAnnounceEventDetail,
+  NetworkErrorEventDetail,
+  PageErrorEventDetail,
+  ServerErrorEventDetail,
+  ShowAlertEventDetail,
+  SwitchTabEventDetail,
+  TabState,
+  ThreadListModifiedDetail,
+  TitleChangeEventDetail,
+} from '../types/events';
 
 export function fireEvent(target: EventTarget, type: string) {
   target.dispatchEvent(
@@ -39,54 +40,38 @@
   );
 }
 
-export function fireAlert(target: EventTarget, message: string) {
+export function fire<T>(target: EventTarget, type: string, detail: T) {
   target.dispatchEvent(
-    new CustomEvent(EventType.SHOW_ALERT, {
-      detail: {message},
+    new CustomEvent<T>(type, {
+      detail,
       composed: true,
       bubbles: true,
     })
   );
 }
 
+export function fireAlert(target: EventTarget, message: string) {
+  fire<ShowAlertEventDetail>(target, EventType.SHOW_ALERT, {message});
+}
+
 export function firePageError(response?: Response | null) {
-  document.dispatchEvent(
-    new CustomEvent(EventType.PAGE_ERROR, {
-      detail: {response},
-      composed: true,
-      bubbles: true,
-    })
-  );
+  if (response === null) response = undefined;
+  fire<PageErrorEventDetail>(document, EventType.PAGE_ERROR, {response});
 }
 
 export function fireServerError(response: Response, request?: FetchRequest) {
-  document.dispatchEvent(
-    new CustomEvent(EventType.SERVER_ERROR, {
-      detail: {response, request},
-      composed: true,
-      bubbles: true,
-    })
-  );
+  fire<ServerErrorEventDetail>(document, EventType.SERVER_ERROR, {
+    response,
+    request,
+  });
 }
 
 export function fireNetworkError(error: Error) {
-  document.dispatchEvent(
-    new CustomEvent(EventType.NETWORK_ERROR, {
-      detail: {error},
-      composed: true,
-      bubbles: true,
-    })
-  );
+  fire<NetworkErrorEventDetail>(document, EventType.NETWORK_ERROR, {error});
 }
 
 export function fireTitleChange(target: EventTarget, title: string) {
-  target.dispatchEvent(
-    new CustomEvent(EventType.TITLE_CHANGE, {
-      detail: {title},
-      composed: true,
-      bubbles: true,
-    })
-  );
+  fire<TitleChangeEventDetail>(target, EventType.TITLE_CHANGE, {title});
 }
 
 // TODO(milutin) - remove once new gr-dialog will do it out of the box
@@ -95,13 +80,11 @@
   target: EventTarget,
   detail: DialogChangeEventDetail
 ) {
-  target.dispatchEvent(
-    new CustomEvent(EventType.DIALOG_CHANGE, {
-      detail,
-      composed: true,
-      bubbles: true,
-    })
-  );
+  fire<DialogChangeEventDetail>(target, EventType.DIALOG_CHANGE, detail);
+}
+
+export function fireIronAnnounce(target: EventTarget, text: string) {
+  fire<IronAnnounceEventDetail>(target, EventType.IRON_ANNOUNCE, {text});
 }
 
 export function fireThreadListModifiedEvent(
@@ -109,13 +92,10 @@
   rootId: UrlEncodedCommentId,
   path: string
 ) {
-  target.dispatchEvent(
-    new CustomEvent(EventType.THREAD_LIST_MODIFIED, {
-      detail: {rootId, path},
-      composed: true,
-      bubbles: true,
-    })
-  );
+  fire<ThreadListModifiedDetail>(target, EventType.THREAD_LIST_MODIFIED, {
+    rootId,
+    path,
+  });
 }
 
 export function fireShowPrimaryTab(
@@ -124,13 +104,8 @@
   scrollIntoView?: boolean,
   tabState?: TabState
 ) {
-  target.dispatchEvent(
-    new CustomEvent(EventType.SHOW_PRIMARY_TAB, {
-      detail: {tab, scrollIntoView, tabState},
-      composed: true,
-      bubbles: true,
-    })
-  );
+  const detail: SwitchTabEventDetail = {tab, scrollIntoView, tabState};
+  fire<SwitchTabEventDetail>(target, EventType.SHOW_PRIMARY_TAB, detail);
 }
 
 export function waitForEventOnce<K extends keyof HTMLElementEventMap>(
diff --git a/polygerrit-ui/app/utils/string-util_test.ts b/polygerrit-ui/app/utils/string-util_test.ts
index 9297d90..2eef50f 100644
--- a/polygerrit-ui/app/utils/string-util_test.ts
+++ b/polygerrit-ui/app/utils/string-util_test.ts
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-import '../test/common-test-setup-karma.js';
-import {pluralize} from './string-util.js';
+import '../test/common-test-setup-karma';
+import {pluralize} from './string-util';
 
 suite('formatter util tests', () => {
   test('pluralize', () => {
diff --git a/polygerrit-ui/server.go b/polygerrit-ui/server.go
index e6487a7..2734f58 100644
--- a/polygerrit-ui/server.go
+++ b/polygerrit-ui/server.go
@@ -400,14 +400,8 @@
 		insertionPoint := strings.Index(replaced, "</script>")
 		builder := new(strings.Builder)
 		builder.WriteString(
-			"window.INITIAL_DATA['/config/server/info'].plugin.html_resource_paths = []; ")
-		builder.WriteString(
 			"window.INITIAL_DATA['/config/server/info'].plugin.js_resource_paths = []; ")
 		for _, p := range strings.Split(*plugins, ",") {
-			if filepath.Ext(p) == ".html" {
-				builder.WriteString(
-					"window.INITIAL_DATA['/config/server/info'].plugin.html_resource_paths.push('" + p + "'); ")
-			}
 			if filepath.Ext(p) == ".js" {
 				builder.WriteString(
 					"window.INITIAL_DATA['/config/server/info'].plugin.js_resource_paths.push('" + p + "'); ")
@@ -435,22 +429,15 @@
 
 	// Configuration path in the JSON server response
 	jsPluginsPath := []string{"plugin", "js_resource_paths"}
-	htmlPluginsPath := []string{"plugin", "html_resource_paths"}
-	htmlResources := getJsonPropByPath(response, htmlPluginsPath).([]interface{})
 	jsResources := getJsonPropByPath(response, jsPluginsPath).([]interface{})
 
 	for _, p := range strings.Split(*plugins, ",") {
-		if filepath.Ext(p) == ".html" {
-			htmlResources = append(htmlResources, p)
-		}
-
 		if filepath.Ext(p) == ".js" {
 			jsResources = append(jsResources, p)
 		}
 	}
 
 	setJsonPropByPath(response, jsPluginsPath, jsResources)
-	setJsonPropByPath(response, htmlPluginsPath, htmlResources)
 
 	reader, writer := io.Pipe()
 	go func() {