diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index afd96e3c0f119..4e05bdd41cc47 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,17 @@
+2018-06-04  Frederic Wang  <fwang@igalia.com>
+
+        import-w3c-tests should rely on <meta name="flags"> to detect CSS manual tests
+        https://bugs.webkit.org/show_bug.cgi?id=186261
+
+        Reviewed by Youenn Fablet.
+
+        * Scripts/webkitpy/w3c/test_parser.py:
+        (TestParser.is_wpt_manualtest): Add code to detect whether a file is a manual test
+        from its <meta name="flags"> tags. This is based on SourceFile::content_is_css_manual from
+        the WPT repository.
+        * Scripts/webkitpy/w3c/test_parser_unittest.py: Add a test to verify whether files with
+        <meta name="flags"> are manual or non-manual according to CSS WG rules.
+
 2018-06-04  Dan Bernstein  <mitz@apple.com>
 
         Fixed building ImageDiff with the default build system in the Xcode 10 developer beta.
diff --git a/Tools/Scripts/webkitpy/w3c/test_parser.py b/Tools/Scripts/webkitpy/w3c/test_parser.py
index 719cb8fab42a4..0afbf5674867d 100644
--- a/Tools/Scripts/webkitpy/w3c/test_parser.py
+++ b/Tools/Scripts/webkitpy/w3c/test_parser.py
@@ -138,8 +138,23 @@ def is_jstest(self):
         return bool(self.test_doc.find(src=re.compile('[\'\"/]?/resources/testharness')))
 
     def is_wpt_manualtest(self):
-        """Returns whether the test is a manual test according WPT rules (i.e. file ends with -manual.htm path)."""
-        return self.filename.endswith('-manual.htm') or self.filename.endswith('-manual.html')
+        """Returns whether the test is a manual test according WPT rules."""
+        # General rule for manual test i.e. file ends with -manual.htm path
+        # See https://web-platform-tests.org/writing-tests/manual.html#requirements-for-a-manual-test
+        if self.filename.endswith('-manual.htm') or self.filename.endswith('-manual.html'):
+            return True
+
+        # Rule specific to CSS WG manual tests i.e. rely on <meta name="flags">
+        # See https://web-platform-tests.org/writing-tests/css-metadata.html#requirement-flags
+        # For further details and discussions, see the following links:
+        # https://github.com/web-platform-tests/wpt/issues/5381
+        # https://github.com/web-platform-tests/wpt/issues/5293
+        for match in self.test_doc.findAll(name='meta', attrs={'name': 'flags', 'content': True}):
+            css_flags = set(match['content'].split())
+            if bool(css_flags & {"animated", "font", "history", "interact", "paged", "speech", "userstyle"}):
+                return True
+
+        return False
 
     def is_slow_test(self):
         return any([match.name == 'meta' and match['name'] == 'timeout' for match in self.test_doc.findAll(content='long')])
diff --git a/Tools/Scripts/webkitpy/w3c/test_parser_unittest.py b/Tools/Scripts/webkitpy/w3c/test_parser_unittest.py
index 580a991d5490d..ae8fcd8ac0d0e 100644
--- a/Tools/Scripts/webkitpy/w3c/test_parser_unittest.py
+++ b/Tools/Scripts/webkitpy/w3c/test_parser_unittest.py
@@ -168,6 +168,31 @@ def test_analyze_manual_wpt_test(self):
 
         self.assertTrue(test_info['manualtest'], 'test_info is None')
 
+    def test_analyze_css_manual_test(self):
+        """ Tests analyze_test() using a css manual test """
+
+        test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
+        parser = TestParser(options, os.path.join(test_path, 'somefile.html'))
+
+        for content in ["", "flag1", "flag1 flag2", "flag1 flag2 flag3", "asis"]:
+            test_html = """
+<head>
+  <meta name="flags" content="%s">
+</head>""" % content
+            test_info = parser.analyze_test(test_contents=test_html)
+            self.assertEqual(test_info, None, 'test_info should be None')
+
+        for flag in ["animated", "font", "history", "interact", "paged", "speech", "userstyle"]:
+            test_html = """
+<head>
+  <meta name="flags" content="flag1 flag2">
+  <meta name="flags" content="flag3 %s flag4 flag5">
+  <meta name="flags" content="flag6">
+</head>
+""" % flag
+            test_info = parser.analyze_test(test_contents=test_html)
+            self.assertTrue(test_info['manualtest'], 'test with CSS flag %s should be manual' % flag)
+
     def test_analyze_pixel_test_all_true(self):
         """ Tests analyze_test() using a test that is neither a reftest or jstest with all=False """