diff --git a/DEPS b/DEPS
index 8e6a02a..8583859f 100644
--- a/DEPS
+++ b/DEPS
@@ -44,7 +44,7 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling V8
   # and whatever else without interference from each other.
-  'v8_revision': 'd1d93c3a0e8f6eb84756b5ad56b33e300e327bdc',
+  'v8_revision': '7ca33baf03d6a2c9a38157829d1bad68ebd78369',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling swarming_client
   # and whatever else without interference from each other.
@@ -64,7 +64,7 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling PDFium
   # and whatever else without interference from each other.
-  'pdfium_revision': '96f482c9cd3c99425fd3422251903b1218253c66',
+  'pdfium_revision': 'd805eec52f6ac574918748c4270873e7e5cde596',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling openmax_dl
   # and whatever else without interference from each other.
@@ -96,7 +96,7 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling catapult
   # and whatever else without interference from each other.
-  'catapult_revision': 'dcd70be386e31db13059dbd7c9342ac678da41a9',
+  'catapult_revision': 'd71b47153f165d7c823deadc02a0c3b5102630ce',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling libFuzzer
   # and whatever else without interference from each other.
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
index c060004..d1f8f36 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
@@ -20,9 +20,6 @@
 import android.webkit.WebSettings;
 import android.webkit.WebSettings.LayoutAlgorithm;
 
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-
 import org.chromium.android_webview.AwContents;
 import org.chromium.android_webview.AwSettings;
 import org.chromium.android_webview.AwWebResourceResponse;
@@ -41,6 +38,7 @@
 import org.chromium.content.browser.test.util.HistoryUtils;
 import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
 import org.chromium.content_public.browser.WebContents;
+import org.chromium.net.test.EmbeddedTestServer;
 import org.chromium.net.test.util.TestWebServer;
 import org.chromium.ui.display.DisplayAndroid;
 
@@ -1751,31 +1749,28 @@
         final TestAwContentsClient contentClient = new TestAwContentsClient();
         final AwTestContainerView testContainerView =
                 createAwTestContainerViewOnMainSync(contentClient);
-        AwContents awContents = testContainerView.getAwContents();
-        AwSettings settings = getAwSettingsOnUiThread(awContents);
         final String customUserAgentString =
                 "testUserAgentWithTestServerUserAgent";
+        AwContents awContents = testContainerView.getAwContents();
+        AwSettings settings = getAwSettingsOnUiThread(awContents);
+        EmbeddedTestServer testServer =
+                EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
 
-        String fileName = null;
-        TestWebServer webServer = TestWebServer.start();
+        enableJavaScriptOnUiThread(awContents);
+
         try {
-            final String httpPath = "/testUserAgentWithTestServer.html";
-            final String url = webServer.setResponse(httpPath, "foo", null);
-
+            // Create url with echoheader echoing the User-Agent header in the the html body.
+            String url = testServer.getURL("/echoheader?User-Agent");
             settings.setUserAgentString(customUserAgentString);
             loadUrlSync(awContents,
                         contentClient.getOnPageFinishedHelper(),
                         url);
-
-            assertEquals(1, webServer.getRequestCount(httpPath));
-            HttpRequest request = webServer.getLastRequest(httpPath);
-            Header[] matchingHeaders = request.getHeaders("User-Agent");
-            assertEquals(1, matchingHeaders.length);
-
-            Header header = matchingHeaders[0];
-            assertEquals(customUserAgentString, header.getValue());
+            String userAgent = maybeStripDoubleQuotes(JSUtils.executeJavaScriptAndWaitForResult(
+                    this, awContents, contentClient.getOnEvaluateJavaScriptResultHelper(),
+                    "document.body.textContent"));
+            assertEquals(customUserAgentString, userAgent);
         } finally {
-            webServer.shutdown();
+            testServer.stopAndDestroyServer();
         }
     }
 
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index cff862ae..21a44c6 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -174,6 +174,7 @@
 
 FilePath::FilePath(const FilePath& that) : path_(that.path_) {
 }
+FilePath::FilePath(FilePath&& that) = default;
 
 FilePath::FilePath(StringPieceType path) {
   path.CopyToString(&path_);
@@ -190,6 +191,8 @@
   return *this;
 }
 
+FilePath& FilePath::operator=(FilePath&& that) = default;
+
 bool FilePath::operator==(const FilePath& that) const {
 #if defined(FILE_PATH_USES_DRIVE_LETTERS)
   return EqualDriveLetterCaseInsensitive(this->path_, that.path_);
diff --git a/base/files/file_path.h b/base/files/file_path.h
index 3234df7bf..02846f6 100644
--- a/base/files/file_path.h
+++ b/base/files/file_path.h
@@ -182,6 +182,13 @@
   ~FilePath();
   FilePath& operator=(const FilePath& that);
 
+  // Constructs FilePath with the contents of |that|, which is left in valid but
+  // unspecified state.
+  FilePath(FilePath&& that);
+  // Replaces the contents with those of |that|, which is left in valid but
+  // unspecified state.
+  FilePath& operator=(FilePath&& that);
+
   bool operator==(const FilePath& that) const;
 
   bool operator!=(const FilePath& that) const;
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index d16ec63..7b8bb2b 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -422,8 +422,6 @@
     "scheduler/scheduler_state_machine.cc",
     "scheduler/scheduler_state_machine.h",
     "scheduler/video_frame_controller.h",
-    "tiles/decoded_image_tracker.cc",
-    "tiles/decoded_image_tracker.h",
     "tiles/eviction_tile_priority_queue.cc",
     "tiles/eviction_tile_priority_queue.h",
     "tiles/gpu_image_decode_cache.cc",
@@ -887,7 +885,6 @@
     "test/mock_helper_unittest.cc",
     "test/ordered_simple_task_runner_unittest.cc",
     "test/test_web_graphics_context_3d_unittest.cc",
-    "tiles/decoded_image_tracker_unittest.cc",
     "tiles/gpu_image_decode_cache_unittest.cc",
     "tiles/image_controller_unittest.cc",
     "tiles/mipmap_util_unittest.cc",
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 08c72af..530cff7 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -160,7 +160,7 @@
     return inputs_.background_filters;
   }
 
-  virtual void SetContentsOpaque(bool opaque);
+  void SetContentsOpaque(bool opaque);
   bool contents_opaque() const { return inputs_.contents_opaque; }
 
   void SetPosition(const gfx::PointF& position);
diff --git a/cc/playback/image_hijack_canvas_unittest.cc b/cc/playback/image_hijack_canvas_unittest.cc
index 76186eea..214de87 100644
--- a/cc/playback/image_hijack_canvas_unittest.cc
+++ b/cc/playback/image_hijack_canvas_unittest.cc
@@ -28,8 +28,6 @@
   MOCK_METHOD0(ReduceCacheUsage, void());
   MOCK_METHOD1(SetShouldAggressivelyFreeResources,
                void(bool aggressively_free_resources));
-  MOCK_METHOD2(GetOutOfRasterDecodeTaskForImageAndRef,
-               bool(const DrawImage& image, scoped_refptr<TileTask>* task));
 };
 
 TEST(ImageHijackCanvasTest, NonLazyImagesSkipped) {
diff --git a/cc/raster/task.cc b/cc/raster/task.cc
index 94486fd5..94e413f 100644
--- a/cc/raster/task.cc
+++ b/cc/raster/task.cc
@@ -18,10 +18,6 @@
          "CANCELED state.";
 }
 
-bool TaskState::IsNew() const {
-  return value_ == Value::NEW;
-}
-
 bool TaskState::IsScheduled() const {
   return value_ == Value::SCHEDULED;
 }
@@ -42,23 +38,6 @@
   value_ = Value::NEW;
 }
 
-std::string TaskState::ToString() const {
-  switch (value_) {
-    case Value::NEW:
-      return "NEW";
-    case Value::SCHEDULED:
-      return "SCHEDULED";
-    case Value::RUNNING:
-      return "RUNNING";
-    case Value::FINISHED:
-      return "FINISHED";
-    case Value::CANCELED:
-      return "CANCELED";
-  }
-  NOTREACHED();
-  return "";
-}
-
 void TaskState::DidSchedule() {
   DCHECK(value_ == Value::NEW)
       << "Task should be in NEW state to get scheduled.";
diff --git a/cc/raster/task.h b/cc/raster/task.h
index 01c16a0..2c406077 100644
--- a/cc/raster/task.h
+++ b/cc/raster/task.h
@@ -7,7 +7,6 @@
 
 #include <stdint.h>
 
-#include <string>
 #include <vector>
 
 #include "base/memory/ref_counted.h"
@@ -39,7 +38,6 @@
 //    └─────────┘         ╚══════════╝
 class CC_EXPORT TaskState {
  public:
-  bool IsNew() const;
   bool IsScheduled() const;
   bool IsRunning() const;
   bool IsFinished() const;
@@ -55,8 +53,6 @@
   void DidFinish();
   void DidCancel();
 
-  std::string ToString() const;
-
  private:
   friend class Task;
 
diff --git a/cc/test/fake_layer_tree_host_impl.cc b/cc/test/fake_layer_tree_host_impl.cc
index 63a32fd..d6b2cd07 100644
--- a/cc/test/fake_layer_tree_host_impl.cc
+++ b/cc/test/fake_layer_tree_host_impl.cc
@@ -31,8 +31,7 @@
                         &stats_instrumentation_,
                         task_graph_runner,
                         AnimationHost::CreateForTesting(ThreadInstance::IMPL),
-                        0,
-                        nullptr),
+                        0),
       notify_tile_state_changed_called_(false) {
   // Explicitly clear all debug settings.
   SetDebugState(LayerTreeDebugState());
diff --git a/cc/test/fake_tile_manager.cc b/cc/test/fake_tile_manager.cc
index 24457b51..0f2b418a 100644
--- a/cc/test/fake_tile_manager.cc
+++ b/cc/test/fake_tile_manager.cc
@@ -30,18 +30,32 @@
 
 }  // namespace
 
-FakeTileManager::FakeTileManager(TileManagerClient* client,
-                                 ResourcePool* resource_pool)
+FakeTileManager::FakeTileManager(TileManagerClient* client)
     : TileManager(client,
                   base::ThreadTaskRunnerHandle::Get().get(),
-                  nullptr,
                   std::numeric_limits<size_t>::max(),
                   false /* use_partial_raster */,
                   false /* check_tile_priority_inversion */),
       image_decode_cache_(
           ResourceFormat::RGBA_8888,
           LayerTreeSettings().software_decoded_image_budget_bytes) {
-  SetDecodedImageTracker(&decoded_image_tracker_);
+  SetResources(
+      nullptr, &image_decode_cache_, g_synchronous_task_graph_runner.Pointer(),
+      g_fake_raster_buffer_provider.Pointer(),
+      std::numeric_limits<size_t>::max(), false /* use_gpu_rasterization */);
+  SetTileTaskManagerForTesting(base::MakeUnique<FakeTileTaskManagerImpl>());
+}
+
+FakeTileManager::FakeTileManager(TileManagerClient* client,
+                                 ResourcePool* resource_pool)
+    : TileManager(client,
+                  base::ThreadTaskRunnerHandle::Get().get(),
+                  std::numeric_limits<size_t>::max(),
+                  false /* use_partial_raster */,
+                  false /* check_tile_priority_inversion */),
+      image_decode_cache_(
+          ResourceFormat::RGBA_8888,
+          LayerTreeSettings().software_decoded_image_budget_bytes) {
   SetResources(resource_pool, &image_decode_cache_,
                g_synchronous_task_graph_runner.Pointer(),
                g_fake_raster_buffer_provider.Pointer(),
diff --git a/cc/test/fake_tile_manager.h b/cc/test/fake_tile_manager.h
index 0e1d715b..07380079 100644
--- a/cc/test/fake_tile_manager.h
+++ b/cc/test/fake_tile_manager.h
@@ -15,8 +15,8 @@
 
 class FakeTileManager : public TileManager {
  public:
-  FakeTileManager(TileManagerClient* client,
-                  ResourcePool* resource_pool = nullptr);
+  explicit FakeTileManager(TileManagerClient* client);
+  FakeTileManager(TileManagerClient* client, ResourcePool* resource_pool);
   ~FakeTileManager() override;
 
   bool HasBeenAssignedMemory(Tile* tile);
@@ -27,7 +27,6 @@
 
  private:
   SoftwareImageDecodeCache image_decode_cache_;
-  DecodedImageTracker decoded_image_tracker_;
 };
 
 }  // namespace cc
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 474399da..7177231 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -117,8 +117,7 @@
                           stats_instrumentation,
                           task_graph_runner,
                           AnimationHost::CreateForTesting(ThreadInstance::IMPL),
-                          0,
-                          nullptr),
+                          0),
         test_hooks_(test_hooks),
         block_notify_ready_to_activate_for_testing_(false),
         notify_ready_to_activate_was_blocked_(false) {}
diff --git a/cc/tiles/decoded_image_tracker.cc b/cc/tiles/decoded_image_tracker.cc
deleted file mode 100644
index cdfa39bb2..0000000
--- a/cc/tiles/decoded_image_tracker.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/tiles/decoded_image_tracker.h"
-
-namespace cc {
-namespace {
-const int kNumFramesToLock = 2;
-}  // namespace
-
-DecodedImageTracker::DecodedImageTracker() = default;
-DecodedImageTracker::~DecodedImageTracker() {
-  for (auto& pair : locked_images_)
-    image_controller_->UnlockImageDecode(pair.first);
-}
-
-void DecodedImageTracker::QueueImageDecode(sk_sp<const SkImage> image,
-                                           const base::Closure& callback) {
-  DCHECK(image_controller_);
-  // Queue the decode in the image controller, but switch out the callback for
-  // our own.
-  image_controller_->QueueImageDecode(
-      std::move(image), base::Bind(&DecodedImageTracker::ImageDecodeFinished,
-                                   base::Unretained(this), callback));
-}
-
-void DecodedImageTracker::NotifyFrameFinished() {
-  // Go through the images and if the frame ref count goes to 0, unlock the
-  // image in the controller.
-  for (auto it = locked_images_.begin(); it != locked_images_.end();) {
-    auto id = it->first;
-    int& ref_count = it->second;
-    if (--ref_count != 0) {
-      ++it;
-      continue;
-    }
-    image_controller_->UnlockImageDecode(id);
-    it = locked_images_.erase(it);
-  }
-}
-
-void DecodedImageTracker::ImageDecodeFinished(
-    const base::Closure& callback,
-    ImageController::ImageDecodeRequestId id) {
-  locked_images_.push_back(std::make_pair(id, kNumFramesToLock));
-  callback.Run();
-}
-
-}  // namespace cc
diff --git a/cc/tiles/decoded_image_tracker.h b/cc/tiles/decoded_image_tracker.h
deleted file mode 100644
index 2d303ee..0000000
--- a/cc/tiles/decoded_image_tracker.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_TILES_DECODED_IMAGE_TRACKER_H_
-#define CC_TILES_DECODED_IMAGE_TRACKER_H_
-
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "cc/base/cc_export.h"
-#include "cc/tiles/image_controller.h"
-
-class SkImage;
-
-namespace cc {
-
-// This class is the main interface for the rest of the system to request
-// decodes. It is responsible for keeping the decodes locked for a number of
-// frames, specified as |kNumFramesToLock| in the implementation file.
-//
-// Note that it is safe to replace ImageController's cache without doing
-// anything special with this class, since it retains only ids to the decode
-// requests. When defunct ids are then used to try and unlock the image, they
-// are silently ignored.
-class CC_EXPORT DecodedImageTracker {
- public:
-  DecodedImageTracker();
-  ~DecodedImageTracker();
-
-  void QueueImageDecode(sk_sp<const SkImage> image,
-                        const base::Closure& callback);
-  void NotifyFrameFinished();
-
- private:
-  friend class TileManager;
-  friend class DecodedImageTrackerTest;
-
-  void set_image_controller(ImageController* controller) {
-    image_controller_ = controller;
-  }
-
-  void ImageDecodeFinished(const base::Closure& callback,
-                           ImageController::ImageDecodeRequestId id);
-
-  ImageController* image_controller_ = nullptr;
-  std::vector<std::pair<ImageController::ImageDecodeRequestId, int>>
-      locked_images_;
-
-  DISALLOW_COPY_AND_ASSIGN(DecodedImageTracker);
-};
-
-}  // namespace cc
-
-#endif  // CC_TILES_DECODED_IMAGE_TRACKER_H_
diff --git a/cc/tiles/decoded_image_tracker_unittest.cc b/cc/tiles/decoded_image_tracker_unittest.cc
deleted file mode 100644
index eff5f18..0000000
--- a/cc/tiles/decoded_image_tracker_unittest.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <vector>
-
-#include "base/bind.h"
-#include "cc/tiles/decoded_image_tracker.h"
-#include "cc/tiles/image_controller.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace cc {
-
-class TestImageController : public ImageController {
- public:
-  TestImageController() : ImageController(nullptr, nullptr) {}
-
-  void UnlockImageDecode(ImageDecodeRequestId id) override {
-    auto it = std::find(locked_ids_.begin(), locked_ids_.end(), id);
-    ASSERT_FALSE(it == locked_ids_.end());
-    locked_ids_.erase(it);
-  }
-
-  ImageDecodeRequestId QueueImageDecode(
-      sk_sp<const SkImage> image,
-      const ImageDecodedCallback& callback) override {
-    auto id = next_id_++;
-    locked_ids_.push_back(id);
-    callback.Run(id);
-    return id;
-  }
-
-  size_t num_locked_images() { return locked_ids_.size(); }
-
- private:
-  ImageDecodeRequestId next_id_ = 1;
-  std::vector<ImageDecodeRequestId> locked_ids_;
-};
-
-class DecodedImageTrackerTest : public testing::Test {
- public:
-  void SetUp() override {
-    decoded_image_tracker_.set_image_controller(image_controller());
-  }
-
-  TestImageController* image_controller() { return &image_controller_; }
-  DecodedImageTracker* decoded_image_tracker() {
-    return &decoded_image_tracker_;
-  }
-
- private:
-  TestImageController image_controller_;
-  DecodedImageTracker decoded_image_tracker_;
-};
-
-TEST_F(DecodedImageTrackerTest, QueueImageLocksImages) {
-  bool locked = false;
-  decoded_image_tracker()->QueueImageDecode(
-      nullptr, base::Bind([](bool* locked) { *locked = true; },
-                          base::Unretained(&locked)));
-  EXPECT_TRUE(locked);
-  EXPECT_EQ(1u, image_controller()->num_locked_images());
-}
-
-TEST_F(DecodedImageTrackerTest, NotifyFrameFinishedUnlocksImages) {
-  bool locked = false;
-  decoded_image_tracker()->QueueImageDecode(
-      nullptr, base::Bind([](bool* locked) { *locked = true; },
-                          base::Unretained(&locked)));
-  EXPECT_TRUE(locked);
-  EXPECT_EQ(1u, image_controller()->num_locked_images());
-
-  decoded_image_tracker()->NotifyFrameFinished();
-  EXPECT_EQ(1u, image_controller()->num_locked_images());
-
-  locked = false;
-  decoded_image_tracker()->QueueImageDecode(
-      nullptr, base::Bind([](bool* locked) { *locked = true; },
-                          base::Unretained(&locked)));
-  EXPECT_TRUE(locked);
-  EXPECT_EQ(2u, image_controller()->num_locked_images());
-
-  decoded_image_tracker()->NotifyFrameFinished();
-  EXPECT_EQ(1u, image_controller()->num_locked_images());
-
-  decoded_image_tracker()->NotifyFrameFinished();
-  EXPECT_EQ(0u, image_controller()->num_locked_images());
-}
-
-}  // namespace cc
diff --git a/cc/tiles/gpu_image_decode_cache.cc b/cc/tiles/gpu_image_decode_cache.cc
index 7f75c88..3ae2645 100644
--- a/cc/tiles/gpu_image_decode_cache.cc
+++ b/cc/tiles/gpu_image_decode_cache.cc
@@ -149,13 +149,11 @@
  public:
   ImageDecodeTaskImpl(GpuImageDecodeCache* cache,
                       const DrawImage& draw_image,
-                      const ImageDecodeCache::TracingInfo& tracing_info,
-                      GpuImageDecodeCache::DecodeTaskType task_type)
+                      const ImageDecodeCache::TracingInfo& tracing_info)
       : TileTask(true),
         cache_(cache),
         image_(draw_image),
-        tracing_info_(tracing_info),
-        task_type_(task_type) {
+        tracing_info_(tracing_info) {
     DCHECK(!SkipImage(draw_image));
   }
 
@@ -171,7 +169,7 @@
 
   // Overridden from TileTask:
   void OnTaskCompleted() override {
-    cache_->OnImageDecodeTaskCompleted(image_, task_type_);
+    cache_->OnImageDecodeTaskCompleted(image_);
   }
 
  protected:
@@ -181,7 +179,6 @@
   GpuImageDecodeCache* cache_;
   DrawImage image_;
   const ImageDecodeCache::TracingInfo tracing_info_;
-  const GpuImageDecodeCache::DecodeTaskType task_type_;
 
   DISALLOW_COPY_AND_ASSIGN(ImageDecodeTaskImpl);
 };
@@ -383,22 +380,6 @@
 bool GpuImageDecodeCache::GetTaskForImageAndRef(const DrawImage& draw_image,
                                                 const TracingInfo& tracing_info,
                                                 scoped_refptr<TileTask>* task) {
-  return GetTaskForImageAndRefInternal(
-      draw_image, tracing_info, DecodeTaskType::PART_OF_UPLOAD_TASK, task);
-}
-
-bool GpuImageDecodeCache::GetOutOfRasterDecodeTaskForImageAndRef(
-    const DrawImage& draw_image,
-    scoped_refptr<TileTask>* task) {
-  return GetTaskForImageAndRefInternal(
-      draw_image, TracingInfo(), DecodeTaskType::STAND_ALONE_DECODE_TASK, task);
-}
-
-bool GpuImageDecodeCache::GetTaskForImageAndRefInternal(
-    const DrawImage& draw_image,
-    const TracingInfo& tracing_info,
-    DecodeTaskType task_type,
-    scoped_refptr<TileTask>* task) {
   TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
                "GpuImageDecodeCache::GetTaskForImageAndRef");
   if (SkipImage(draw_image)) {
@@ -427,18 +408,11 @@
     RefImage(draw_image);
     *task = nullptr;
     return true;
-  } else if (task_type == DecodeTaskType::PART_OF_UPLOAD_TASK &&
-             image_data->upload.task) {
+  } else if (image_data->upload.task) {
     // We had an existing upload task, ref the image and return the task.
     RefImage(draw_image);
     *task = image_data->upload.task;
     return true;
-  } else if (task_type == DecodeTaskType::STAND_ALONE_DECODE_TASK &&
-             image_data->decode.stand_alone_task) {
-    // We had an existing out of raster task, ref the image and return the task.
-    RefImage(draw_image);
-    *task = image_data->decode.stand_alone_task;
-    return true;
   }
 
   // Ensure that the image we're about to decode/upload will fit in memory.
@@ -453,18 +427,13 @@
   if (new_data)
     persistent_cache_.Put(image_id, std::move(new_data));
 
-  if (task_type == DecodeTaskType::PART_OF_UPLOAD_TASK) {
-    // Ref image and create a upload and decode tasks. We will release this ref
-    // in UploadTaskCompleted.
-    RefImage(draw_image);
-    *task = make_scoped_refptr(new ImageUploadTaskImpl(
-        this, draw_image,
-        GetImageDecodeTaskAndRef(draw_image, tracing_info, task_type),
-        tracing_info));
-    image_data->upload.task = *task;
-  } else {
-    *task = GetImageDecodeTaskAndRef(draw_image, tracing_info, task_type);
-  }
+  // Ref image and create a upload and decode tasks. We will release this ref
+  // in UploadTaskCompleted.
+  RefImage(draw_image);
+  *task = make_scoped_refptr(new ImageUploadTaskImpl(
+      this, draw_image, GetImageDecodeTaskAndRef(draw_image, tracing_info),
+      tracing_info));
+  image_data->upload.task = *task;
 
   // Ref the image again - this ref is owned by the caller, and it is their
   // responsibility to release it by calling UnrefImage.
@@ -678,22 +647,15 @@
 }
 
 void GpuImageDecodeCache::OnImageDecodeTaskCompleted(
-    const DrawImage& draw_image,
-    DecodeTaskType task_type) {
+    const DrawImage& draw_image) {
   TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
                "GpuImageDecodeCache::OnImageDecodeTaskCompleted");
   base::AutoLock lock(lock_);
   // Decode task is complete, remove our reference to it.
   ImageData* image_data = GetImageDataForDrawImage(draw_image);
   DCHECK(image_data);
-  if (task_type == DecodeTaskType::PART_OF_UPLOAD_TASK) {
-    DCHECK(image_data->decode.task);
-    image_data->decode.task = nullptr;
-  } else {
-    DCHECK(task_type == DecodeTaskType::STAND_ALONE_DECODE_TASK);
-    DCHECK(image_data->decode.stand_alone_task);
-    image_data->decode.stand_alone_task = nullptr;
-  }
+  DCHECK(image_data->decode.task);
+  image_data->decode.task = nullptr;
 
   // While the decode task is active, we keep a ref on the decoded data.
   // Release that ref now.
@@ -722,16 +684,14 @@
 // the requested decode.
 scoped_refptr<TileTask> GpuImageDecodeCache::GetImageDecodeTaskAndRef(
     const DrawImage& draw_image,
-    const TracingInfo& tracing_info,
-    DecodeTaskType task_type) {
+    const TracingInfo& tracing_info) {
   TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
                "GpuImageDecodeCache::GetImageDecodeTaskAndRef");
   lock_.AssertAcquired();
 
   // This ref is kept alive while an upload task may need this decode. We
   // release this ref in UploadTaskCompleted.
-  if (task_type == DecodeTaskType::PART_OF_UPLOAD_TASK)
-    RefImageDecode(draw_image);
+  RefImageDecode(draw_image);
 
   ImageData* image_data = GetImageDataForDrawImage(draw_image);
   DCHECK(image_data);
@@ -744,16 +704,13 @@
   }
 
   // We didn't have an existing locked image, create a task to lock or decode.
-  scoped_refptr<TileTask>& existing_task =
-      (task_type == DecodeTaskType::PART_OF_UPLOAD_TASK)
-          ? image_data->decode.task
-          : image_data->decode.stand_alone_task;
+  scoped_refptr<TileTask>& existing_task = image_data->decode.task;
   if (!existing_task) {
     // Ref image decode and create a decode task. This ref will be released in
     // DecodeTaskCompleted.
     RefImageDecode(draw_image);
     existing_task = make_scoped_refptr(
-        new ImageDecodeTaskImpl(this, draw_image, tracing_info, task_type));
+        new ImageDecodeTaskImpl(this, draw_image, tracing_info));
   }
   return existing_task;
 }
@@ -900,11 +857,10 @@
   // We should unlock the discardable memory for the image in two cases:
   // 1) The image is no longer being used (no decode or upload refs).
   // 2) This is a GPU backed image that has already been uploaded (no decode
-  //    refs, and we actually already have an image).
+  //    refs).
   bool should_unlock_discardable =
-      !has_any_refs ||
-      (image_data->mode == DecodedDataMode::GPU &&
-       !image_data->decode.ref_count && image_data->upload.image());
+      !has_any_refs || (image_data->mode == DecodedDataMode::GPU &&
+                        !image_data->decode.ref_count);
 
   if (should_unlock_discardable && image_data->decode.is_locked()) {
     DCHECK(image_data->decode.data());
diff --git a/cc/tiles/gpu_image_decode_cache.h b/cc/tiles/gpu_image_decode_cache.h
index 08dd6602..34f8dca 100644
--- a/cc/tiles/gpu_image_decode_cache.h
+++ b/cc/tiles/gpu_image_decode_cache.h
@@ -99,8 +99,6 @@
       public base::trace_event::MemoryDumpProvider,
       public base::MemoryCoordinatorClient {
  public:
-  enum class DecodeTaskType { PART_OF_UPLOAD_TASK, STAND_ALONE_DECODE_TASK };
-
   explicit GpuImageDecodeCache(ContextProvider* context,
                                ResourceFormat decode_format,
                                size_t max_gpu_image_bytes);
@@ -113,9 +111,6 @@
   bool GetTaskForImageAndRef(const DrawImage& image,
                              const TracingInfo& tracing_info,
                              scoped_refptr<TileTask>* task) override;
-  bool GetOutOfRasterDecodeTaskForImageAndRef(
-      const DrawImage& image,
-      scoped_refptr<TileTask>* task) override;
   void UnrefImage(const DrawImage& image) override;
   DecodedDrawImage GetDecodedImageForDraw(const DrawImage& draw_image) override;
   void DrawWithImageFinished(const DrawImage& image,
@@ -136,8 +131,7 @@
   void UploadImage(const DrawImage& image);
 
   // Called by Decode / Upload tasks when tasks are finished.
-  void OnImageDecodeTaskCompleted(const DrawImage& image,
-                                  DecodeTaskType task_type);
+  void OnImageDecodeTaskCompleted(const DrawImage& image);
   void OnImageUploadTaskCompleted(const DrawImage& image);
 
   // For testing only.
@@ -173,9 +167,6 @@
     bool decode_failure = false;
     // If non-null, this is the pending decode task for this image.
     scoped_refptr<TileTask> task;
-    // Similar to above, but only is generated if there is no associated upload
-    // generated for this task (ie, this is an out-of-raster request for decode.
-    scoped_refptr<TileTask> stand_alone_task;
 
    private:
     struct UsageStats {
@@ -271,15 +262,7 @@
   // rather than the upload task, if necessary.
   scoped_refptr<TileTask> GetImageDecodeTaskAndRef(
       const DrawImage& image,
-      const TracingInfo& tracing_info,
-      DecodeTaskType task_type);
-
-  // Note that this function behaves as if it was public (all of the same locks
-  // need to be acquired).
-  bool GetTaskForImageAndRefInternal(const DrawImage& image,
-                                     const TracingInfo& tracing_info,
-                                     DecodeTaskType task_type,
-                                     scoped_refptr<TileTask>* task);
+      const TracingInfo& tracing_info);
 
   void RefImageDecode(const DrawImage& draw_image);
   void UnrefImageDecode(const DrawImage& draw_image);
diff --git a/cc/tiles/gpu_image_decode_cache_unittest.cc b/cc/tiles/gpu_image_decode_cache_unittest.cc
index 34d2b29..072dfd9 100644
--- a/cc/tiles/gpu_image_decode_cache_unittest.cc
+++ b/cc/tiles/gpu_image_decode_cache_unittest.cc
@@ -497,7 +497,6 @@
   EXPECT_TRUE(need_unref);
   EXPECT_TRUE(task);
 
-  ASSERT_GT(task->dependencies().size(), 0u);
   TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
 
   scoped_refptr<TileTask> another_task;
@@ -510,10 +509,6 @@
   TestTileTaskRunner::CancelTask(task.get());
   TestTileTaskRunner::CompleteTask(task.get());
 
-  // 2 Unrefs, so that the decode is unlocked as well.
-  cache.UnrefImage(draw_image);
-  cache.UnrefImage(draw_image);
-
   // Note that here, everything is reffed, but a new task is created. This is
   // possible with repeated schedule/cancel operations.
   scoped_refptr<TileTask> third_task;
@@ -523,11 +518,12 @@
   EXPECT_TRUE(third_task);
   EXPECT_FALSE(third_task.get() == task.get());
 
-  ASSERT_GT(third_task->dependencies().size(), 0u);
   TestTileTaskRunner::ProcessTask(third_task->dependencies()[0].get());
   TestTileTaskRunner::ProcessTask(third_task.get());
 
-  // Unref!
+  // 3 Unrefs!
+  cache.UnrefImage(draw_image);
+  cache.UnrefImage(draw_image);
   cache.UnrefImage(draw_image);
 }
 
diff --git a/cc/tiles/image_controller.cc b/cc/tiles/image_controller.cc
index f0d1bb9..95729568 100644
--- a/cc/tiles/image_controller.cc
+++ b/cc/tiles/image_controller.cc
@@ -4,122 +4,15 @@
 
 #include "cc/tiles/image_controller.h"
 
-#include "base/bind.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/task_scheduler/task_traits.h"
-#include "base/threading/thread_restrictions.h"
-#include "base/trace_event/trace_event.h"
-#include "cc/base/completion_event.h"
-#include "cc/tiles/tile_task_manager.h"
-
 namespace cc {
 
-ImageController::ImageDecodeRequestId
-    ImageController::s_next_image_decode_queue_id_ = 1;
-
-ImageController::ImageController(
-    base::SequencedTaskRunner* origin_task_runner,
-    scoped_refptr<base::SequencedTaskRunner> worker_task_runner)
-    : origin_task_runner_(origin_task_runner),
-      worker_task_runner_(std::move(worker_task_runner)),
-      weak_ptr_factory_(this) {}
-
-ImageController::~ImageController() {
-  StopWorkerTasks();
-}
-
-void ImageController::StopWorkerTasks() {
-  // We can't have worker threads without a cache_ or a worker_task_runner_, so
-  // terminate early.
-  if (!cache_ || !worker_task_runner_)
-    return;
-
-  // Abort all tasks that are currently scheduled to run (we'll wait for them to
-  // finish next).
-  {
-    base::AutoLock hold(lock_);
-    abort_tasks_ = true;
-  }
-
-  // Post a task that will simply signal a completion event to ensure that we
-  // "flush" any scheduled tasks (they will abort).
-  CompletionEvent completion_event;
-  worker_task_runner_->PostTask(
-      FROM_HERE, base::Bind([](CompletionEvent* event) { event->Signal(); },
-                            base::Unretained(&completion_event)));
-  completion_event.Wait();
-
-  // Reset the abort flag so that new tasks can be scheduled.
-  {
-    base::AutoLock hold(lock_);
-    abort_tasks_ = false;
-  }
-
-  // Now that we flushed everything, if there was a task running and it
-  // finished, it would have posted a completion callback back to the compositor
-  // thread. We don't want that, so invalidate the weak ptrs again. Note that
-  // nothing can start running between wait and this invalidate, since it would
-  // only run on the current (compositor) thread.
-  weak_ptr_factory_.InvalidateWeakPtrs();
-
-  // Now, begin cleanup.
-
-  // Unlock all of the locked images (note that this vector would only be
-  // populated if we actually need to unref the image.
-  for (auto image_pair : requested_locked_images_)
-    cache_->UnrefImage(image_pair.second);
-  requested_locked_images_.clear();
-
-  // Now, complete the tasks that already ran but haven't completed. These would
-  // be posted in the run loop, but since we invalidated the weak ptrs, we need
-  // to run everything manually.
-  for (auto& request_to_complete : requests_needing_completion_) {
-    ImageDecodeRequestId id = request_to_complete.first;
-    ImageDecodeRequest& request = request_to_complete.second;
-
-    // The task (if one exists) would have run already, so we just need to
-    // complete it.
-    if (request.task)
-      request.task->DidComplete();
-
-    // Issue the callback, and unref the image immediately. This is so that any
-    // code waiting on the callback can proceed, although we're breaking the
-    // promise of having this image decoded. This is unfortunate, but it seems
-    // like the least complexity to process an image decode controller becoming
-    // nullptr.
-    request.callback.Run(id);
-    if (request.need_unref)
-      cache_->UnrefImage(request.draw_image);
-  }
-  requests_needing_completion_.clear();
-
-  // Finally, complete all of the tasks that never started running. This is
-  // similar to the |requests_needing_completion_|, but happens at a different
-  // stage in the pipeline.
-  for (auto& request_pair : image_decode_queue_) {
-    ImageDecodeRequestId id = request_pair.first;
-    ImageDecodeRequest& request = request_pair.second;
-
-    if (request.task) {
-      // This task may have run via a different request, so only cancel it if
-      // it's "new". That is, the same task could have been referenced by
-      // several different image deque requests for the same image.
-      if (request.task->state().IsNew())
-        request.task->state().DidCancel();
-      request.task->DidComplete();
-    }
-    // Run the callback and unref the image.
-    request.callback.Run(id);
-    cache_->UnrefImage(request.draw_image);
-  }
-  image_decode_queue_.clear();
-}
+ImageController::ImageController() = default;
+ImageController::~ImageController() = default;
 
 void ImageController::SetImageDecodeCache(ImageDecodeCache* cache) {
   if (!cache) {
     SetPredecodeImages(std::vector<DrawImage>(),
                        ImageDecodeCache::TracingInfo());
-    StopWorkerTasks();
   }
   cache_ = cache;
 }
@@ -163,155 +56,4 @@
   return new_tasks;
 }
 
-ImageController::ImageDecodeRequestId ImageController::QueueImageDecode(
-    sk_sp<const SkImage> image,
-    const ImageDecodedCallback& callback) {
-  // We must not receive any image requests if we have no worker.
-  CHECK(worker_task_runner_);
-
-  // Generate the next id.
-  ImageDecodeRequestId id = s_next_image_decode_queue_id_++;
-
-  DCHECK(image);
-  auto image_bounds = image->bounds();
-  DrawImage draw_image(std::move(image), image_bounds, kNone_SkFilterQuality,
-                       SkMatrix::I());
-
-  // Get the tasks for this decode.
-  scoped_refptr<TileTask> task;
-  bool need_unref =
-      cache_->GetOutOfRasterDecodeTaskForImageAndRef(draw_image, &task);
-  // If we don't need to unref this, we don't actually have a task.
-  DCHECK(need_unref || !task);
-
-  // Schedule the task and signal that there is more work.
-  base::AutoLock hold(lock_);
-  image_decode_queue_[id] =
-      ImageDecodeRequest(id, draw_image, callback, std::move(task), need_unref);
-
-  // If this is the only image decode request, schedule a task to run.
-  // Otherwise, the task will be scheduled in the previou task's completion.
-  if (image_decode_queue_.size() == 1) {
-    // Post a worker task.
-    worker_task_runner_->PostTask(
-        FROM_HERE,
-        base::Bind(&ImageController::ProcessNextImageDecodeOnWorkerThread,
-                   base::Unretained(this)));
-  }
-
-  return id;
-}
-
-void ImageController::UnlockImageDecode(ImageDecodeRequestId id) {
-  // If the image exists, ie we actually need to unlock it, then do so.
-  auto it = requested_locked_images_.find(id);
-  if (it == requested_locked_images_.end())
-    return;
-
-  UnrefImages({it->second});
-  requested_locked_images_.erase(it);
-}
-
-void ImageController::ProcessNextImageDecodeOnWorkerThread() {
-  TRACE_EVENT0("cc", "ImageController::ProcessNextImageDecodeOnWorkerThread");
-  ImageDecodeRequest decode;
-  {
-    base::AutoLock hold(lock_);
-
-    // If we don't have any work, abort.
-    if (image_decode_queue_.empty() || abort_tasks_)
-      return;
-
-    // Take the next request from the queue.
-    auto decode_it = image_decode_queue_.begin();
-    DCHECK(decode_it != image_decode_queue_.end());
-    decode = std::move(decode_it->second);
-    image_decode_queue_.erase(decode_it);
-
-    // Notify that the task will need completion. Note that there are two cases
-    // where we process this. First, we might complete this task as a response
-    // to the posted task below. Second, we might complete it in
-    // StopWorkerTasks(). In either case, the task would have already run
-    // (either post task happens after running, or the thread was already joined
-    // which means the task ran). This means that we can put the decode into
-    // |requests_needing_completion_| here before actually running the task.
-    requests_needing_completion_[decode.id] = decode;
-  }
-
-  // Run the task if we need to run it. If the task state isn't new, then
-  // there is another task that is responsible for finishing it and cleaning
-  // up (and it already ran); we just need to post a completion callback.
-  // Note that the other tasks's completion will also run first, since the
-  // requests are ordered. So, when we process this task's completion, we
-  // won't actually do anything with the task and simply issue the callback.
-  if (decode.task && decode.task->state().IsNew()) {
-    decode.task->state().DidSchedule();
-    decode.task->state().DidStart();
-    decode.task->RunOnWorkerThread();
-    decode.task->state().DidFinish();
-  }
-  origin_task_runner_->PostTask(
-      FROM_HERE, base::Bind(&ImageController::ImageDecodeCompleted,
-                            weak_ptr_factory_.GetWeakPtr(), decode.id));
-}
-
-void ImageController::ImageDecodeCompleted(ImageDecodeRequestId id) {
-  ImageDecodedCallback callback;
-  {
-    base::AutoLock hold(lock_);
-
-    auto request_it = requests_needing_completion_.find(id);
-    DCHECK(request_it != requests_needing_completion_.end());
-    id = request_it->first;
-    ImageDecodeRequest& request = request_it->second;
-
-    // If we need to unref this decode, then we have to put it into the locked
-    // images vector.
-    if (request.need_unref)
-      requested_locked_images_[id] = std::move(request.draw_image);
-
-    // If we have a task that isn't completed yet, we need to complete it.
-    if (request.task && !request.task->HasCompleted()) {
-      request.task->OnTaskCompleted();
-      request.task->DidComplete();
-    }
-    // Finally, save the callback so we can run it without the lock, and erase
-    // the request from |requests_needing_completion_|.
-    callback = std::move(request.callback);
-    requests_needing_completion_.erase(request_it);
-  }
-
-  // Post another task to run.
-  worker_task_runner_->PostTask(
-      FROM_HERE,
-      base::Bind(&ImageController::ProcessNextImageDecodeOnWorkerThread,
-                 base::Unretained(this)));
-
-  // Finally run the requested callback.
-  callback.Run(id);
-}
-
-ImageController::ImageDecodeRequest::ImageDecodeRequest() = default;
-ImageController::ImageDecodeRequest::ImageDecodeRequest(
-    ImageDecodeRequestId id,
-    const DrawImage& draw_image,
-    const ImageDecodedCallback& callback,
-    scoped_refptr<TileTask> task,
-    bool need_unref)
-    : id(id),
-      draw_image(draw_image),
-      callback(callback),
-      task(std::move(task)),
-      need_unref(need_unref) {}
-ImageController::ImageDecodeRequest::ImageDecodeRequest(
-    ImageDecodeRequest&& other) = default;
-ImageController::ImageDecodeRequest::ImageDecodeRequest(
-    const ImageDecodeRequest& other) = default;
-ImageController::ImageDecodeRequest::~ImageDecodeRequest() = default;
-
-ImageController::ImageDecodeRequest& ImageController::ImageDecodeRequest::
-operator=(ImageDecodeRequest&& other) = default;
-ImageController::ImageDecodeRequest& ImageController::ImageDecodeRequest::
-operator=(const ImageDecodeRequest& other) = default;
-
 }  // namespace cc
diff --git a/cc/tiles/image_controller.h b/cc/tiles/image_controller.h
index 7fb45b8..d64282f8e 100644
--- a/cc/tiles/image_controller.h
+++ b/cc/tiles/image_controller.h
@@ -5,15 +5,11 @@
 #ifndef CC_TILES_IMAGE_CONTROLLER_H_
 #define CC_TILES_IMAGE_CONTROLLER_H_
 
-#include <set>
 #include <vector>
 
 #include "base/macros.h"
 #include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/simple_thread.h"
 #include "cc/base/cc_export.h"
-#include "cc/base/unique_notifier.h"
 #include "cc/playback/draw_image.h"
 #include "cc/raster/tile_task.h"
 #include "cc/tiles/image_decode_cache.h"
@@ -22,12 +18,8 @@
 
 class CC_EXPORT ImageController {
  public:
-  using ImageDecodeRequestId = uint64_t;
-  using ImageDecodedCallback = base::Callback<void(ImageDecodeRequestId)>;
-  explicit ImageController(
-      base::SequencedTaskRunner* origin_task_runner,
-      scoped_refptr<base::SequencedTaskRunner> worker_task_runner);
-  virtual ~ImageController();
+  ImageController();
+  ~ImageController();
 
   void SetImageDecodeCache(ImageDecodeCache* cache);
   void GetTasksForImagesAndRef(
@@ -40,66 +32,10 @@
       std::vector<DrawImage> predecode_images,
       const ImageDecodeCache::TracingInfo& tracing_info);
 
-  // Virtual for testing.
-  virtual void UnlockImageDecode(ImageDecodeRequestId id);
-
-  // This function requests that the given image be decoded and locked. Once the
-  // callback has been issued, it is passed an ID, which should be used to
-  // unlock this image. It is up to the caller to ensure that the image is later
-  // unlocked using UnlockImageDecode.
-  // Virtual for testing.
-  virtual ImageDecodeRequestId QueueImageDecode(
-      sk_sp<const SkImage> image,
-      const ImageDecodedCallback& callback);
-
  private:
-  struct ImageDecodeRequest {
-    ImageDecodeRequest();
-    ImageDecodeRequest(ImageDecodeRequestId id,
-                       const DrawImage& draw_image,
-                       const ImageDecodedCallback& callback,
-                       scoped_refptr<TileTask> task,
-                       bool need_unref);
-    ImageDecodeRequest(ImageDecodeRequest&& other);
-    ImageDecodeRequest(const ImageDecodeRequest& other);
-    ~ImageDecodeRequest();
-
-    ImageDecodeRequest& operator=(ImageDecodeRequest&& other);
-    ImageDecodeRequest& operator=(const ImageDecodeRequest& other);
-
-    ImageDecodeRequestId id;
-    DrawImage draw_image;
-    ImageDecodedCallback callback;
-    scoped_refptr<TileTask> task;
-    bool need_unref;
-  };
-
-  void StopWorkerTasks();
-
-  // Called from the worker thread.
-  void ProcessNextImageDecodeOnWorkerThread();
-
-  void ImageDecodeCompleted(ImageDecodeRequestId id);
-
   ImageDecodeCache* cache_ = nullptr;
   std::vector<DrawImage> predecode_locked_images_;
 
-  static ImageDecodeRequestId s_next_image_decode_queue_id_;
-  std::unordered_map<ImageDecodeRequestId, DrawImage> requested_locked_images_;
-
-  base::SequencedTaskRunner* origin_task_runner_ = nullptr;
-  scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
-
-  // The variables defined below this lock (aside from weak_ptr_factory_) can
-  // only be accessed when the lock is acquired.
-  base::Lock lock_;
-  std::map<ImageDecodeRequestId, ImageDecodeRequest> image_decode_queue_;
-  std::map<ImageDecodeRequestId, ImageDecodeRequest>
-      requests_needing_completion_;
-  bool abort_tasks_ = false;
-
-  base::WeakPtrFactory<ImageController> weak_ptr_factory_;
-
   DISALLOW_COPY_AND_ASSIGN(ImageController);
 };
 
diff --git a/cc/tiles/image_controller_unittest.cc b/cc/tiles/image_controller_unittest.cc
index 945dce0..fd9841c 100644
--- a/cc/tiles/image_controller_unittest.cc
+++ b/cc/tiles/image_controller_unittest.cc
@@ -2,102 +2,18 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/bind.h"
-#include "base/optional.h"
-#include "base/run_loop.h"
-#include "base/test/test_simple_task_runner.h"
-#include "base/threading/sequenced_task_runner_handle.h"
 #include "cc/tiles/image_controller.h"
 #include "cc/tiles/image_decode_cache.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace cc {
-namespace {
 
-class TestWorkerThread : public base::SimpleThread {
- public:
-  TestWorkerThread()
-      : base::SimpleThread("test_worker_thread"), condition_(&lock_) {}
-
-  void Run() override {
-    for (;;) {
-      base::AutoLock hold(lock_);
-      if (shutdown_)
-        break;
-
-      if (queue_.empty()) {
-        condition_.Wait();
-        continue;
-      }
-
-      queue_.front().Run();
-      queue_.erase(queue_.begin());
-    }
-  }
-
-  void Shutdown() {
-    base::AutoLock hold(lock_);
-    shutdown_ = true;
-    condition_.Signal();
-  }
-
-  void PostTask(const base::Closure& task) {
-    base::AutoLock hold(lock_);
-    queue_.push_back(task);
-    condition_.Signal();
-  }
-
- private:
-  base::Lock lock_;
-  base::ConditionVariable condition_;
-  std::vector<base::Closure> queue_;
-  bool shutdown_ = false;
-};
-
-class WorkerTaskRunner : public base::SequencedTaskRunner {
- public:
-  WorkerTaskRunner() { thread_.Start(); }
-
-  bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
-                                  const base::Closure& task,
-                                  base::TimeDelta delay) override {
-    return PostDelayedTask(from_here, task, delay);
-  }
-
-  bool PostDelayedTask(const tracked_objects::Location& from_here,
-                       const base::Closure& task,
-                       base::TimeDelta delay) override {
-    thread_.PostTask(task);
-    return true;
-  }
-
-  bool RunsTasksOnCurrentThread() const override { return false; }
-
- protected:
-  ~WorkerTaskRunner() override {
-    thread_.Shutdown();
-    thread_.Join();
-  }
-
-  TestWorkerThread thread_;
-};
-
-// Image decode cache with introspection!
 class TestableCache : public ImageDecodeCache {
  public:
-  ~TestableCache() override { EXPECT_EQ(number_of_refs_, 0); }
-
   bool GetTaskForImageAndRef(const DrawImage& image,
                              const TracingInfo& tracing_info,
                              scoped_refptr<TileTask>* task) override {
-    *task = task_to_use_;
-    ++number_of_refs_;
-    return true;
-  }
-  bool GetOutOfRasterDecodeTaskForImageAndRef(
-      const DrawImage& image,
-      scoped_refptr<TileTask>* task) override {
-    *task = task_to_use_;
+    *task = nullptr;
     ++number_of_refs_;
     return true;
   }
@@ -116,333 +32,26 @@
       bool aggressively_free_resources) override {}
 
   int number_of_refs() const { return number_of_refs_; }
-  void SetTaskToUse(scoped_refptr<TileTask> task) { task_to_use_ = task; }
 
  private:
   int number_of_refs_ = 0;
-  scoped_refptr<TileTask> task_to_use_;
 };
 
-// A simple class that can receive decode callbacks.
-class DecodeClient {
- public:
-  DecodeClient() {}
-  void Callback(const base::Closure& quit_closure,
-                ImageController::ImageDecodeRequestId id) {
-    id_ = id;
-    quit_closure.Run();
-  }
+TEST(ImageControllerTest, NullCacheUnrefsImages) {
+  TestableCache cache;
+  ImageController controller;
+  controller.SetImageDecodeCache(&cache);
 
-  ImageController::ImageDecodeRequestId id() { return id_; }
-
- private:
-  ImageController::ImageDecodeRequestId id_ = 0;
-};
-
-// A dummy task that does nothing.
-class SimpleTask : public TileTask {
- public:
-  SimpleTask() : TileTask(true /* supports_concurrent_execution */) {
-    EXPECT_TRUE(thread_checker_.CalledOnValidThread());
-  }
-
-  void RunOnWorkerThread() override {
-    EXPECT_FALSE(HasCompleted());
-    EXPECT_FALSE(thread_checker_.CalledOnValidThread());
-    has_run_ = true;
-  }
-  void OnTaskCompleted() override {
-    EXPECT_TRUE(thread_checker_.CalledOnValidThread());
-  }
-
-  bool has_run() { return has_run_; }
-
- private:
-  ~SimpleTask() override = default;
-
-  base::ThreadChecker thread_checker_;
-  bool has_run_ = false;
-
-  DISALLOW_COPY_AND_ASSIGN(SimpleTask);
-};
-
-// A task that blocks until instructed otherwise.
-class BlockingTask : public TileTask {
- public:
-  BlockingTask()
-      : TileTask(true /* supports_concurrent_execution */), run_cv_(&lock_) {
-    EXPECT_TRUE(thread_checker_.CalledOnValidThread());
-  }
-
-  void RunOnWorkerThread() override {
-    EXPECT_FALSE(HasCompleted());
-    EXPECT_FALSE(thread_checker_.CalledOnValidThread());
-    base::AutoLock hold(lock_);
-    if (!can_run_)
-      run_cv_.Wait();
-    has_run_ = true;
-  }
-
-  void OnTaskCompleted() override {
-    EXPECT_TRUE(thread_checker_.CalledOnValidThread());
-  }
-
-  void AllowToRun() {
-    base::AutoLock hold(lock_);
-    can_run_ = true;
-    run_cv_.Signal();
-  }
-
-  bool has_run() { return has_run_; }
-
- private:
-  ~BlockingTask() override = default;
-
-  base::ThreadChecker thread_checker_;
-  bool has_run_ = false;
-  base::Lock lock_;
-  base::ConditionVariable run_cv_;
-  bool can_run_ = false;
-
-  DISALLOW_COPY_AND_ASSIGN(BlockingTask);
-};
-
-// For tests that exercise image controller's thread, this is the timeout value
-// to
-// allow the worker thread to do its work.
-int kDefaultTimeoutSeconds = 10;
-
-class ImageControllerTest : public testing::Test {
- public:
-  ImageControllerTest() : task_runner_(base::SequencedTaskRunnerHandle::Get()) {
-    bitmap_.allocN32Pixels(1, 1);
-    image_ = SkImage::MakeFromBitmap(bitmap_);
-  }
-  ~ImageControllerTest() override = default;
-
-  void SetUp() override {
-    worker_task_runner_ = make_scoped_refptr(new WorkerTaskRunner);
-    controller_.reset(
-        new ImageController(task_runner_.get(), worker_task_runner_));
-    cache_ = TestableCache();
-    controller_->SetImageDecodeCache(&cache_);
-  }
-
-  void TearDown() override {
-    controller_.reset();
-    worker_task_runner_ = nullptr;
-  }
-
-  base::SequencedTaskRunner* task_runner() { return task_runner_.get(); }
-  ImageController* controller() { return controller_.get(); }
-  TestableCache* cache() { return &cache_; }
-  sk_sp<const SkImage> image() const { return image_; }
-
-  // Timeout callback, which errors and exits the runloop.
-  static void Timeout(base::RunLoop* run_loop) {
-    ADD_FAILURE() << "Timeout.";
-    run_loop->Quit();
-  }
-
-  // Convenience method to run the run loop with a timeout.
-  void RunOrTimeout(base::RunLoop* run_loop) {
-    task_runner_->PostDelayedTask(
-        FROM_HERE,
-        base::Bind(&ImageControllerTest::Timeout, base::Unretained(run_loop)),
-        base::TimeDelta::FromSeconds(kDefaultTimeoutSeconds));
-    run_loop->Run();
-  }
-
- private:
-  scoped_refptr<base::SequencedTaskRunner> task_runner_;
-  scoped_refptr<WorkerTaskRunner> worker_task_runner_;
-  TestableCache cache_;
-  std::unique_ptr<ImageController> controller_;
-  SkBitmap bitmap_;
-  sk_sp<const SkImage> image_;
-};
-
-TEST_F(ImageControllerTest, NullControllerUnrefsImages) {
   std::vector<DrawImage> images(10);
   ImageDecodeCache::TracingInfo tracing_info;
 
   ASSERT_EQ(10u, images.size());
-  auto tasks =
-      controller()->SetPredecodeImages(std::move(images), tracing_info);
+  auto tasks = controller.SetPredecodeImages(std::move(images), tracing_info);
   EXPECT_EQ(0u, tasks.size());
-  EXPECT_EQ(10, cache()->number_of_refs());
+  EXPECT_EQ(10, cache.number_of_refs());
 
-  controller()->SetImageDecodeCache(nullptr);
-  EXPECT_EQ(0, cache()->number_of_refs());
+  controller.SetImageDecodeCache(nullptr);
+  EXPECT_EQ(0, cache.number_of_refs());
 }
 
-TEST_F(ImageControllerTest, QueueImageDecode) {
-  base::RunLoop run_loop;
-  DecodeClient decode_client;
-  EXPECT_EQ(image()->bounds().width(), 1);
-  ImageController::ImageDecodeRequestId expected_id =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client),
-                     run_loop.QuitClosure()));
-  RunOrTimeout(&run_loop);
-  EXPECT_EQ(expected_id, decode_client.id());
-}
-
-TEST_F(ImageControllerTest, QueueImageDecodeMultipleImages) {
-  base::RunLoop run_loop;
-  DecodeClient decode_client1;
-  ImageController::ImageDecodeRequestId expected_id1 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client1),
-                     base::Bind([] {})));
-  DecodeClient decode_client2;
-  ImageController::ImageDecodeRequestId expected_id2 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client2),
-                     base::Bind([] {})));
-  DecodeClient decode_client3;
-  ImageController::ImageDecodeRequestId expected_id3 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client3),
-                     run_loop.QuitClosure()));
-  RunOrTimeout(&run_loop);
-  EXPECT_EQ(expected_id1, decode_client1.id());
-  EXPECT_EQ(expected_id2, decode_client2.id());
-  EXPECT_EQ(expected_id3, decode_client3.id());
-}
-
-TEST_F(ImageControllerTest, QueueImageDecodeWithTask) {
-  scoped_refptr<SimpleTask> task(new SimpleTask);
-  cache()->SetTaskToUse(task);
-
-  base::RunLoop run_loop;
-  DecodeClient decode_client;
-  ImageController::ImageDecodeRequestId expected_id =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client),
-                     run_loop.QuitClosure()));
-  RunOrTimeout(&run_loop);
-  EXPECT_EQ(expected_id, decode_client.id());
-  EXPECT_TRUE(task->has_run());
-  EXPECT_TRUE(task->HasCompleted());
-}
-
-TEST_F(ImageControllerTest, QueueImageDecodeMultipleImagesSameTask) {
-  scoped_refptr<SimpleTask> task(new SimpleTask);
-  cache()->SetTaskToUse(task);
-
-  base::RunLoop run_loop;
-  DecodeClient decode_client1;
-  ImageController::ImageDecodeRequestId expected_id1 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client1),
-                     base::Bind([] {})));
-  DecodeClient decode_client2;
-  ImageController::ImageDecodeRequestId expected_id2 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client2),
-                     base::Bind([] {})));
-  DecodeClient decode_client3;
-  ImageController::ImageDecodeRequestId expected_id3 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client3),
-                     run_loop.QuitClosure()));
-  RunOrTimeout(&run_loop);
-  EXPECT_EQ(expected_id1, decode_client1.id());
-  EXPECT_EQ(expected_id2, decode_client2.id());
-  EXPECT_EQ(expected_id3, decode_client3.id());
-  EXPECT_TRUE(task->has_run());
-  EXPECT_TRUE(task->HasCompleted());
-}
-
-TEST_F(ImageControllerTest, QueueImageDecodeChangeControllerWithTaskQueued) {
-  scoped_refptr<BlockingTask> task_one(new BlockingTask);
-  cache()->SetTaskToUse(task_one);
-
-  DecodeClient decode_client1;
-  ImageController::ImageDecodeRequestId expected_id1 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client1),
-                     base::Bind([] {})));
-
-  scoped_refptr<BlockingTask> task_two(new BlockingTask);
-  cache()->SetTaskToUse(task_two);
-
-  base::RunLoop run_loop;
-  DecodeClient decode_client2;
-  ImageController::ImageDecodeRequestId expected_id2 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client2),
-                     run_loop.QuitClosure()));
-
-  task_one->AllowToRun();
-  task_two->AllowToRun();
-  controller()->SetImageDecodeCache(nullptr);
-
-  RunOrTimeout(&run_loop);
-
-  EXPECT_TRUE(task_one->state().IsCanceled() || task_one->HasCompleted());
-  EXPECT_TRUE(task_two->state().IsCanceled() || task_two->HasCompleted());
-  EXPECT_EQ(expected_id1, decode_client1.id());
-  EXPECT_EQ(expected_id2, decode_client2.id());
-}
-
-TEST_F(ImageControllerTest, QueueImageDecodeImageAlreadyLocked) {
-  scoped_refptr<SimpleTask> task(new SimpleTask);
-  cache()->SetTaskToUse(task);
-
-  base::RunLoop run_loop1;
-  DecodeClient decode_client1;
-  ImageController::ImageDecodeRequestId expected_id1 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client1),
-                     run_loop1.QuitClosure()));
-  RunOrTimeout(&run_loop1);
-  EXPECT_EQ(expected_id1, decode_client1.id());
-  EXPECT_TRUE(task->has_run());
-
-  cache()->SetTaskToUse(nullptr);
-  base::RunLoop run_loop2;
-  DecodeClient decode_client2;
-  ImageController::ImageDecodeRequestId expected_id2 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client2),
-                     run_loop2.QuitClosure()));
-  RunOrTimeout(&run_loop2);
-  EXPECT_EQ(expected_id2, decode_client2.id());
-}
-
-TEST_F(ImageControllerTest, QueueImageDecodeLockedImageControllerChange) {
-  scoped_refptr<SimpleTask> task(new SimpleTask);
-  cache()->SetTaskToUse(task);
-
-  base::RunLoop run_loop1;
-  DecodeClient decode_client1;
-  ImageController::ImageDecodeRequestId expected_id1 =
-      controller()->QueueImageDecode(
-          image(),
-          base::Bind(&DecodeClient::Callback, base::Unretained(&decode_client1),
-                     run_loop1.QuitClosure()));
-  RunOrTimeout(&run_loop1);
-  EXPECT_EQ(expected_id1, decode_client1.id());
-  EXPECT_TRUE(task->has_run());
-  EXPECT_EQ(1, cache()->number_of_refs());
-
-  controller()->SetImageDecodeCache(nullptr);
-  EXPECT_EQ(0, cache()->number_of_refs());
-}
-
-}  // namespace
 }  // namespace cc
diff --git a/cc/tiles/image_decode_cache.h b/cc/tiles/image_decode_cache.h
index 4cba352d..d20ed37 100644
--- a/cc/tiles/image_decode_cache.h
+++ b/cc/tiles/image_decode_cache.h
@@ -61,15 +61,6 @@
   virtual bool GetTaskForImageAndRef(const DrawImage& image,
                                      const TracingInfo& tracing_info,
                                      scoped_refptr<TileTask>* task) = 0;
-  // Similar to GetTaskForImageAndRef, except that it returns tasks that are not
-  // meant to be run as part of raster. That is, this is part of a predecode
-  // API. Note that this should only return a task responsible for decoding (and
-  // not uploading), since it will be run on a worker thread which may not have
-  // the right GPU context for upload.
-  virtual bool GetOutOfRasterDecodeTaskForImageAndRef(
-      const DrawImage& image,
-      scoped_refptr<TileTask>* task) = 0;
-
   // Unrefs an image. When the tile is finished, this should be called for every
   // GetTaskForImageAndRef call that returned true.
   virtual void UnrefImage(const DrawImage& image) = 0;
diff --git a/cc/tiles/software_image_decode_cache.cc b/cc/tiles/software_image_decode_cache.cc
index aa206659..a69e1bc 100644
--- a/cc/tiles/software_image_decode_cache.cc
+++ b/cc/tiles/software_image_decode_cache.cc
@@ -94,13 +94,11 @@
   ImageDecodeTaskImpl(SoftwareImageDecodeCache* cache,
                       const SoftwareImageDecodeCache::ImageKey& image_key,
                       const DrawImage& image,
-                      const SoftwareImageDecodeCache::DecodeTaskType task_type,
                       const ImageDecodeCache::TracingInfo& tracing_info)
       : TileTask(true),
         cache_(cache),
         image_key_(image_key),
         image_(image),
-        task_type_(task_type),
         tracing_info_(tracing_info) {}
 
   // Overridden from Task:
@@ -111,13 +109,11 @@
     devtools_instrumentation::ScopedImageDecodeTask image_decode_task(
         image_.image().get(),
         devtools_instrumentation::ScopedImageDecodeTask::SOFTWARE);
-    cache_->DecodeImage(image_key_, image_, task_type_);
+    cache_->DecodeImage(image_key_, image_);
   }
 
   // Overridden from TileTask:
-  void OnTaskCompleted() override {
-    cache_->RemovePendingTask(image_key_, task_type_);
-  }
+  void OnTaskCompleted() override { cache_->RemovePendingTask(image_key_); }
 
  protected:
   ~ImageDecodeTaskImpl() override {}
@@ -126,7 +122,6 @@
   SoftwareImageDecodeCache* cache_;
   SoftwareImageDecodeCache::ImageKey image_key_;
   DrawImage image_;
-  SoftwareImageDecodeCache::DecodeTaskType task_type_;
   const ImageDecodeCache::TracingInfo tracing_info_;
 
   DISALLOW_COPY_AND_ASSIGN(ImageDecodeTaskImpl);
@@ -213,22 +208,6 @@
     const DrawImage& image,
     const TracingInfo& tracing_info,
     scoped_refptr<TileTask>* task) {
-  return GetTaskForImageAndRefInternal(
-      image, tracing_info, DecodeTaskType::USE_IN_RASTER_TASKS, task);
-}
-
-bool SoftwareImageDecodeCache::GetOutOfRasterDecodeTaskForImageAndRef(
-    const DrawImage& image,
-    scoped_refptr<TileTask>* task) {
-  return GetTaskForImageAndRefInternal(
-      image, TracingInfo(), DecodeTaskType::USE_OUT_OF_RASTER_TASKS, task);
-}
-
-bool SoftwareImageDecodeCache::GetTaskForImageAndRefInternal(
-    const DrawImage& image,
-    const TracingInfo& tracing_info,
-    DecodeTaskType task_type,
-    scoped_refptr<TileTask>* task) {
   // If the image already exists or if we're going to create a task for it, then
   // we'll likely need to ref this image (the exception is if we're prerolling
   // the image only). That means the image is or will be in the cache. When the
@@ -279,15 +258,8 @@
     }
   }
 
-  DCHECK(task_type == DecodeTaskType::USE_IN_RASTER_TASKS ||
-         task_type == DecodeTaskType::USE_OUT_OF_RASTER_TASKS);
-  // If the task exists, return it. Note that if we always need to create a new
-  // task, then just set |existing_task| to reference the passed in task (which
-  // is set to nullptr above).
-  scoped_refptr<TileTask>& existing_task =
-      (task_type == DecodeTaskType::USE_IN_RASTER_TASKS)
-          ? pending_in_raster_image_tasks_[key]
-          : pending_out_of_raster_image_tasks_[key];
+  // If the task exists, return it.
+  scoped_refptr<TileTask>& existing_task = pending_image_tasks_[key];
   if (existing_task) {
     RefImage(key);
     *task = existing_task;
@@ -311,7 +283,7 @@
   // ref.
   RefImage(key);
   existing_task = make_scoped_refptr(
-      new ImageDecodeTaskImpl(this, key, image, task_type, tracing_info));
+      new ImageDecodeTaskImpl(this, key, image, tracing_info));
   *task = existing_task;
   SanityCheckState(__LINE__, true);
   return true;
@@ -362,16 +334,11 @@
 }
 
 void SoftwareImageDecodeCache::DecodeImage(const ImageKey& key,
-                                           const DrawImage& image,
-                                           DecodeTaskType task_type) {
+                                           const DrawImage& image) {
   TRACE_EVENT1("cc", "SoftwareImageDecodeCache::DecodeImage", "key",
                key.ToString());
   base::AutoLock lock(lock_);
-  AutoRemoveKeyFromTaskMap remove_key_from_task_map(
-      (task_type == DecodeTaskType::USE_IN_RASTER_TASKS)
-          ? &pending_in_raster_image_tasks_
-          : &pending_out_of_raster_image_tasks_,
-      key);
+  AutoRemoveKeyFromTaskMap remove_key_from_task_map(&pending_image_tasks_, key);
 
   // We could have finished all of the raster tasks (cancelled) while the task
   // was just starting to run. Since this task already started running, it
@@ -801,17 +768,9 @@
   }
 }
 
-void SoftwareImageDecodeCache::RemovePendingTask(const ImageKey& key,
-                                                 DecodeTaskType task_type) {
+void SoftwareImageDecodeCache::RemovePendingTask(const ImageKey& key) {
   base::AutoLock lock(lock_);
-  switch (task_type) {
-    case DecodeTaskType::USE_IN_RASTER_TASKS:
-      pending_in_raster_image_tasks_.erase(key);
-      break;
-    case DecodeTaskType::USE_OUT_OF_RASTER_TASKS:
-      pending_out_of_raster_image_tasks_.erase(key);
-      break;
-  }
+  pending_image_tasks_.erase(key);
 }
 
 bool SoftwareImageDecodeCache::OnMemoryDump(
@@ -878,10 +837,7 @@
       DCHECK(ref_it != decoded_images_ref_counts_.end()) << line;
     } else {
       DCHECK(ref_it == decoded_images_ref_counts_.end() ||
-             pending_in_raster_image_tasks_.find(key) !=
-                 pending_in_raster_image_tasks_.end() ||
-             pending_out_of_raster_image_tasks_.find(key) !=
-                 pending_out_of_raster_image_tasks_.end())
+             pending_image_tasks_.find(key) != pending_image_tasks_.end())
           << line;
     }
   }
diff --git a/cc/tiles/software_image_decode_cache.h b/cc/tiles/software_image_decode_cache.h
index 1f3d72f..9befb55 100644
--- a/cc/tiles/software_image_decode_cache.h
+++ b/cc/tiles/software_image_decode_cache.h
@@ -109,8 +109,6 @@
   using ImageKey = ImageDecodeCacheKey;
   using ImageKeyHash = ImageDecodeCacheKeyHash;
 
-  enum class DecodeTaskType { USE_IN_RASTER_TASKS, USE_OUT_OF_RASTER_TASKS };
-
   SoftwareImageDecodeCache(ResourceFormat format,
                            size_t locked_memory_limit_bytes);
   ~SoftwareImageDecodeCache() override;
@@ -119,9 +117,6 @@
   bool GetTaskForImageAndRef(const DrawImage& image,
                              const TracingInfo& tracing_info,
                              scoped_refptr<TileTask>* task) override;
-  bool GetOutOfRasterDecodeTaskForImageAndRef(
-      const DrawImage& image,
-      scoped_refptr<TileTask>* task) override;
   void UnrefImage(const DrawImage& image) override;
   DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) override;
   void DrawWithImageFinished(const DrawImage& image,
@@ -133,11 +128,9 @@
 
   // Decode the given image and store it in the cache. This is only called by an
   // image decode task from a worker thread.
-  void DecodeImage(const ImageKey& key,
-                   const DrawImage& image,
-                   DecodeTaskType task_type);
+  void DecodeImage(const ImageKey& key, const DrawImage& image);
 
-  void RemovePendingTask(const ImageKey& key, DecodeTaskType task_type);
+  void RemovePendingTask(const ImageKey& key);
 
   // MemoryDumpProvider overrides.
   bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
@@ -274,17 +267,8 @@
   // Overriden from base::MemoryCoordinatorClient.
   void OnMemoryStateChange(base::MemoryState state) override;
 
-  // Helper method to get the different tasks. Note that this should be used as
-  // if it was public (ie, all of the locks need to be properly acquired).
-  bool GetTaskForImageAndRefInternal(const DrawImage& image,
-                                     const TracingInfo& tracing_info,
-                                     DecodeTaskType type,
-                                     scoped_refptr<TileTask>* task);
-
   std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash>
-      pending_in_raster_image_tasks_;
-  std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash>
-      pending_out_of_raster_image_tasks_;
+      pending_image_tasks_;
 
   // The members below this comment can only be accessed if the lock is held to
   // ensure that they are safe to access on multiple threads.
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index 02cffea..1e948f1e 100644
--- a/cc/tiles/tile_manager.cc
+++ b/cc/tiles/tile_manager.cc
@@ -342,15 +342,13 @@
   return std::move(state);
 }
 
-TileManager::TileManager(
-    TileManagerClient* client,
-    base::SequencedTaskRunner* origin_task_runner,
-    scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner,
-    size_t scheduled_raster_task_limit,
-    bool use_partial_raster,
-    bool check_tile_priority_inversion)
+TileManager::TileManager(TileManagerClient* client,
+                         base::SequencedTaskRunner* task_runner,
+                         size_t scheduled_raster_task_limit,
+                         bool use_partial_raster,
+                         bool check_tile_priority_inversion)
     : client_(client),
-      task_runner_(origin_task_runner),
+      task_runner_(task_runner),
       resource_pool_(nullptr),
       tile_task_manager_(nullptr),
       scheduled_raster_task_limit_(scheduled_raster_task_limit),
@@ -359,8 +357,6 @@
       all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
       did_check_for_completed_tasks_since_last_schedule_tasks_(true),
       did_oom_on_last_assign_(false),
-      image_controller_(origin_task_runner,
-                        std::move(image_worker_task_runner)),
       more_tiles_need_prepare_check_notifier_(
           task_runner_,
           base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared,
@@ -1068,13 +1064,6 @@
   client_->NotifyTileStateChanged(tile);
 }
 
-void TileManager::SetDecodedImageTracker(
-    DecodedImageTracker* decoded_image_tracker) {
-  // TODO(vmpstr): If the tile manager needs to request out-of-raster decodes,
-  // it should retain and use |decoded_image_tracker| here.
-  decoded_image_tracker->set_image_controller(&image_controller_);
-}
-
 std::unique_ptr<Tile> TileManager::CreateTile(const Tile::CreateInfo& info,
                                               int layer_id,
                                               int source_frame_number,
diff --git a/cc/tiles/tile_manager.h b/cc/tiles/tile_manager.h
index ea71587b..91ae0a8b 100644
--- a/cc/tiles/tile_manager.h
+++ b/cc/tiles/tile_manager.h
@@ -21,7 +21,6 @@
 #include "cc/raster/raster_buffer_provider.h"
 #include "cc/resources/memory_history.h"
 #include "cc/resources/resource_pool.h"
-#include "cc/tiles/decoded_image_tracker.h"
 #include "cc/tiles/eviction_tile_priority_queue.h"
 #include "cc/tiles/image_controller.h"
 #include "cc/tiles/raster_tile_priority_queue.h"
@@ -99,8 +98,7 @@
 class CC_EXPORT TileManager {
  public:
   TileManager(TileManagerClient* client,
-              base::SequencedTaskRunner* origin_task_runner,
-              scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner,
+              base::SequencedTaskRunner* task_runner,
               size_t scheduled_raster_task_limit,
               bool use_partial_raster,
               bool check_tile_priority_inversion);
@@ -208,8 +206,6 @@
                              Resource* resource,
                              bool was_canceled);
 
-  void SetDecodedImageTracker(DecodedImageTracker* decoded_image_tracker);
-
  protected:
   friend class Tile;
   // Must be called by tile during destruction.
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index ab2763b..f4ce94d 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -190,12 +190,10 @@
     RenderingStatsInstrumentation* rendering_stats_instrumentation,
     TaskGraphRunner* task_graph_runner,
     std::unique_ptr<MutatorHost> mutator_host,
-    int id,
-    scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner) {
+    int id) {
   return base::WrapUnique(new LayerTreeHostImpl(
       settings, client, task_runner_provider, rendering_stats_instrumentation,
-      task_graph_runner, std::move(mutator_host), id,
-      std::move(image_worker_task_runner)));
+      task_graph_runner, std::move(mutator_host), id));
 }
 
 LayerTreeHostImpl::LayerTreeHostImpl(
@@ -205,8 +203,7 @@
     RenderingStatsInstrumentation* rendering_stats_instrumentation,
     TaskGraphRunner* task_graph_runner,
     std::unique_ptr<MutatorHost> mutator_host,
-    int id,
-    scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner)
+    int id)
     : client_(client),
       task_runner_provider_(task_runner_provider),
       current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
@@ -232,7 +229,6 @@
       // task_runner_provider_.
       tile_manager_(this,
                     GetTaskRunner(),
-                    std::move(image_worker_task_runner),
                     is_synchronous_single_threaded_
                         ? std::numeric_limits<size_t>::max()
                         : settings.scheduled_raster_task_limit,
@@ -277,8 +273,6 @@
   browser_controls_offset_manager_ = BrowserControlsOffsetManager::Create(
       this, settings.top_controls_show_threshold,
       settings.top_controls_hide_threshold);
-
-  tile_manager_.SetDecodedImageTracker(&decoded_image_tracker_);
 }
 
 LayerTreeHostImpl::~LayerTreeHostImpl() {
@@ -1843,7 +1837,6 @@
 
 void LayerTreeHostImpl::DidFinishImplFrame() {
   current_begin_frame_tracker_.Finish();
-  decoded_image_tracker_.NotifyFrameFinished();
 }
 
 void LayerTreeHostImpl::UpdateViewportContainerSizes() {
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index d51f307..2bbf782 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -36,7 +36,6 @@
 #include "cc/scheduler/commit_earlyout_reason.h"
 #include "cc/scheduler/draw_result.h"
 #include "cc/scheduler/video_frame_controller.h"
-#include "cc/tiles/decoded_image_tracker.h"
 #include "cc/tiles/image_decode_cache.h"
 #include "cc/tiles/tile_manager.h"
 #include "cc/trees/layer_tree_mutator.h"
@@ -145,8 +144,7 @@
       RenderingStatsInstrumentation* rendering_stats_instrumentation,
       TaskGraphRunner* task_graph_runner,
       std::unique_ptr<MutatorHost> mutator_host,
-      int id,
-      scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner);
+      int id);
   ~LayerTreeHostImpl() override;
 
   // InputHandler implementation
@@ -596,8 +594,7 @@
       RenderingStatsInstrumentation* rendering_stats_instrumentation,
       TaskGraphRunner* task_graph_runner,
       std::unique_ptr<MutatorHost> mutator_host,
-      int id,
-      scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner);
+      int id);
 
   // Virtual for testing.
   virtual bool AnimateLayers(base::TimeTicks monotonic_time);
@@ -749,7 +746,6 @@
 
   const bool is_synchronous_single_threaded_;
   TileManager tile_manager_;
-  DecodedImageTracker decoded_image_tracker_;
 
   gfx::Vector2dF accumulated_root_overscroll_;
 
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 761b4a6b..f0afd40 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -199,7 +199,7 @@
     host_impl_ = LayerTreeHostImpl::Create(
         settings, this, task_runner_provider, &stats_instrumentation_,
         &task_graph_runner_,
-        AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
+        AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
     compositor_frame_sink_ = std::move(compositor_frame_sink);
     host_impl_->SetVisible(true);
     bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get());
@@ -2709,8 +2709,7 @@
                           rendering_stats_instrumentation,
                           task_graph_runner,
                           AnimationHost::CreateForTesting(ThreadInstance::IMPL),
-                          0,
-                          nullptr) {}
+                          0) {}
 
   BeginFrameArgs CurrentBeginFrameArgs() const override {
     return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1,
@@ -7580,7 +7579,7 @@
       LayerTreeHostImpl::Create(
           settings, this, &task_runner_provider_, &stats_instrumentation_,
           &task_graph_runner_,
-          AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
+          AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
   layer_tree_host_impl->SetVisible(true);
   layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get());
   layer_tree_host_impl->WillBeginImplFrame(
@@ -7709,7 +7708,7 @@
   std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create(
       settings, client, task_runner_provider, stats_instrumentation,
       task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL),
-      0, nullptr);
+      0);
   my_host_impl->SetVisible(true);
   my_host_impl->InitializeRenderer(compositor_frame_sink);
   my_host_impl->WillBeginImplFrame(
@@ -8177,7 +8176,7 @@
   host_impl_ = LayerTreeHostImpl::Create(
       settings, this, &task_runner_provider_, &stats_instrumentation_,
       &task_graph_runner_,
-      AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
+      AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
 
   // Gpu compositing.
   compositor_frame_sink_ =
@@ -11606,7 +11605,7 @@
   host_impl_ = LayerTreeHostImpl::Create(
       settings, this, &task_runner_provider_, &stats_instrumentation_,
       &task_graph_runner_,
-      AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr);
+      AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
   host_impl_->SetVisible(true);
 
   // InitializeRenderer with a gpu-raster enabled output surface.
diff --git a/cc/trees/layer_tree_host_in_process.cc b/cc/trees/layer_tree_host_in_process.cc
index 805009e..1f0eab1 100644
--- a/cc/trees/layer_tree_host_in_process.cc
+++ b/cc/trees/layer_tree_host_in_process.cc
@@ -122,8 +122,7 @@
       did_complete_scale_animation_(false),
       id_(s_layer_tree_host_sequence_number.GetNext() + 1),
       task_graph_runner_(params->task_graph_runner),
-      image_serialization_processor_(params->image_serialization_processor),
-      image_worker_task_runner_(params->image_worker_task_runner) {
+      image_serialization_processor_(params->image_serialization_processor) {
   DCHECK(task_graph_runner_);
   DCHECK(layer_tree_);
   DCHECK_NE(compositor_mode_, CompositorMode::REMOTE);
@@ -446,7 +445,7 @@
   std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
       settings_, client, task_runner_provider_.get(),
       rendering_stats_instrumentation_.get(), task_graph_runner_,
-      std::move(mutator_host_impl), id_, std::move(image_worker_task_runner_));
+      std::move(mutator_host_impl), id_);
   host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_);
   host_impl->SetContentIsSuitableForGpuRasterization(
       content_is_suitable_for_gpu_rasterization_);
diff --git a/cc/trees/layer_tree_host_in_process.h b/cc/trees/layer_tree_host_in_process.h
index 909dce7..eec43948 100644
--- a/cc/trees/layer_tree_host_in_process.h
+++ b/cc/trees/layer_tree_host_in_process.h
@@ -74,8 +74,7 @@
     LayerTreeSettings const* settings = nullptr;
     scoped_refptr<base::SingleThreadTaskRunner> main_task_runner;
     ImageSerializationProcessor* image_serialization_processor = nullptr;
-    MutatorHost* mutator_host = nullptr;
-    scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner;
+    MutatorHost* mutator_host;
 
     InitParams();
     ~InitParams();
@@ -318,8 +317,6 @@
   // should get these PropertyTrees directly from blink?
   std::unique_ptr<ReflectedMainFrameState> reflected_main_frame_state_;
 
-  scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner_;
-
   DISALLOW_COPY_AND_ASSIGN(LayerTreeHostInProcess);
 };
 
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
index 4d6ae23..25ce77f 100644
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -186,6 +186,7 @@
     "//components/payments:payment_request_java",
     "//components/policy/android:policy_java",
     "//components/precache/android:precache_java",
+    "//components/safe_browsing_db/android:safe_browsing_java",
     "//components/safe_json/android:safe_json_java",
     "//components/safe_json/android:safe_json_java",
     "//components/signin/core/browser/android:java",
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
index 78c4010..c228920 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
@@ -38,6 +38,8 @@
 import org.chromium.chrome.browser.download.ui.BackendProvider.DownloadDelegate;
 import org.chromium.chrome.browser.download.ui.DownloadFilter;
 import org.chromium.chrome.browser.download.ui.DownloadHistoryItemWrapper;
+import org.chromium.chrome.browser.offlinepages.ClientId;
+import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
 import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBridge;
 import org.chromium.chrome.browser.tab.Tab;
 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
@@ -187,10 +189,21 @@
      * @param context Context to pull resources from.
      */
     public static void downloadOfflinePage(Context context, Tab tab) {
-        final OfflinePageDownloadBridge bridge = new OfflinePageDownloadBridge(tab.getProfile());
-        bridge.startDownload(tab);
-        bridge.destroy();
-        DownloadUtils.recordDownloadPageMetrics(tab);
+        if (tab.isShowingErrorPage()) {
+            // The download needs to be scheduled to happen at later time due to current network
+            // error.
+            ClientId clientId = ClientId.createGuidClientIdForNamespace(
+                    OfflinePageBridge.ASYNC_NAMESPACE);
+            final OfflinePageBridge bridge = OfflinePageBridge.getForProfile(tab.getProfile());
+            bridge.savePageLater(tab.getUrl(), clientId, true /* userRequested */);
+        } else {
+            // Otherwise, the download can be started immediately.
+            final OfflinePageDownloadBridge bridge =
+                    new OfflinePageDownloadBridge(tab.getProfile());
+            bridge.startDownload(tab);
+            bridge.destroy();
+            DownloadUtils.recordDownloadPageMetrics(tab);
+        }
     }
 
     /**
@@ -201,13 +214,15 @@
     public static boolean isAllowedToDownloadPage(Tab tab) {
         if (tab == null) return false;
 
-        // Only allow HTTP and HTTPS pages, as that is these are the only scenarios supported by the
-        // background/offline page saving.
-        if (!tab.getUrl().startsWith(UrlConstants.HTTP_SCHEME)
-                && !tab.getUrl().startsWith(UrlConstants.HTTPS_SCHEME)) {
-            return false;
+        // Check if the page url is supported for saving. Only HTTP and HTTPS pages are allowed.
+        if (!OfflinePageBridge.canSavePage(tab.getUrl())) return false;
+
+        // Download will only be allowed for the error page if download button is shown in the page.
+        if (tab.isShowingErrorPage()) {
+            final OfflinePageBridge bridge = OfflinePageBridge.getForProfile(tab.getProfile());
+            return bridge.isShowingDownloadButtonInErrorPage(tab.getWebContents());
         }
-        if (tab.isShowingErrorPage()) return false;
+
         if (tab.isShowingInterstitialPage()) return false;
 
         // Don't allow re-downloading the currently displayed offline page.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java
index 04d12de7..f2f42ff6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java
@@ -24,6 +24,7 @@
  */
 @JNINamespace("offline_pages::android")
 public class OfflinePageBridge {
+    public static final String ASYNC_NAMESPACE = "async_loading";
     public static final String BOOKMARK_NAMESPACE = "bookmark";
     public static final String SHARE_NAMESPACE = "share";
 
@@ -398,6 +399,14 @@
         return nativeIsShowingOfflinePreview(mNativeOfflinePageBridge, webContents);
     }
 
+    /**
+     * @return True if download button is being shown in the error page.
+     * @param webContents Contents of the page to check.
+     */
+    public boolean isShowingDownloadButtonInErrorPage(WebContents webContents) {
+        return nativeIsShowingDownloadButtonInErrorPage(mNativeOfflinePageBridge, webContents);
+    }
+
     private static class CheckPagesExistOfflineCallbackInternal {
         private Callback<Set<String>> mCallback;
 
@@ -525,4 +534,6 @@
             long nativeOfflinePageBridge, WebContents webContents);
     private native boolean nativeIsShowingOfflinePreview(
             long nativeOfflinePageBridge, WebContents webContents);
+    private native boolean nativeIsShowingDownloadButtonInErrorPage(
+            long nativeOfflinePageBridge, WebContents webContents);
 }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
index bc4ec06..ba594a7a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
@@ -10,6 +10,8 @@
 import org.chromium.base.ContextUtils;
 import org.chromium.chrome.browser.ChromeFeatureList;
 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager;
+import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.chrome.browser.search_engines.TemplateUrlService;
 import org.chromium.components.location.LocationUtils;
 
 /**
@@ -24,7 +26,7 @@
     private static final int MIN_ANDROID_VERSION = 18;
 
     /**
-     * Evaluate whether the environment is one in which the Physical Web should
+     * Evaluates whether the environment is one in which the Physical Web should
      * be enabled.
      * @return true if the PhysicalWeb should be enabled
      */
@@ -53,7 +55,7 @@
     }
 
     /**
-     * Start the Physical Web feature.
+     * Starts the Physical Web feature.
      * At the moment, this only enables URL discovery over BLE.
      */
     public static void startPhysicalWeb() {
@@ -66,7 +68,7 @@
     }
 
     /**
-     * Stop the Physical Web feature.
+     * Stops the Physical Web feature.
      */
     public static void stopPhysicalWeb() {
         new NearbyBackgroundSubscription(NearbySubscription.UNSUBSCRIBE, new Runnable() {
@@ -108,21 +110,40 @@
     }
 
     /**
-     * Perform various Physical Web operations that should happen on startup.
+     * Performs various Physical Web operations that should happen on startup.
      */
     public static void onChromeStart() {
-        // The PhysicalWebUma calls in this method should be called only when the native library is
-        // loaded.  This is always the case on chrome startup.
-        if (featureIsEnabled() && (isPhysicalWebPreferenceEnabled() || isOnboarding())) {
+        if (!featureIsEnabled()) {
+            stopPhysicalWeb();
+            return;
+        }
+
+        // If this user is in the default state, we need to check if we should enable Physical Web.
+        if (isOnboarding() && shouldAutoEnablePhysicalWeb()) {
+            PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(true);
+        }
+
+        if (isPhysicalWebPreferenceEnabled()) {
             boolean ignoreOtherClients =
                     ChromeFeatureList.isEnabled(IGNORE_OTHER_CLIENTS_FEATURE_NAME);
             ContextUtils.getAppSharedPreferences().edit()
                     .putBoolean(PREF_IGNORE_OTHER_CLIENTS, ignoreOtherClients)
                     .apply();
             startPhysicalWeb();
+            // The PhysicalWebUma call in this method should be called only when the native library
+            // is loaded.  This is always the case on chrome startup.
             PhysicalWebUma.uploadDeferredMetrics();
-        } else {
-            stopPhysicalWeb();
         }
     }
+
+    /**
+     * Checks if this device should have Physical Web automatically enabled.
+     */
+    private static boolean shouldAutoEnablePhysicalWeb() {
+        LocationUtils locationUtils = LocationUtils.getInstance();
+        return locationUtils.isSystemLocationSettingEnabled()
+                && locationUtils.hasAndroidLocationPermission()
+                && TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()
+                && !Profile.getLastUsedProfile().isOffTheRecord();
+    }
 }
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni
index e3e6410c..7bf1251 100644
--- a/chrome/android/java_sources.gni
+++ b/chrome/android/java_sources.gni
@@ -872,8 +872,6 @@
   "java/src/org/chromium/chrome/browser/push_messaging/PushMessagingServiceObserver.java",
   "java/src/org/chromium/chrome/browser/rappor/RapporServiceBridge.java",
   "java/src/org/chromium/chrome/browser/rlz/RevenueStats.java",
-  "java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java",
-  "java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java",
   "java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java",
   "java/src/org/chromium/chrome/browser/services/AccountsChangedReceiver.java",
   "java/src/org/chromium/chrome/browser/services/AndroidEduAndChildAccountHelper.java",
diff --git a/chrome/app/DEPS b/chrome/app/DEPS
index 98a624b..417fa0e 100644
--- a/chrome/app/DEPS
+++ b/chrome/app/DEPS
@@ -22,7 +22,7 @@
   "+components/nacl/renderer/plugin/ppapi_entrypoints.h",
   "+components/nacl/zygote",
   "+components/policy",
-  "+components/safe_browsing_db/safe_browsing_api_handler.h",
+  "+components/safe_browsing_db",
   "+components/startup_metric_utils/browser",
   "+components/upload_list",
   "+components/version_info",
diff --git a/chrome/app/android/chrome_main_delegate_android.cc b/chrome/app/android/chrome_main_delegate_android.cc
index 298a8f1..7e52cc74 100644
--- a/chrome/app/android/chrome_main_delegate_android.cc
+++ b/chrome/app/android/chrome_main_delegate_android.cc
@@ -13,9 +13,9 @@
 #include "base/trace_event/trace_event.h"
 #include "chrome/browser/android/chrome_startup_flags.h"
 #include "chrome/browser/android/metrics/uma_utils.h"
-#include "chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.h"
 #include "chrome/browser/media/android/remote/remote_media_player_manager.h"
 #include "components/policy/core/browser/android/android_combined_policy_provider.h"
+#include "components/safe_browsing_db/android/safe_browsing_api_handler_bridge.h"
 #include "components/safe_browsing_db/safe_browsing_api_handler.h"
 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
 #include "content/browser/media/android/browser_media_player_manager.h"
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 4f8265ac..f203b98 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -9051,46 +9051,6 @@
       </if>
 
       <!-- Page Information Window -->
-      <message name="IDS_WEBSITE_SETTINGS_SECURE_SUMMARY" desc="A short summary phrase at the top of the Page Info bubble (which shows when you click the lock icon) that indicates that the connection to the current website is secure.">
-        Secure connection
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_MIXED_CONTENT_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is using mainly using a secure connection but has some insecure parts (like insecurely loaded images).">
-        Your connection to this site is not fully secure
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is secure.">
-        Your connection to this site is not secure
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_MALWARE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as containing malware.">
-        This site contains malware
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_SOCIAL_ENGINEERING_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as social engineering.">
-        This site is deceptive
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as containing unwanted software.">
-        This site contains harmful programs
-      </message>
-
-      <message name="IDS_WEBSITE_SETTINGS_SECURE_DETAILS" desc="A short paragraph explaining a secure site to the user.">
-        Your information (for example, passwords or credit card numbers) is private when it is sent to this site.
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_MIXED_CONTENT_DETAILS" desc="A short paragraph explaining a partially insecure site to the user.">
-        Attackers might be able to see the images you’re looking at on this site and trick you by modifying them.
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS" desc="A short paragraph explaining a non-secure site to the user.">
-        You should not enter any sensitive information on this site (for example, passwords or credit cards), because it could be stolen by attackers.
-      </message>
-      <message name="IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION" desc="A short paragraph to the user that security warnings are disabled. This is the case when the user has encountered a certificate error for the current site and chosen to override it.">
-        You have chosen to disable security warnings for this site.
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_MALWARE_DETAILS" desc="A short paragraph explaining to the user that the current website has been flagged as containing malware.">
-        Attackers on this site might attempt to install dangerous programs on your computer that steal or delete your information (for example, photos, passwords, messages, and credit cards).
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_SOCIAL_ENGINEERING_DETAILS" desc="A short paragraph explaining to the user that the current website has been flagged as social engineering.">
-        Attackers on this site may trick you into doing something dangerous like installing software or revealing your personal information (for example, passwords, phone numbers, or credit cards).
-      </message>
-      <message name="IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_DETAILS" desc="A short paragraph explaining to the user that the current website has been flagged as containing unwanted software.">
-        Attackers on this site might try to trick you into installing programs that harm your browsing experience (for example, by changing your homepage or showing extra ads on sites you visit).
-      </message>
       <if expr="is_android">
         <message name="IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON" desc="Text of button in the page info that resets allow/deny decisions of invalid certificates, which will start showing security warnings for the page again.">
           Stop using an invalid certificate
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 4ee34ea6..20813f2 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -2798,8 +2798,6 @@
       "android/resource_mapper.h",
       "android/rlz/revenue_stats.cc",
       "android/rlz/revenue_stats.h",
-      "android/safe_browsing/safe_browsing_api_handler_bridge.cc",
-      "android/safe_browsing/safe_browsing_api_handler_bridge.h",
       "android/search_geolocation/search_geolocation_disclosure_infobar_delegate.cc",
       "android/search_geolocation/search_geolocation_disclosure_infobar_delegate.h",
       "android/search_geolocation/search_geolocation_disclosure_tab_helper.cc",
@@ -2997,7 +2995,7 @@
       "//components/precache/content",
       "//components/precache/core",
       "//components/resources:components_resources",
-      "//components/resources:components_resources",
+      "//components/safe_browsing_db",
       "//components/toolbar",
       "//components/web_contents_delegate_android",
       "//sandbox:sandbox_features",
@@ -4019,7 +4017,6 @@
       "../android/java/src/org/chromium/chrome/browser/push_messaging/PushMessagingServiceObserver.java",
       "../android/java/src/org/chromium/chrome/browser/rappor/RapporServiceBridge.java",
       "../android/java/src/org/chromium/chrome/browser/rlz/RevenueStats.java",
-      "../android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java",
       "../android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java",
       "../android/java/src/org/chromium/chrome/browser/sessions/SessionTabHelper.java",
       "../android/java/src/org/chromium/chrome/browser/signin/AccountManagementScreenHelper.java",
@@ -4431,6 +4428,13 @@
     "ui/webui/signin/login_ui_test_utils.h",
   ]
 
+  if (!is_android) {
+    sources += [
+      "ui/webui/web_ui_test_handler.cc",
+      "ui/webui/web_ui_test_handler.h",
+    ]
+  }
+
   configs += [ "//build/config:precompiled_headers" ]
 
   deps = [
diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc
index b4fc6c596..8a18442 100644
--- a/chrome/browser/android/chrome_jni_registrar.cc
+++ b/chrome/browser/android/chrome_jni_registrar.cc
@@ -85,7 +85,6 @@
 #include "chrome/browser/android/rappor/rappor_service_bridge.h"
 #include "chrome/browser/android/recently_closed_tabs_bridge.h"
 #include "chrome/browser/android/rlz/revenue_stats.h"
-#include "chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.h"
 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosure_tab_helper.h"
 #include "chrome/browser/android/service_tab_launcher.h"
 #include "chrome/browser/android/sessions/session_tab_helper_android.h"
@@ -170,6 +169,7 @@
 #include "components/invalidation/impl/android/component_jni_registrar.h"
 #include "components/payments/android/payments_jni_registrar.h"
 #include "components/policy/core/browser/android/component_jni_registrar.h"
+#include "components/safe_browsing_db/android/jni_registrar.h"
 #include "components/safe_json/android/component_jni_registrar.h"
 #include "components/signin/core/browser/android/component_jni_registrar.h"
 #include "components/spellcheck/browser/android/component_jni_registrar.h"
@@ -363,7 +363,6 @@
     {"ResourcePrefetchPredictor",
      predictors::RegisterResourcePrefetchPredictor},
     {"RevenueStats", chrome::android::RegisterRevenueStats},
-    {"SafeBrowsingApiBridge", safe_browsing::RegisterSafeBrowsingApiBridge},
     {"SceneLayer", RegisterSceneLayer},
     {"ScreenshotTask", chrome::android::RegisterScreenshotTask},
     {"ServiceTabLauncher", ServiceTabLauncher::Register},
diff --git a/chrome/browser/android/offline_pages/offline_page_bridge.cc b/chrome/browser/android/offline_pages/offline_page_bridge.cc
index ff555ba..66df120 100644
--- a/chrome/browser/android/offline_pages/offline_page_bridge.cc
+++ b/chrome/browser/android/offline_pages/offline_page_bridge.cc
@@ -510,6 +510,18 @@
   return offline_pages::OfflinePageUtils::IsShowingOfflinePreview(web_contents);
 }
 
+jboolean OfflinePageBridge::IsShowingDownloadButtonInErrorPage(
+    JNIEnv* env,
+    const base::android::JavaParamRef<jobject>& obj,
+    const JavaParamRef<jobject>& j_web_contents) {
+  content::WebContents* web_contents =
+      content::WebContents::FromJavaWebContents(j_web_contents);
+  if (!web_contents)
+    return false;
+  return offline_pages::OfflinePageUtils::IsShowingDownloadButtonInErrorPage(
+      web_contents);
+}
+
 void OfflinePageBridge::GetRequestsInQueue(
     JNIEnv* env,
     const JavaParamRef<jobject>& obj,
diff --git a/chrome/browser/android/offline_pages/offline_page_bridge.h b/chrome/browser/android/offline_pages/offline_page_bridge.h
index 52de41e..f0ee0d17 100644
--- a/chrome/browser/android/offline_pages/offline_page_bridge.h
+++ b/chrome/browser/android/offline_pages/offline_page_bridge.h
@@ -104,6 +104,11 @@
       const base::android::JavaParamRef<jobject>& obj,
       const base::android::JavaParamRef<jobject>& j_web_contents);
 
+  jboolean IsShowingDownloadButtonInErrorPage(
+      JNIEnv* env,
+      const base::android::JavaParamRef<jobject>& obj,
+      const base::android::JavaParamRef<jobject>& j_web_contents);
+
   base::android::ScopedJavaLocalRef<jstring> GetOfflinePageHeaderForReload(
       JNIEnv* env,
       const base::android::JavaParamRef<jobject>& obj,
diff --git a/chrome/browser/android/offline_pages/offline_page_utils.cc b/chrome/browser/android/offline_pages/offline_page_utils.cc
index 2a6afa6..a640ab4 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils.cc
+++ b/chrome/browser/android/offline_pages/offline_page_utils.cc
@@ -18,6 +18,7 @@
 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h"
 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
 #include "chrome/browser/android/tab_android.h"
+#include "chrome/browser/net/net_error_tab_helper.h"
 #include "components/offline_pages/core/background/request_coordinator.h"
 #include "components/offline_pages/core/background/save_page_request.h"
 #include "components/offline_pages/core/client_namespace_constants.h"
@@ -139,6 +140,14 @@
 }
 
 // static
+bool OfflinePageUtils::IsShowingDownloadButtonInErrorPage(
+    content::WebContents* web_contents) {
+  chrome_browser_net::NetErrorTabHelper* tab_helper =
+      chrome_browser_net::NetErrorTabHelper::FromWebContents(web_contents);
+  return tab_helper && tab_helper->is_showing_download_button_in_error_page();
+}
+
+// static
 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents,
                                 int* tab_id) {
   TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents);
diff --git a/chrome/browser/android/offline_pages/offline_page_utils.h b/chrome/browser/android/offline_pages/offline_page_utils.h
index 60f94179..85f61b60 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils.h
+++ b/chrome/browser/android/offline_pages/offline_page_utils.h
@@ -60,6 +60,10 @@
   // Returns true if the offline page is shown for previewing purpose.
   static bool IsShowingOfflinePreview(content::WebContents* web_contents);
 
+  // Returns true if download button is shown in the error page.
+  static bool IsShowingDownloadButtonInErrorPage(
+      content::WebContents* web_contents);
+
   // Gets an Android Tab ID from a tab containing |web_contents|. Returns false,
   // when tab is not available. Returns true otherwise and sets |tab_id| to the
   // ID of the tab.
diff --git a/chrome/browser/collected_cookies_browsertest.cc b/chrome/browser/collected_cookies_browsertest.cc
deleted file mode 100644
index d190cf9f..0000000
--- a/chrome/browser/collected_cookies_browsertest.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <string>
-
-#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/content_settings/cookie_settings_factory.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/tab_dialogs.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "components/content_settings/core/browser/cookie_settings.h"
-#include "net/test/embedded_test_server/embedded_test_server.h"
-
-typedef InProcessBrowserTest CollectedCookiesTest;
-
-// If this crashes on Windows, use http://crbug.com/79331
-IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) {
-  ASSERT_TRUE(embedded_test_server()->Start());
-
-  // Disable cookies.
-  CookieSettingsFactory::GetForProfile(browser()->profile())
-      ->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
-
-  // Load a page with cookies.
-  ui_test_utils::NavigateToURL(
-      browser(), embedded_test_server()->GetURL("/cookie1.html"));
-
-  // Click on the info link twice.
-  content::WebContents* web_contents =
-      browser()->tab_strip_model()->GetActiveWebContents();
-  TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
-  TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
-}
-
-// If this crashes on Windows, use http://crbug.com/79331
-IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) {
-  ASSERT_TRUE(embedded_test_server()->Start());
-
-  // Disable cookies.
-  CookieSettingsFactory::GetForProfile(browser()->profile())
-      ->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
-
-  // Load a page with cookies.
-  ui_test_utils::NavigateToURL(
-      browser(), embedded_test_server()->GetURL("/cookie1.html"));
-
-  // Click on the info link.
-  content::WebContents* web_contents =
-      browser()->tab_strip_model()->GetActiveWebContents();
-  TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
-
-  // Navigate to another page.
-  ui_test_utils::NavigateToURL(
-      browser(), embedded_test_server()->GetURL("/cookie2.html"));
-}
diff --git a/chrome/browser/devtools/devtools_ui_bindings.cc b/chrome/browser/devtools/devtools_ui_bindings.cc
index 466150c4b..2c6c722 100644
--- a/chrome/browser/devtools/devtools_ui_bindings.cc
+++ b/chrome/browser/devtools/devtools_ui_bindings.cc
@@ -472,6 +472,12 @@
 }
 
 bool DevToolsUIBindings::IsValidFrontendURL(const GURL& url) {
+  if (url.SchemeIs(content::kChromeUIScheme) &&
+      url.host() == content::kChromeUITracingHost &&
+      !url.has_query() && !url.has_ref()) {
+    return true;
+  }
+
   return SanitizeFrontendURL(url).spec() == url.spec();
 }
 
@@ -582,7 +588,7 @@
 // content::DevToolsFrontendHost::Delegate implementation ---------------------
 void DevToolsUIBindings::HandleMessageFromDevToolsFrontend(
     const std::string& message) {
-  if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
+  if (!frontend_host_)
     return;
   std::string method;
   base::ListValue empty_params;
@@ -612,7 +618,7 @@
 void DevToolsUIBindings::DispatchProtocolMessage(
     content::DevToolsAgentHost* agent_host, const std::string& message) {
   DCHECK(agent_host == agent_host_.get());
-  if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
+  if (!frontend_host_)
     return;
 
   if (message.length() < kMaxMessageChunkSize) {
@@ -728,7 +734,7 @@
 }
 
 void DevToolsUIBindings::RequestFileSystems() {
-  CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
+  CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
   std::vector<DevToolsFileHelper::FileSystem> file_systems =
       file_helper_->GetFileSystems();
   base::ListValue file_systems_value;
@@ -739,7 +745,7 @@
 }
 
 void DevToolsUIBindings::AddFileSystem(const std::string& file_system_path) {
-  CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
+  CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
   file_helper_->AddFileSystem(
       file_system_path,
       base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar,
@@ -747,13 +753,13 @@
 }
 
 void DevToolsUIBindings::RemoveFileSystem(const std::string& file_system_path) {
-  CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
+  CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
   file_helper_->RemoveFileSystem(file_system_path);
 }
 
 void DevToolsUIBindings::UpgradeDraggedFileSystemPermissions(
     const std::string& file_system_url) {
-  CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
+  CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
   file_helper_->UpgradeDraggedFileSystemPermissions(
       file_system_url,
       base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar,
@@ -763,7 +769,7 @@
 void DevToolsUIBindings::IndexPath(int index_request_id,
                                    const std::string& file_system_path) {
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
-  CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
+  CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
   if (!file_helper_->IsFileSystemAdded(file_system_path)) {
     IndexingDone(index_request_id, file_system_path);
     return;
@@ -801,7 +807,7 @@
                                       const std::string& file_system_path,
                                       const std::string& query) {
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
-  CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
+  CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
   if (!file_helper_->IsFileSystemAdded(file_system_path)) {
     SearchCompleted(search_request_id,
                     file_system_path,
@@ -1287,8 +1293,6 @@
                                             const base::Value* arg1,
                                             const base::Value* arg2,
                                             const base::Value* arg3) {
-  if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
-    return;
   // If we're not exposing bindings, we shouldn't call functions either.
   if (!frontend_host_)
     return;
diff --git a/chrome/browser/net/net_error_tab_helper.cc b/chrome/browser/net/net_error_tab_helper.cc
index 0ab91f0..2cac81c 100644
--- a/chrome/browser/net/net_error_tab_helper.cc
+++ b/chrome/browser/net/net_error_tab_helper.cc
@@ -130,6 +130,9 @@
              !navigation_handle->IsErrorPage()) {
     dns_error_active_ = false;
     dns_error_page_committed_ = false;
+#if defined(OS_ANDROID)
+    is_showing_download_button_in_error_page_ = false;
+#endif  // defined(OS_ANDROID)
   }
 }
 
@@ -141,7 +144,10 @@
 #if defined(OS_ANDROID)
   bool handled = true;
   IPC_BEGIN_MESSAGE_MAP(NetErrorTabHelper, message)
-    IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DownloadPageLater, DownloadPageLater)
+    IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DownloadPageLater,
+                        OnDownloadPageLater)
+    IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetIsShowingDownloadButtonInErrorPage,
+                        OnSetIsShowingDownloadButtonInErrorPage)
     IPC_MESSAGE_UNHANDLED(handled = false)
   IPC_END_MESSAGE_MAP()
 
@@ -157,6 +163,9 @@
       is_error_page_(false),
       dns_error_active_(false),
       dns_error_page_committed_(false),
+#if defined(OS_ANDROID)
+      is_showing_download_button_in_error_page_(false),
+#endif  // defined(OS_ANDROID)
       dns_probe_status_(error_page::DNS_PROBE_POSSIBLE),
       weak_factory_(this) {
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -209,7 +218,7 @@
 }
 
 #if defined(OS_ANDROID)
-void NetErrorTabHelper::DownloadPageLater() {
+void NetErrorTabHelper::OnDownloadPageLater() {
   // Makes sure that this is coming from an error page.
   content::NavigationEntry* entry =
       web_contents()->GetController().GetLastCommittedEntry();
@@ -223,6 +232,11 @@
 
   DownloadPageLaterHelper(url);
 }
+
+void NetErrorTabHelper::OnSetIsShowingDownloadButtonInErrorPage(
+    bool is_showing_download_button) {
+  is_showing_download_button_in_error_page_ = is_showing_download_button;
+}
 #endif  // defined(OS_ANDROID)
 
 void NetErrorTabHelper::InitializePref(WebContents* contents) {
diff --git a/chrome/browser/net/net_error_tab_helper.h b/chrome/browser/net/net_error_tab_helper.h
index 42b2abe1..3a03feef 100644
--- a/chrome/browser/net/net_error_tab_helper.h
+++ b/chrome/browser/net/net_error_tab_helper.h
@@ -51,6 +51,12 @@
     dns_probe_status_snoop_callback_ = dns_probe_status_snoop_callback;
   }
 
+#if defined(OS_ANDROID)
+  bool is_showing_download_button_in_error_page() const {
+    return is_showing_download_button_in_error_page_;
+  }
+#endif  // defined(OS_ANDROID)
+
   // content::WebContentsObserver implementation.
   void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
   void DidStartNavigation(
@@ -78,7 +84,8 @@
   }
 
 #if defined(OS_ANDROID)
-  void DownloadPageLater();
+  void OnDownloadPageLater();
+  void OnSetIsShowingDownloadButtonInErrorPage(bool is_showing_download_button);
 #endif  // defined(OS_ANDROID)
 
  private:
@@ -115,6 +122,11 @@
   // is true.  (This should never be true if |dns_error_active_| is false.)
   bool dns_error_page_committed_;
 
+#if defined(OS_ANDROID)
+  // True if download button is being shown when the error page commits.
+  bool is_showing_download_button_in_error_page_;
+#endif  // defined(OS_ANDROID)
+
   // The status of a DNS probe that may or may not have started or finished.
   // Since the renderer can change out from under the helper (in cross-process
   // navigations), it re-sends the status whenever an error page commits.
diff --git a/chrome/browser/net/net_error_tab_helper_unittest.cc b/chrome/browser/net/net_error_tab_helper_unittest.cc
index 77e8221..efa5448 100644
--- a/chrome/browser/net/net_error_tab_helper_unittest.cc
+++ b/chrome/browser/net/net_error_tab_helper_unittest.cc
@@ -44,7 +44,7 @@
   int mock_sent_count() const { return mock_sent_count_; }
 
 #if defined(OS_ANDROID)
-  using NetErrorTabHelper::DownloadPageLater;
+  using NetErrorTabHelper::OnDownloadPageLater;
 
   const GURL& download_page_later_url() const {
     return download_page_later_url_;
@@ -175,7 +175,7 @@
                                             bool succeeded) {
     GURL url(url_string);
     LoadURL(url, succeeded);
-    tab_helper()->DownloadPageLater();
+    tab_helper()->OnDownloadPageLater();
     EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
   }
 #endif
@@ -376,7 +376,7 @@
 TEST_F(NetErrorTabHelperTest, DownloadPageLater) {
   GURL url("http://somewhere:123/");
   LoadURL(url, false /*succeeded*/);
-  tab_helper()->DownloadPageLater();
+  tab_helper()->OnDownloadPageLater();
   EXPECT_EQ(url, tab_helper()->download_page_later_url());
   EXPECT_EQ(1, tab_helper()->times_download_page_later_invoked());
 }
@@ -384,7 +384,7 @@
 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) {
   GURL url("http://somewhere:123/");
   LoadURL(url, true /*succeeded*/);
-  tab_helper()->DownloadPageLater();
+  tab_helper()->OnDownloadPageLater();
   EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
 }
 
diff --git a/chrome/browser/plugins/plugin_power_saver_browsertest.cc b/chrome/browser/plugins/plugin_power_saver_browsertest.cc
index 183b0036..4727c2d 100644
--- a/chrome/browser/plugins/plugin_power_saver_browsertest.cc
+++ b/chrome/browser/plugins/plugin_power_saver_browsertest.cc
@@ -28,6 +28,7 @@
 #include "content/public/browser/render_frame_host.h"
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/render_widget_host.h"
+#include "content/public/common/content_features.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/test/browser_test_utils.h"
 #include "content/public/test/ppapi_test_utils.h"
@@ -599,6 +600,32 @@
   VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential");
 }
 
+// Separate test case with FilterSameOriginTinyPlugins feature flag on.
+class PluginPowerSaverFilterSameOriginTinyPluginsBrowserTest
+    : public PluginPowerSaverBrowserTest {
+ public:
+  void SetUpInProcessBrowserTestFixture() override {
+    // Although this is redundant with the Field Trial testing configuration,
+    // the official builders don't read that.
+    feature_list.InitWithFeatures({features::kFilterSameOriginTinyPlugin},
+                                  {features::kPreferHtmlOverPlugins});
+  }
+
+ private:
+  base::test::ScopedFeatureList feature_list;
+};
+
+IN_PROC_BROWSER_TEST_F(PluginPowerSaverFilterSameOriginTinyPluginsBrowserTest,
+                       BlockSameOriginTinyPlugin) {
+  LoadHTML("/same_origin_tiny_plugin.html");
+
+  VerifyPluginIsPlaceholderOnly("tiny_same_origin");
+
+  TabSpecificContentSettings* tab_specific_content_settings =
+      TabSpecificContentSettings::FromWebContents(GetActiveWebContents());
+  EXPECT_FALSE(tab_specific_content_settings->blocked_plugin_names().empty());
+}
+
 // Separate test case with HTML By Default feature flag on.
 class PluginPowerSaverPreferHtmlBrowserTest
     : public PluginPowerSaverBrowserTest {
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_predicate.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_predicate.js
index 3fe675a..bb028e0 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_predicate.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_predicate.js
@@ -322,9 +322,17 @@
  */
 AutomationPredicate.root = function(node) {
   switch (node.role) {
-    case Role.dialog:
     case Role.window:
       return true;
+    case Role.dialog:
+      // The below logic handles nested dialogs properly in the desktop tree
+      // like that found in a bubble view.
+      return node.root.role != Role.desktop ||
+          (!!node.parent &&
+           node.parent.role == Role.window &&
+           node.parent.children.every(function(child) {
+             return node.role == Role.window || node.role == Role.dialog;
+           }));
     case Role.toolbar:
       return node.root.role == Role.desktop;
     case Role.rootWebArea:
diff --git a/chrome/browser/resources/chromeos/first_run/app/main.html b/chrome/browser/resources/chromeos/first_run/app/main.html
index 32e52a3..a8c6df8 100644
--- a/chrome/browser/resources/chromeos/first_run/app/main.html
+++ b/chrome/browser/resources/chromeos/first_run/app/main.html
@@ -26,14 +26,14 @@
           </div>
         </div>
       </div>
-      <h1 i18n-content="greetingHeader"></h1>
+      <h1>$i18n{greetingHeader}</h1>
       <p>
-        <span i18n-content="greetingText1"></span><br>
-        <span i18n-content="greetingText2"></span>
+        <span>$i18n{greetingText1}</span><br>
+        <span>$i18n{greetingText2}</span>
       </p>
       <div class="controls">
-        <button i18n-content="greetingButton"
-            class="next-button custom-appearance blue-button" tabindex="0">
+        <button class="next-button custom-appearance blue-button" tabindex="0">
+          $i18n{greetingButton}
         </button>
       </div>
       <include src="greeting_image_[GREETING_IMAGE].html">
diff --git a/chrome/browser/resources/chromeos/first_run/app_list_step.html b/chrome/browser/resources/chromeos/first_run/app_list_step.html
index bdc51ce..7cb2e4d 100644
--- a/chrome/browser/resources/chromeos/first_run/app_list_step.html
+++ b/chrome/browser/resources/chromeos/first_run/app_list_step.html
@@ -1,11 +1,12 @@
 <div id="app-list" class="step bubble transparent hidden">
-  <h1 i18n-content="appListHeader"></h1>
+  <h1>$i18n{appListHeader}</h1>
   <p>
-    <span i18n-content="appListText1"></span><br>
-    <span i18n-content="appListText2"></span>
+    <span>$i18n{appListText1}</span><br>
+    <span>$i18n{appListText2}</span>
   </p>
   <div class="controls">
-    <button i18n-content="nextButton"
-        class="next-button custom-appearance blue-button"></button>
+    <button class="next-button custom-appearance blue-button">
+      $i18n{nextButton}
+    </button>
   </div>
 </div>
diff --git a/chrome/browser/resources/chromeos/first_run/help_step.html b/chrome/browser/resources/chromeos/first_run/help_step.html
index 0a9c513..44659862 100644
--- a/chrome/browser/resources/chromeos/first_run/help_step.html
+++ b/chrome/browser/resources/chromeos/first_run/help_step.html
@@ -1,12 +1,14 @@
 <div id="help" class="step bubble transparent hidden">
   <div id="completion-image"></div>
-  <h1 i18n-content="helpHeader"></h1>
-  <p i18n-content="helpText1"></p>
-  <p i18n-content="helpText2"></p>
+  <h1>$i18n{helpHeader}</h1>
+  <p>$i18n{helpText1}</p>
+  <p>$i18n{helpText2}</p>
   <div class="controls">
-    <button i18n-content="helpKeepExploringButton"
-        class="help-button custom-appearance blue-button"></button>
-    <button i18n-content="helpFinishButton"
-        class="next-button custom-appearance white-button"></button>
+    <button class="help-button custom-appearance blue-button">
+      $i18n{helpKeepExploringButton}
+    </button>
+    <button class="next-button custom-appearance white-button">
+      $i18n{helpFinishButton}
+    </button>
   </div>
 </div>
diff --git a/chrome/browser/resources/chromeos/first_run/tray_step.html b/chrome/browser/resources/chromeos/first_run/tray_step.html
index 2b7b9e7..ed96e21 100644
--- a/chrome/browser/resources/chromeos/first_run/tray_step.html
+++ b/chrome/browser/resources/chromeos/first_run/tray_step.html
@@ -1,8 +1,9 @@
 <div id="tray" class="step bubble transparent hidden">
-  <h1 i18n-content="trayHeader"></h1>
-  <p i18n-content="trayText"><p>
+  <h1>$i18n{trayHeader}</h1>
+  <p>$i18n{trayText}<p>
   <div class="controls">
-    <button i18n-content="nextButton"
-        class="next-button custom-appearance blue-button"></button>
+    <button class="next-button custom-appearance blue-button">
+      $i18n{nextButton}
+    </button>
   </div>
 </div>
diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html
index c789f6c..e37bd57 100644
--- a/chrome/browser/resources/settings/privacy_page/privacy_page.html
+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html
@@ -45,12 +45,10 @@
         --paper-tooltip: var(--cr-policy-tooltip);
       }
 
-      #indicator {
-        -webkit-margin-start: var(--checkbox-spacing);
-      }
-
+      #metricsReportingControl,
+      #indicator,
       #restart {
-        text-align: end;
+        -webkit-margin-start: var(--checkbox-spacing);
       }
     </style>
     <template is="dom-if" if="[[showClearBrowsingDataDialog_]]" restamp>
@@ -98,11 +96,9 @@
           <div class="layout horizontal center settings-row-min-height">
             <div class="flex">$i18n{enableLogging}</div>
             <template is="dom-if" if="[[showRestart_]]" restamp>
-              <div id="restart" class="flex">
-                <paper-button on-tap="onRestartTap_">
-                  $i18n{restart}
-                </paper-button>
-              </div>
+              <paper-button on-tap="onRestartTap_" id="restart">
+                $i18n{restart}
+              </paper-button>
             </template>
             <template is="dom-if" if="[[metricsReporting_.managed]]" restamp>
               <iron-icon id="indicator" tabindex=0 icon="cr:domain"></iron-icon>
diff --git a/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp b/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp
index 45b699c..e60dd12 100644
--- a/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp
+++ b/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp
@@ -8,6 +8,7 @@
       'dependencies': [
         '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar',
         '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar_search_field',
+        '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior',
         '../compiled_resources2.gyp:direction_delegate',
         '../compiled_resources2.gyp:global_scroll_target_behavior',
         '../prefs/compiled_resources2.gyp:prefs',
diff --git a/chrome/browser/resources/settings/settings_ui/settings_ui.js b/chrome/browser/resources/settings/settings_ui/settings_ui.js
index 07d662c..22fe0457 100644
--- a/chrome/browser/resources/settings/settings_ui/settings_ui.js
+++ b/chrome/browser/resources/settings/settings_ui/settings_ui.js
@@ -87,6 +87,20 @@
       this.$.drawer.closeDrawer();
     }.bind(this));
 
+    CrPolicyStrings = {
+      controlledSettingPolicy:
+          loadTimeData.getString('controlledSettingPolicy'),
+      controlledSettingRecommendedMatches:
+          loadTimeData.getString('controlledSettingRecommendedMatches'),
+      controlledSettingRecommendedDiffers:
+          loadTimeData.getString('controlledSettingRecommendedDiffers'),
+// <if expr="chromeos">
+      controlledSettingShared:
+          loadTimeData.getString('controlledSettingShared'),
+      controlledSettingOwner: loadTimeData.getString('controlledSettingOwner'),
+// </if>
+    };
+
     if (loadTimeData.getBoolean('isGuest')) {
       this.pageVisibility_ = {
         people: false,
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index 7d361a70..85414bef 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -2905,6 +2905,8 @@
         "cocoa/tab_contents/tab_contents_controller.mm",
         "cocoa/tab_dialogs_cocoa.h",
         "cocoa/tab_dialogs_cocoa.mm",
+        "cocoa/tab_dialogs_views_mac.h",
+        "cocoa/tab_dialogs_views_mac.mm",
         "cocoa/tab_modal_confirm_dialog_mac.h",
         "cocoa/tab_modal_confirm_dialog_mac.mm",
         "cocoa/tabs/alert_indicator_button_cocoa.h",
diff --git a/chrome/browser/ui/cocoa/tab_dialogs_cocoa.h b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.h
index 2d08f81..1eb2bd5 100644
--- a/chrome/browser/ui/cocoa/tab_dialogs_cocoa.h
+++ b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.h
@@ -32,6 +32,9 @@
       const base::string16& main_text,
       const base::string16& sub_text) override;
 
+ protected:
+  content::WebContents* web_contents() const { return web_contents_; }
+
  private:
   content::WebContents* web_contents_;  // Weak. Owns this.
 
diff --git a/chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm
index e70c579..bc20ecf6 100644
--- a/chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm
+++ b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm
@@ -9,14 +9,22 @@
 #import "chrome/browser/ui/cocoa/hung_renderer_controller.h"
 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa.h"
 #import "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h"
+#include "chrome/browser/ui/cocoa/tab_dialogs_views_mac.h"
 #import "chrome/browser/ui/cocoa/validation_message_bubble_cocoa.h"
 #include "content/public/browser/web_contents.h"
+#include "ui/base/material_design/material_design_controller.h"
 
 // static
 void TabDialogs::CreateForWebContents(content::WebContents* contents) {
   DCHECK(contents);
-  if (!FromWebContents(contents))
-    contents->SetUserData(UserDataKey(), new TabDialogsCocoa(contents));
+
+  if (!FromWebContents(contents)) {
+    TabDialogs* tab_dialogs =
+        ui::MaterialDesignController::IsSecondaryUiMaterial()
+            ? new TabDialogsViewsMac(contents)
+            : new TabDialogsCocoa(contents);
+    contents->SetUserData(UserDataKey(), tab_dialogs);
+  }
 }
 
 TabDialogsCocoa::TabDialogsCocoa(content::WebContents* contents)
diff --git a/chrome/browser/ui/cocoa/tab_dialogs_views_mac.h b/chrome/browser/ui/cocoa/tab_dialogs_views_mac.h
new file mode 100644
index 0000000..622777c
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tab_dialogs_views_mac.h
@@ -0,0 +1,23 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_VIEWS_MAC_H_
+#define CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_VIEWS_MAC_H_
+
+#include "chrome/browser/ui/cocoa/tab_dialogs_cocoa.h"
+
+// Implementation of TabDialogs interface for toolkit-views dialogs on Mac.
+class TabDialogsViewsMac : public TabDialogsCocoa {
+ public:
+  explicit TabDialogsViewsMac(content::WebContents* contents);
+  ~TabDialogsViewsMac() override;
+
+  // TabDialogs:
+  void ShowCollectedCookies() override;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(TabDialogsViewsMac);
+};
+
+#endif  // CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_VIEWS_MAC_H_
diff --git a/chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm b/chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm
new file mode 100644
index 0000000..6187e48
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm
@@ -0,0 +1,17 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/cocoa/tab_dialogs_views_mac.h"
+
+#include "chrome/browser/ui/views/collected_cookies_views.h"
+
+TabDialogsViewsMac::TabDialogsViewsMac(content::WebContents* contents)
+    : TabDialogsCocoa(contents) {}
+
+TabDialogsViewsMac::~TabDialogsViewsMac() {}
+
+void TabDialogsViewsMac::ShowCollectedCookies() {
+  // Deletes itself on close.
+  new CollectedCookiesViews(web_contents());
+}
diff --git a/chrome/browser/ui/collected_cookies_browsertest.cc b/chrome/browser/ui/collected_cookies_browsertest.cc
new file mode 100644
index 0000000..0316265
--- /dev/null
+++ b/chrome/browser/ui/collected_cookies_browsertest.cc
@@ -0,0 +1,85 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/command_line.h"
+#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/content_settings/cookie_settings_factory.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tab_dialogs.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/test/test_browser_dialog.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "components/content_settings/core/browser/cookie_settings.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
+#include "ui/base/ui_base_switches.h"
+
+class CollectedCookiesTest : public DialogBrowserTest {
+ public:
+  CollectedCookiesTest() {}
+
+  // TestDialogInterface:
+  void ShowDialog(const std::string& name) override {
+    ASSERT_TRUE(embedded_test_server()->Start());
+
+    // Disable cookies.
+    CookieSettingsFactory::GetForProfile(browser()->profile())
+        ->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
+
+    // Load a page with cookies.
+    ui_test_utils::NavigateToURL(
+        browser(), embedded_test_server()->GetURL("/cookie1.html"));
+
+    content::WebContents* web_contents =
+        browser()->tab_strip_model()->GetActiveWebContents();
+    TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(CollectedCookiesTest);
+};
+
+// Runs with --secondary-ui-md. Users of this can switch to CollectedCookiesTest
+// when that is the default.
+class CollectedCookiesTestMd : public CollectedCookiesTest {
+ public:
+  CollectedCookiesTestMd() {}
+
+  // content::BrowserTestBase:
+  void SetUpCommandLine(base::CommandLine* command_line) override {
+    command_line->AppendSwitch(switches::kExtendMdToSecondaryUi);
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(CollectedCookiesTestMd);
+};
+
+// Test that calls ShowDialog("default"). Interactive when run via
+// browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
+// --dialog=CollectedCookiesTestMd.InvokeDialog_default
+IN_PROC_BROWSER_TEST_F(CollectedCookiesTestMd, InvokeDialog_default) {
+  RunDialog();
+}
+
+// If this crashes on Windows, use http://crbug.com/79331
+IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) {
+  ShowDialog(std::string());
+
+  // Click on the info link a second time.
+  content::WebContents* web_contents =
+      browser()->tab_strip_model()->GetActiveWebContents();
+  TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
+}
+
+// If this crashes on Windows, use http://crbug.com/79331
+IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) {
+  ShowDialog(std::string());
+
+  // Navigate to another page.
+  ui_test_utils::NavigateToURL(
+      browser(), embedded_test_server()->GetURL("/cookie2.html"));
+}
diff --git a/chrome/browser/ui/website_settings/website_settings.cc b/chrome/browser/ui/website_settings/website_settings.cc
index 914cebb..dc13e59 100644
--- a/chrome/browser/ui/website_settings/website_settings.cc
+++ b/chrome/browser/ui/website_settings/website_settings.cc
@@ -172,17 +172,17 @@
     case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
       *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE;
       *details =
-          l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MALWARE_DETAILS);
+          l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
       break;
     case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
       *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
       *details = l10n_util::GetStringUTF16(
-          IDS_WEBSITE_SETTINGS_SOCIAL_ENGINEERING_DETAILS);
+          IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
       break;
     case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
       *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
       *details = l10n_util::GetStringUTF16(
-          IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_DETAILS);
+          IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
       break;
   }
 }
diff --git a/chrome/browser/ui/website_settings/website_settings_ui.cc b/chrome/browser/ui/website_settings/website_settings_ui.cc
index 62370e0..eb5d6ae9 100644
--- a/chrome/browser/ui/website_settings/website_settings_ui.cc
+++ b/chrome/browser/ui/website_settings/website_settings_ui.cc
@@ -170,34 +170,34 @@
         case WebsiteSettings::
             SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE:
           return CreateSecurityDescription(
-              IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY,
-              IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS);
+              IDS_PAGEINFO_NOT_SECURE_SUMMARY,
+              IDS_PAGEINFO_NOT_SECURE_DETAILS);
         case WebsiteSettings::
             SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE:
           return CreateSecurityDescription(
-              IDS_WEBSITE_SETTINGS_MIXED_CONTENT_SUMMARY,
-              IDS_WEBSITE_SETTINGS_MIXED_CONTENT_DETAILS);
+              IDS_PAGEINFO_MIXED_CONTENT_SUMMARY,
+              IDS_PAGEINFO_MIXED_CONTENT_DETAILS);
         default:
-          return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_SECURE_SUMMARY,
-                                           IDS_WEBSITE_SETTINGS_SECURE_DETAILS);
+          return CreateSecurityDescription(IDS_PAGEINFO_SECURE_SUMMARY,
+                                           IDS_PAGEINFO_SECURE_DETAILS);
       }
     case WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE:
-      return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_MALWARE_SUMMARY,
-                                       IDS_WEBSITE_SETTINGS_MALWARE_DETAILS);
+      return CreateSecurityDescription(IDS_PAGEINFO_MALWARE_SUMMARY,
+                                       IDS_PAGEINFO_MALWARE_DETAILS);
     case WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING:
       return CreateSecurityDescription(
-          IDS_WEBSITE_SETTINGS_SOCIAL_ENGINEERING_SUMMARY,
-          IDS_WEBSITE_SETTINGS_SOCIAL_ENGINEERING_DETAILS);
+          IDS_PAGEINFO_SOCIAL_ENGINEERING_SUMMARY,
+          IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
     case WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE:
       return CreateSecurityDescription(
-          IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_SUMMARY,
-          IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_DETAILS);
+          IDS_PAGEINFO_UNWANTED_SOFTWARE_SUMMARY,
+          IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
     case WebsiteSettings::SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM:
     case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN:
     case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT:
     default:
-      return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY,
-                                       IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS);
+      return CreateSecurityDescription(IDS_PAGEINFO_NOT_SECURE_SUMMARY,
+                                       IDS_PAGEINFO_NOT_SECURE_DETAILS);
   }
 }
 
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index cdd991f..45d770ec 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -341,6 +341,11 @@
 // Message sent from the renderer to the browser to schedule to download the
 // page at a later time.
 IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_DownloadPageLater)
+
+// Message sent from the renderer to the browser to indicate if download button
+// is being shown in error page.
+IPC_MESSAGE_ROUTED1(ChromeViewHostMsg_SetIsShowingDownloadButtonInErrorPage,
+                    bool /* showing download button */)
 #endif  // defined(OS_ANDROID)
 
 //-----------------------------------------------------------------------------
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc
index e4c6001a..47316642 100644
--- a/chrome/renderer/net/net_error_helper.cc
+++ b/chrome/renderer/net/net_error_helper.cc
@@ -340,6 +340,14 @@
 #endif  // defined(OS_ANDROID)
 }
 
+void NetErrorHelper::SetIsShowingDownloadButton(bool show) {
+#if defined(OS_ANDROID)
+  render_frame()->Send(
+      new ChromeViewHostMsg_SetIsShowingDownloadButtonInErrorPage(
+          render_frame()->GetRoutingID(), show));
+#endif  // defined(OS_ANDROID)
+}
+
 void NetErrorHelper::OnNetErrorInfo(int status_num) {
   DCHECK(status_num >= 0 && status_num < error_page::DNS_PROBE_MAX);
 
diff --git a/chrome/renderer/net/net_error_helper.h b/chrome/renderer/net/net_error_helper.h
index 664bf6b..bc7fc80e 100644
--- a/chrome/renderer/net/net_error_helper.h
+++ b/chrome/renderer/net/net_error_helper.h
@@ -112,6 +112,7 @@
   void LoadPageFromCache(const GURL& page_url) override;
   void DiagnoseError(const GURL& page_url) override;
   void DownloadPageLater() override;
+  void SetIsShowingDownloadButton(bool show) override;
 
   void OnNetErrorInfo(int status);
   void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url,
diff --git a/chrome/renderer/plugins/power_saver_info.cc b/chrome/renderer/plugins/power_saver_info.cc
index 0ecfbba..983b19d 100644
--- a/chrome/renderer/plugins/power_saver_info.cc
+++ b/chrome/renderer/plugins/power_saver_info.cc
@@ -9,6 +9,7 @@
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/renderer/plugins/power_saver_info.h"
 #include "content/public/common/content_constants.h"
+#include "content/public/common/content_features.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/webplugininfo.h"
 #include "content/public/renderer/render_frame.h"
@@ -107,12 +108,14 @@
     // Early-exit from the whole Power Saver system if the content is
     // same-origin or whitelisted-origin. We ignore the other possibilities,
     // because we don't know the unobscured size of the plugin content yet.
+    // If we are filtering same-origin tiny content, we cannot early exit here.
     //
     // Once the plugin is loaded, the peripheral content status is re-tested
     // with the actual unobscured plugin size.
-    if (status == content::RenderFrame::CONTENT_STATUS_ESSENTIAL_SAME_ORIGIN ||
-        status == content::RenderFrame::
-                      CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED) {
+    if (!base::FeatureList::IsEnabled(features::kFilterSameOriginTinyPlugin) &&
+        (status == content::RenderFrame::CONTENT_STATUS_ESSENTIAL_SAME_ORIGIN ||
+         status == content::RenderFrame::
+                       CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED)) {
       info.power_saver_enabled = false;
     } else {
       info.poster_attribute = GetPluginInstancePosterAttribute(params);
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index eefb11e..7322e11 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -303,8 +303,14 @@
       "base/in_process_browser_test.cc",
       "base/in_process_browser_test.h",
       "base/in_process_browser_test_mac.cc",
+      "base/javascript_browser_test.cc",
+      "base/javascript_browser_test.h",
+      "base/test_chrome_web_ui_controller_factory.cc",
+      "base/test_chrome_web_ui_controller_factory.h",
       "base/ui_test_utils.cc",
       "base/ui_test_utils.h",
+      "base/web_ui_browser_test.cc",
+      "base/web_ui_browser_test.h",
     ]
 
     configs += [ "//build/config:precompiled_headers" ]
@@ -422,17 +428,22 @@
 
     data = [
       "data/",
+      "//chrome/third_party/mock4js/",
       "//content/test/data/",
       "//net/tools/testserver/",
       "//ppapi/tests/test_case.html",
       "//ppapi/tests/test_case.html.mock-http-headers",
       "//ppapi/tests/test_page.css",
       "//ppapi/tests/test_page.css.mock-http-headers",
+      "//third_party/accessibility-audit/axs_testing.js",
+      "//third_party/chaijs/chai.js",
+      "//third_party/mocha/mocha.js",
       "//third_party/pyftpdlib/",
       "//third_party/pywebsocket/",
       "//third_party/tlslite/",
       "//third_party/zlib/google/test/data/",
       "//tools/metrics/histograms/histograms.xml",
+      "//ui/webui/resources/js/",
       "$root_out_dir/pyproto/google/",
       "$root_out_dir/test_case.html",
       "$root_out_dir/test_case.html.mock-http-headers",
@@ -457,6 +468,7 @@
     ldflags = []
 
     deps = [
+      ":interactive_ui_tests_js_webui",
       ":test_support",
       ":test_support_ui",
       "//chrome:packed_resources",
@@ -913,6 +925,20 @@
     }
   }
 
+  js2gtest("interactive_ui_tests_js_webui") {
+    test_type = "webui"
+
+    sources = [
+      "data/webui/md_history/md_history_focus_test.js",
+    ]
+
+    deps = [
+      "//chrome/browser/ui",
+    ]
+
+    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
+  }
+
   js2gtest("browser_tests_js_webui") {
     test_type = "webui"
 
@@ -1312,7 +1338,6 @@
       "../browser/chrome_security_exploit_browsertest.cc",
       "../browser/chrome_site_per_process_browsertest.cc",
       "../browser/chrome_switches_browsertest.cc",
-      "../browser/collected_cookies_browsertest.cc",
       "../browser/content_settings/content_settings_browsertest.cc",
       "../browser/crash_recovery_browsertest.cc",
       "../browser/custom_handlers/protocol_handler_registry_browsertest.cc",
@@ -1725,6 +1750,7 @@
       "../browser/ui/browser_navigator_browsertest.h",
       "../browser/ui/browser_navigator_browsertest_chromeos.cc",
       "../browser/ui/browser_tabrestore_browsertest.cc",
+      "../browser/ui/collected_cookies_browsertest.cc",
       "../browser/ui/content_settings/content_setting_bubble_model_browsertest.cc",
       "../browser/ui/content_settings/content_setting_image_model_browsertest.cc",
       "../browser/ui/exclusive_access/fullscreen_controller_browsertest.cc",
@@ -1799,8 +1825,6 @@
       "../browser/ui/webui/signin/user_manager_ui_browsertest.cc",
       "../browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui_browsertest.cc",
       "../browser/ui/webui/uber/uber_ui_browsertest.cc",
-      "../browser/ui/webui/web_ui_test_handler.cc",
-      "../browser/ui/webui/web_ui_test_handler.h",
       "../browser/ui/webui/webui_browsertest.cc",
       "../browser/ui/webui/webui_webview_browsertest.cc",
       "../browser/ui/zoom/zoom_controller_browsertest.cc",
@@ -1833,14 +1857,8 @@
       "base/chrome_render_view_test.cc",
       "base/chrome_render_view_test.h",
       "base/in_process_browser_test_browsertest.cc",
-      "base/javascript_browser_test.cc",
-      "base/javascript_browser_test.h",
-      "base/test_chrome_web_ui_controller_factory.cc",
-      "base/test_chrome_web_ui_controller_factory.h",
       "base/test_chrome_web_ui_controller_factory_browsertest.cc",
       "base/tracing_browsertest.cc",
-      "base/web_ui_browser_test.cc",
-      "base/web_ui_browser_test.h",
       "base/web_ui_browser_test_browsertest.cc",
       "data/webui/async_gen.cc",
       "data/webui/async_gen.h",
diff --git a/chrome/test/data/plugin_power_saver/same_origin_tiny_plugin.html b/chrome/test/data/plugin_power_saver/same_origin_tiny_plugin.html
new file mode 100644
index 0000000..01c64b2
--- /dev/null
+++ b/chrome/test/data/plugin_power_saver/same_origin_tiny_plugin.html
@@ -0,0 +1,2 @@
+<object id='tiny_same_origin' data='fake.swf'
+    type='application/x-shockwave-flash' width='3' height='3'></object>
diff --git a/chrome/test/data/webui/md_history/history_list_test.js b/chrome/test/data/webui/md_history/history_list_test.js
index c270983..3987332 100644
--- a/chrome/test/data/webui/md_history/history_list_test.js
+++ b/chrome/test/data/webui/md_history/history_list_test.js
@@ -479,61 +479,6 @@
     });
   });
 
-  // Test is very flaky on all platforms, http://crbug.com/669227.
-  test.skip('focus and keyboard nav', function(done) {
-    app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
-    PolymerTest.flushTasks().then(function() {
-      var items = polymerSelectAll(element, 'history-item');
-
-      var focused = items[2].$.checkbox;
-      focused.focus();
-
-      // Wait for next render to ensure that focus handlers have been
-      // registered (see HistoryItemElement.attached).
-      Polymer.RenderStatus.afterNextRender(this, function() {
-        MockInteractions.pressAndReleaseKeyOn(
-            focused, 39, [], 'ArrowRight');
-        focused = items[2].$.title;
-        assertEquals(focused, element.lastFocused_);
-        assertTrue(items[2].row_.isActive());
-        assertFalse(items[3].row_.isActive());
-
-        MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
-        focused = items[3].$.title;
-        assertEquals(focused, element.lastFocused_);
-        assertFalse(items[2].row_.isActive());
-        assertTrue(items[3].row_.isActive());
-
-        MockInteractions.pressAndReleaseKeyOn(
-            focused, 39, [], 'ArrowRight');
-        focused = items[3].$['menu-button'];
-        assertEquals(focused, element.lastFocused_);
-        assertFalse(items[2].row_.isActive());
-        assertTrue(items[3].row_.isActive());
-
-        MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
-        focused = items[2].$['menu-button'];
-        assertEquals(focused, element.lastFocused_);
-        assertTrue(items[2].row_.isActive());
-        assertFalse(items[3].row_.isActive());
-
-        MockInteractions.pressAndReleaseKeyOn(focused, 37, [], 'ArrowLeft');
-        focused = items[2].$$('#bookmark-star');
-        assertEquals(focused, element.lastFocused_);
-        assertTrue(items[2].row_.isActive());
-        assertFalse(items[3].row_.isActive());
-
-        MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
-        focused = items[3].$.title;
-        assertEquals(focused, element.lastFocused_);
-        assertFalse(items[2].row_.isActive());
-        assertTrue(items[3].row_.isActive());
-
-        done();
-      });
-    });
-  });
-
   teardown(function() {
     registerMessageCallback('removeVisits', this, undefined);
     registerMessageCallback('queryHistory', this, function() {});
diff --git a/chrome/test/data/webui/md_history/history_synced_tabs_test.js b/chrome/test/data/webui/md_history/history_synced_tabs_test.js
index 8336ae0..b4080a4c 100644
--- a/chrome/test/data/webui/md_history/history_synced_tabs_test.js
+++ b/chrome/test/data/webui/md_history/history_synced_tabs_test.js
@@ -225,95 +225,6 @@
     });
   });
 
-  // Fails on Mac, http://crbug.com/640862
-  test.skip('focus and keyboard nav', function() {
-    var sessionList = [
-      createSession('Nexus 5', [createWindow([
-                      'http://www.example.com', 'http://www.google.com'
-                    ])]),
-      createSession('Pixel C', [createWindow(['http://www.badssl.com'])]),
-      createSession('Potato', [createWindow(['http://www.wikipedia.org'])]),
-    ];
-
-    setForeignSessions(sessionList);
-
-    var lastFocused;
-    var cards;
-    var focused;
-    var onFocusHandler = element.focusGrid_.onFocus;
-    element.focusGrid_.onFocus = function(row, e) {
-      onFocusHandler.call(element.focusGrid_, row, e);
-      lastFocused = e.currentTarget;
-    };
-
-    return PolymerTest.flushTasks().then(function() {
-      cards = polymerSelectAll(element, 'history-synced-device-card');
-
-      focused = cards[0].$['menu-button'];
-      focused.focus();
-
-      // Go to the collapse button.
-      MockInteractions.pressAndReleaseKeyOn(focused, 39, [], 'ArrowRight');
-      focused = cards[0].$['collapse-button'];
-      assertEquals(focused, lastFocused);
-
-      // Go to the first url.
-      MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
-      focused = polymerSelectAll(cards[0], '.website-title')[0];
-      assertEquals(focused, lastFocused);
-
-      // Collapse the first card.
-      MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
-      focused = cards[0].$['collapse-button'];
-      assertEquals(focused, lastFocused);
-      MockInteractions.tap(focused);
-    }).then(function() {
-      // Pressing down goes to the next card.
-      MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
-      focused = cards[1].$['collapse-button'];
-      assertEquals(focused, lastFocused);
-
-      // Expand the first card.
-      MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
-      focused = cards[0].$['collapse-button'];
-      assertEquals(focused, lastFocused);
-      MockInteractions.tap(focused);
-    }).then(function() {
-      // First card's urls are focusable again.
-      MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
-      focused = polymerSelectAll(cards[0], '.website-title')[0];
-      assertEquals(focused, lastFocused);
-
-      // Remove the second URL from the first card.
-      sessionList[0].windows[0].tabs.splice(1, 1);
-      setForeignSessions(sessionList.slice());
-      return PolymerTest.flushTasks();
-    }).then(function() {
-      cards = polymerSelectAll(element, 'history-synced-device-card');
-
-      // Go to the next card's menu buttons.
-      MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
-      focused = cards[1].$['collapse-button'];
-      assertEquals(focused, lastFocused);
-
-      MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
-      focused = polymerSelectAll(cards[0], '.website-title')[0];
-      assertEquals(focused, lastFocused);
-
-      // Remove the second card.
-      sessionList.splice(1, 1);
-      setForeignSessions(sessionList.slice());
-      return PolymerTest.flushTasks();
-    }).then(function() {
-      cards = polymerSelectAll(element, 'history-synced-device-card');
-
-      // Pressing down goes to the next card.
-      MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
-      focused = cards[1].$['collapse-button'];
-      assertEquals(focused, lastFocused);
-    });
-  });
-
   test('click synced tab', function(done) {
     setForeignSessions(
         [createSession(
diff --git a/chrome/test/data/webui/md_history/history_toolbar_test.js b/chrome/test/data/webui/md_history/history_toolbar_test.js
index e7d7d16a..ecd9a77 100644
--- a/chrome/test/data/webui/md_history/history_toolbar_test.js
+++ b/chrome/test/data/webui/md_history/history_toolbar_test.js
@@ -50,44 +50,22 @@
         app.queryState_.queryingDisabled = false;
         registerMessageCallback('queryHistory', this, function (info) {
           assertEquals('Test', info[0]);
+          app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
           done();
         });
 
         toolbar.$$('cr-toolbar').fire('search-changed', 'Test');
       });
 
-      test('shortcuts to open search field', function() {
-        var field = toolbar.$['main-toolbar'].getSearchField();
-        field.blur();
-        assertFalse(field.showingSearch);
-
-        MockInteractions.pressAndReleaseKeyOn(
-            document.body, 191, '', '/');
-        assertTrue(field.showingSearch);
-        assertEquals(field.$.searchInput, field.root.activeElement);
-
-        MockInteractions.pressAndReleaseKeyOn(
-            field.$.searchInput, 27, '', 'Escape');
-        assertFalse(field.showingSearch, 'Pressing escape closes field.');
-        assertNotEquals(field.$.searchInput, field.root.activeElement);
-
-        var modifier = 'ctrl';
-        if (cr.isMac)
-          modifier = 'meta';
-
-        MockInteractions.pressAndReleaseKeyOn(
-            document.body, 70, modifier, 'f');
-        assertTrue(field.showingSearch);
-        assertEquals(field.$.searchInput, field.root.activeElement);
-      });
-
       test('spinner is active on search' , function(done) {
         app.queryState_.queryingDisabled = false;
         registerMessageCallback('queryHistory', this, function (info) {
-          assertTrue(toolbar.spinnerActive);
-          app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
-          assertFalse(toolbar.spinnerActive);
-          done();
+          PolymerTest.flushTasks().then(function() {
+            assertTrue(toolbar.spinnerActive);
+            app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
+            assertFalse(toolbar.spinnerActive);
+            done();
+          });
         });
 
         toolbar.$$('cr-toolbar').fire('search-changed', 'Test2');
@@ -133,56 +111,3 @@
     registerTests: registerTests
   };
 });
-
-
-cr.define('md_history.history_toolbar_focus_test', function() {
-  function registerTests() {
-    suite('history-toolbar', function() {
-      var app;
-      var element;
-      var toolbar;
-      var TEST_HISTORY_RESULTS =
-          [createHistoryEntry('2016-03-15', 'https://google.com')];
-      ;
-
-      setup(function() {
-        window.resultsRendered = false;
-        app = replaceApp();
-
-        element = app.$['history'].$['infinite-list'];
-        toolbar = app.$['toolbar'];
-      });
-
-      test('search bar is focused on load in wide mode', function() {
-        toolbar.$['main-toolbar'].narrow_ = false;
-
-        historyResult(createHistoryInfo(), []);
-        return PolymerTest.flushTasks().then(() => {
-          // Ensure the search bar is focused on load.
-          assertTrue(
-              app.$.toolbar.$['main-toolbar']
-                  .getSearchField()
-                  .isSearchFocused());
-        });
-      });
-
-      test('search bar is not focused on load in narrow mode', function() {
-        toolbar.$['main-toolbar'].narrow_ = true;
-
-        historyResult(createHistoryInfo(), []);
-        return PolymerTest.flushTasks().then(() => {
-          // Ensure the search bar is focused on load.
-          assertFalse(
-              $('history-app')
-                  .$.toolbar.$['main-toolbar']
-                  .getSearchField()
-                  .isSearchFocused());
-        });
-      });
-    });
-  };
-
-  return {
-    registerTests: registerTests
-  };
-});
diff --git a/chrome/test/data/webui/md_history/md_history_browsertest.js b/chrome/test/data/webui/md_history/md_history_browsertest.js
index 76186a8..eeb1dcb 100644
--- a/chrome/test/data/webui/md_history/md_history_browsertest.js
+++ b/chrome/test/data/webui/md_history/md_history_browsertest.js
@@ -248,12 +248,7 @@
   ]),
 };
 
-TEST_F('MaterialHistoryToolbarTest', 'Basic', function() {
+TEST_F('MaterialHistoryToolbarTest', 'All', function() {
   md_history.history_toolbar_test.registerTests();
   mocha.run();
 });
-
-TEST_F('MaterialHistoryToolbarTest', 'Focus', function() {
-  md_history.history_toolbar_focus_test.registerTests();
-  mocha.run();
-});
diff --git a/chrome/test/data/webui/md_history/md_history_focus_test.js b/chrome/test/data/webui/md_history/md_history_focus_test.js
new file mode 100644
index 0000000..522a45a
--- /dev/null
+++ b/chrome/test/data/webui/md_history/md_history_focus_test.js
@@ -0,0 +1,285 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Tests for MD History which are run as interactive ui tests.
+ * Should be used for tests which care about focus.
+ */
+
+var ROOT_PATH = '../../../../../';
+
+GEN_INCLUDE(
+    [ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js']);
+GEN('#include "chrome/browser/ui/browser.h"');
+GEN('#include "chrome/browser/ui/tabs/tab_strip_model.h"');
+GEN('#include "content/public/browser/web_contents.h"');
+
+function MaterialHistoryFocusTest() {}
+
+MaterialHistoryFocusTest.prototype = {
+  __proto__: PolymerTest.prototype,
+
+  browsePreload: 'chrome://history',
+
+  extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([
+    'test_util.js',
+  ]),
+
+  setUp: function() {
+    PolymerTest.prototype.setUp.call(this);
+
+    suiteSetup(function() {
+      // Wait for the top-level app element to be upgraded.
+      return waitForAppUpgrade()
+          .then(() => md_history.ensureLazyLoaded())
+          .then(() => {
+            $('history-app').queryState_.queryingDisabled = true;
+          });
+    });
+  },
+};
+
+TEST_F('MaterialHistoryFocusTest', 'All', function() {
+  suite('<history-toolbar>', function() {
+    var app;
+    var toolbar;
+    var TEST_HISTORY_RESULTS =
+        [createHistoryEntry('2016-03-15', 'https://google.com')];
+
+    setup(function() {
+      window.resultsRendered = false;
+      app = replaceApp();
+
+      toolbar = app.$['toolbar'];
+    });
+
+    test('search bar is focused on load in wide mode', function() {
+      toolbar.$['main-toolbar'].narrow_ = false;
+
+      historyResult(createHistoryInfo(), []);
+      return PolymerTest.flushTasks().then(() => {
+        // Ensure the search bar is focused on load.
+        assertTrue(
+            app.$.toolbar.$['main-toolbar']
+            .getSearchField()
+            .isSearchFocused());
+      });
+    });
+
+    test('search bar is not focused on load in narrow mode', function() {
+      toolbar.$['main-toolbar'].narrow_ = true;
+
+      historyResult(createHistoryInfo(), []);
+      return PolymerTest.flushTasks().then(() => {
+        // Ensure the search bar is focused on load.
+        assertFalse(
+            $('history-app')
+            .$.toolbar.$['main-toolbar']
+            .getSearchField()
+            .isSearchFocused());
+      });
+    });
+
+    test('shortcuts to open search field', function() {
+      var field = toolbar.$['main-toolbar'].getSearchField();
+      field.blur();
+      assertFalse(field.showingSearch);
+
+      MockInteractions.pressAndReleaseKeyOn(
+          document.body, 191, '', '/');
+      assertTrue(field.showingSearch);
+      assertEquals(field.$.searchInput, field.root.activeElement);
+
+      MockInteractions.pressAndReleaseKeyOn(
+          field.$.searchInput, 27, '', 'Escape');
+      assertFalse(field.showingSearch, 'Pressing escape closes field.');
+      assertNotEquals(field.$.searchInput, field.root.activeElement);
+
+      var modifier = 'ctrl';
+      if (cr.isMac)
+        modifier = 'meta';
+
+      MockInteractions.pressAndReleaseKeyOn(
+          document.body, 70, modifier, 'f');
+      assertTrue(field.showingSearch);
+      assertEquals(field.$.searchInput, field.root.activeElement);
+    });
+  });
+
+  suite('<history-list>', function() {
+    var app;
+    var element;
+    var TEST_HISTORY_RESULTS;
+
+    suiteSetup(function() {
+      TEST_HISTORY_RESULTS = [
+        createHistoryEntry('2016-03-15', 'https://www.google.com'),
+        createHistoryEntry('2016-03-14 10:00', 'https://www.example.com'),
+        createHistoryEntry('2016-03-14 9:00', 'https://www.google.com'),
+        createHistoryEntry('2016-03-13', 'https://en.wikipedia.org')
+      ];
+      TEST_HISTORY_RESULTS[2].starred = true;
+    });
+
+    setup(function() {
+      app = replaceApp();
+      element = app.$['history'].$['infinite-list'];
+    });
+
+    test('list focus and keyboard nav', function(done) {
+      app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
+      PolymerTest.flushTasks().then(function() {
+        var items = polymerSelectAll(element, 'history-item');
+
+        var focused = items[2].$.checkbox;
+        focused.focus();
+
+        // Wait for next render to ensure that focus handlers have been
+        // registered (see HistoryItemElement.attached).
+        Polymer.RenderStatus.afterNextRender(this, function() {
+          MockInteractions.pressAndReleaseKeyOn(
+              focused, 39, [], 'ArrowRight');
+          focused = items[2].$.title;
+          assertEquals(focused, element.lastFocused_);
+          assertTrue(items[2].row_.isActive());
+          assertFalse(items[3].row_.isActive());
+
+          MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
+          focused = items[3].$.title;
+          assertEquals(focused, element.lastFocused_);
+          assertFalse(items[2].row_.isActive());
+          assertTrue(items[3].row_.isActive());
+
+          MockInteractions.pressAndReleaseKeyOn(
+              focused, 39, [], 'ArrowRight');
+          focused = items[3].$['menu-button'];
+          assertEquals(focused, element.lastFocused_);
+          assertFalse(items[2].row_.isActive());
+          assertTrue(items[3].row_.isActive());
+
+          MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
+          focused = items[2].$['menu-button'];
+          assertEquals(focused, element.lastFocused_);
+          assertTrue(items[2].row_.isActive());
+          assertFalse(items[3].row_.isActive());
+
+          MockInteractions.pressAndReleaseKeyOn(focused, 37, [], 'ArrowLeft');
+          focused = items[2].$$('#bookmark-star');
+          assertEquals(focused, element.lastFocused_);
+          assertTrue(items[2].row_.isActive());
+          assertFalse(items[3].row_.isActive());
+
+          MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
+          focused = items[3].$.title;
+          assertEquals(focused, element.lastFocused_);
+          assertFalse(items[2].row_.isActive());
+          assertTrue(items[3].row_.isActive());
+
+          done();
+        });
+      });
+    });
+  });
+
+  suite('<history-synced-device-manager>', function() {
+    var element;
+
+    setup(function() {
+      element = document.createElement('history-synced-device-manager');
+      element.signInState = true;
+      element.searchTerm = '';
+      replaceBody(element);
+    });
+
+    test('focus and keyboard nav', function() {
+      var sessionList = [
+        createSession('Nexus 5', [createWindow([
+                        'http://www.example.com', 'http://www.google.com'
+                      ])]),
+        createSession('Pixel C', [createWindow(['http://www.badssl.com'])]),
+        createSession('Potato', [createWindow(['http://www.wikipedia.org'])]),
+      ];
+
+      element.sessionList = sessionList;
+
+      var lastFocused;
+      var cards;
+      var focused;
+      var onFocusHandler = element.focusGrid_.onFocus;
+      element.focusGrid_.onFocus = function(row, e) {
+        onFocusHandler.call(element.focusGrid_, row, e);
+        lastFocused = e.currentTarget;
+      };
+
+      return PolymerTest.flushTasks().then(function() {
+        cards = polymerSelectAll(element, 'history-synced-device-card');
+
+        focused = cards[0].$['menu-button'];
+        focused.focus();
+
+        // Go to the collapse button.
+        MockInteractions.pressAndReleaseKeyOn(focused, 39, [], 'ArrowRight');
+        focused = cards[0].$['collapse-button'];
+        assertEquals(focused, lastFocused);
+
+        // Go to the first url.
+        MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
+        focused = polymerSelectAll(cards[0], '.website-title')[0];
+        assertEquals(focused, lastFocused);
+
+        // Collapse the first card.
+        MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
+        focused = cards[0].$['collapse-button'];
+        assertEquals(focused, lastFocused);
+        MockInteractions.tap(focused);
+      }).then(function() {
+        // Pressing down goes to the next card.
+        MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
+        focused = cards[1].$['collapse-button'];
+        assertEquals(focused, lastFocused);
+
+        // Expand the first card.
+        MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
+        focused = cards[0].$['collapse-button'];
+        assertEquals(focused, lastFocused);
+        MockInteractions.tap(focused);
+      }).then(function() {
+        // First card's urls are focusable again.
+        MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
+        focused = polymerSelectAll(cards[0], '.website-title')[0];
+        assertEquals(focused, lastFocused);
+
+        // Remove the second URL from the first card.
+        sessionList[0].windows[0].tabs.splice(1, 1);
+        element.sessionList = sessionList.slice();
+        return PolymerTest.flushTasks();
+      }).then(function() {
+        cards = polymerSelectAll(element, 'history-synced-device-card');
+
+        // Go to the next card's menu buttons.
+        MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
+        focused = cards[1].$['collapse-button'];
+        assertEquals(focused, lastFocused);
+
+        MockInteractions.pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
+        focused = polymerSelectAll(cards[0], '.website-title')[0];
+        assertEquals(focused, lastFocused);
+
+        // Remove the second card.
+        sessionList.splice(1, 1);
+        element.sessionList = sessionList.slice();
+        return PolymerTest.flushTasks();
+      }).then(function() {
+        cards = polymerSelectAll(element, 'history-synced-device-card');
+
+        // Pressing down goes to the next card.
+        MockInteractions.pressAndReleaseKeyOn(focused, 40, [], 'ArrowDown');
+        focused = cards[1].$['collapse-button'];
+        assertEquals(focused, lastFocused);
+      });
+    });
+  });
+
+  mocha.run();
+});
diff --git a/components/OWNERS b/components/OWNERS
index 897ff2c..fb6112e8a 100644
--- a/components/OWNERS
+++ b/components/OWNERS
@@ -16,6 +16,8 @@
 per-file ntp_snippets_strings.grdp=file://components/ntp_snippets/OWNERS
 per-file omnibox_strings.grdp=file://components/omnibox/OWNERS
 per-file password_manager_strings.grdp=file://components/password_manager/OWNERS
+per-file pageinfo_strings.grdp=estark@chromium.org
+per-file pageinfo_strings.grdp=lgarron@chromium.org
 per-file pdf_strings.grdp=raymes@chromium.org
 per-file pdf_strings.grdp=tsergeant@chromium.org
 per-file policy_strings.grdp=file://components/policy/OWNERS
diff --git a/components/error_page/renderer/net_error_helper_core.cc b/components/error_page/renderer/net_error_helper_core.cc
index 13cb441..3451b7e 100644
--- a/components/error_page/renderer/net_error_helper_core.cc
+++ b/components/error_page/renderer/net_error_helper_core.cc
@@ -658,6 +658,9 @@
     RecordEvent(NETWORK_ERROR_PAGE_CACHED_COPY_BUTTON_SHOWN);
   }
 
+  delegate_->SetIsShowingDownloadButton(
+      committed_error_page_info_->download_button_in_page);
+
   delegate_->EnablePageHelperFunctions();
 
   if (committed_error_page_info_->needs_load_navigation_corrections) {
diff --git a/components/error_page/renderer/net_error_helper_core.h b/components/error_page/renderer/net_error_helper_core.h
index d202e34..57d5194 100644
--- a/components/error_page/renderer/net_error_helper_core.h
+++ b/components/error_page/renderer/net_error_helper_core.h
@@ -110,6 +110,9 @@
     // Schedule to download the page at a later time.
     virtual void DownloadPageLater() = 0;
 
+    // Inform that download button is being shown in the error page.
+    virtual void SetIsShowingDownloadButton(bool show) = 0;
+
    protected:
     virtual ~Delegate() {}
   };
diff --git a/components/error_page/renderer/net_error_helper_core_unittest.cc b/components/error_page/renderer/net_error_helper_core_unittest.cc
index 79d84d68..db07d68 100644
--- a/components/error_page/renderer/net_error_helper_core_unittest.cc
+++ b/components/error_page/renderer/net_error_helper_core_unittest.cc
@@ -435,6 +435,8 @@
     download_count_++;
   }
 
+  void SetIsShowingDownloadButton(bool show) override {}
+
   void SendTrackingRequest(const GURL& tracking_url,
                            const std::string& tracking_request_body) override {
     last_tracking_url_ = tracking_url;
diff --git a/components/pageinfo_strings.grdp b/components/pageinfo_strings.grdp
index 25baa50..203605f 100644
--- a/components/pageinfo_strings.grdp
+++ b/components/pageinfo_strings.grdp
@@ -1,5 +1,48 @@
 <?xml version="1.0" encoding="utf-8"?>
 <grit-part>
+  <!-- Summary strings -->
+  <message name="IDS_PAGEINFO_SECURE_SUMMARY" desc="A short summary phrase at the top of the Page Info bubble (which shows when you click the lock icon) that indicates that the connection to the current website is secure.">
+    Secure connection
+  </message>
+  <message name="IDS_PAGEINFO_MIXED_CONTENT_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is using mainly using a secure connection but has some insecure parts (like insecurely loaded images).">
+    Your connection to this site is not fully secure
+  </message>
+  <message name="IDS_PAGEINFO_NOT_SECURE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is secure.">
+    Your connection to this site is not secure
+  </message>
+  <message name="IDS_PAGEINFO_MALWARE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as containing malware.">
+    This site contains malware
+  </message>
+  <message name="IDS_PAGEINFO_SOCIAL_ENGINEERING_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as social engineering.">
+    This site is deceptive
+  </message>
+  <message name="IDS_PAGEINFO_UNWANTED_SOFTWARE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as containing unwanted software.">
+    This site contains harmful programs
+  </message>
+
+  <!-- Detail strings -->
+  <message name="IDS_PAGEINFO_SECURE_DETAILS" desc="A short paragraph explaining a secure site to the user.">
+    Your information (for example, passwords or credit card numbers) is private when it is sent to this site.
+  </message>
+  <message name="IDS_PAGEINFO_MIXED_CONTENT_DETAILS" desc="A short paragraph explaining a partially insecure site to the user.">
+    Attackers might be able to see the images you’re looking at on this site and trick you by modifying them.
+  </message>
+  <message name="IDS_PAGEINFO_NOT_SECURE_DETAILS" desc="A short paragraph explaining a non-secure site to the user.">
+    You should not enter any sensitive information on this site (for example, passwords or credit cards), because it could be stolen by attackers.
+  </message>
+  <message name="IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION" desc="A short paragraph to the user that security warnings are disabled. This is the case when the user has encountered a certificate error for the current site and chosen to override it.">
+    You have chosen to disable security warnings for this site.
+  </message>
+  <message name="IDS_PAGEINFO_MALWARE_DETAILS" desc="A short paragraph explaining to the user that the current website has been flagged as containing malware.">
+    Attackers on this site might attempt to install dangerous programs on your computer that steal or delete your information (for example, photos, passwords, messages, and credit cards).
+  </message>
+  <message name="IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS" desc="A short paragraph explaining to the user that the current website has been flagged as social engineering.">
+    Attackers on this site may trick you into doing something dangerous like installing software or revealing your personal information (for example, passwords, phone numbers, or credit cards).
+  </message>
+  <message name="IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS" desc="A short paragraph explaining to the user that the current website has been flagged as containing unwanted software.">
+    Attackers on this site might try to trick you into installing programs that harm your browsing experience (for example, by changing your homepage or showing extra ads on sites you visit).
+  </message>
+
   <message name="IDS_PAGE_INFO_HELP_CENTER_LINK" desc="This is the text of the link pointing to the Help Center. This appears at the bottom of the SSL dialog and 'this' refers to the sections within the bubble.">
     What do these mean?
   </message>
diff --git a/components/safe_browsing_db/BUILD.gn b/components/safe_browsing_db/BUILD.gn
index 13bdd1b..24803b5 100644
--- a/components/safe_browsing_db/BUILD.gn
+++ b/components/safe_browsing_db/BUILD.gn
@@ -118,14 +118,26 @@
 
 source_set("safe_browsing_api_handler") {
   sources = [
+    "android/jni_registrar.cc",
+    "android/jni_registrar.h",
     "safe_browsing_api_handler.cc",
     "safe_browsing_api_handler.h",
   ]
   deps = [
+    ":safe_browsing_api_handler_util",
     ":util",
     "//base",
+    "//content/public/browser:browser",
     "//url",
   ]
+
+  if (is_android) {
+    deps += [ "//components/safe_browsing_db/android:jni_headers" ]
+    sources += [
+      "android/safe_browsing_api_handler_bridge.cc",
+      "android/safe_browsing_api_handler_bridge.h",
+    ]
+  }
 }
 
 static_library("safe_browsing_api_handler_util") {
diff --git a/components/safe_browsing_db/DEPS b/components/safe_browsing_db/DEPS
index 91ea0ff..e6985f9 100644
--- a/components/safe_browsing_db/DEPS
+++ b/components/safe_browsing_db/DEPS
@@ -6,6 +6,7 @@
   "+content/public/common",
   "+content/public/test",
   "+crypto",
+  "+jni",
   "+third_party/protobuf/src/google",
   "+net",
 ]
diff --git a/components/safe_browsing_db/android/BUILD.gn b/components/safe_browsing_db/android/BUILD.gn
new file mode 100644
index 0000000..32b2ff2
--- /dev/null
+++ b/components/safe_browsing_db/android/BUILD.gn
@@ -0,0 +1,23 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/android/config.gni")
+import("//build/config/android/rules.gni")
+android_library("safe_browsing_java") {
+  deps = [
+    "//base:base_java",
+    "//third_party/android_tools:android_support_annotations_java",
+  ]
+  java_files = [
+    "java/src/org/chromium/components/safe_browsing/SafeBrowsingApiBridge.java",
+    "java/src/org/chromium/components/safe_browsing/SafeBrowsingApiHandler.java",
+  ]
+}
+
+generate_jni("jni_headers") {
+  sources = [
+    "java/src/org/chromium/components/safe_browsing/SafeBrowsingApiBridge.java",
+  ]
+  jni_package = "components/safe_browsing_db/android"
+}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java b/components/safe_browsing_db/android/java/src/org/chromium/components/safe_browsing/SafeBrowsingApiBridge.java
similarity index 89%
rename from chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java
rename to components/safe_browsing_db/android/java/src/org/chromium/components/safe_browsing/SafeBrowsingApiBridge.java
index cd4668a..a06bd15 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java
+++ b/components/safe_browsing_db/android/java/src/org/chromium/components/safe_browsing/SafeBrowsingApiBridge.java
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-package org.chromium.chrome.browser.safe_browsing;
+package org.chromium.components.safe_browsing;
 
 import android.content.Context;
 
@@ -15,7 +15,7 @@
  */
 @JNINamespace("safe_browsing")
 public final class SafeBrowsingApiBridge {
-    private static final String TAG = "SafeBrowsingApi";
+    private static final String TAG = "ApiBridge";
 
     private static Class<? extends SafeBrowsingApiHandler> sHandler;
 
@@ -56,8 +56,8 @@
     }
 
     @CalledByNative
-    private static void startUriLookup(SafeBrowsingApiHandler handler, long callbackId,
-            String uri, int[] threatsOfInterest) {
+    private static void startUriLookup(
+            SafeBrowsingApiHandler handler, long callbackId, String uri, int[] threatsOfInterest) {
         handler.startUriLookup(callbackId, uri, threatsOfInterest);
         Log.d(TAG, "Done starting request");
     }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java b/components/safe_browsing_db/android/java/src/org/chromium/components/safe_browsing/SafeBrowsingApiHandler.java
similarity index 84%
rename from chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java
rename to components/safe_browsing_db/android/java/src/org/chromium/components/safe_browsing/SafeBrowsingApiHandler.java
index 6909946..7a3f656e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java
+++ b/components/safe_browsing_db/android/java/src/org/chromium/components/safe_browsing/SafeBrowsingApiHandler.java
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-package org.chromium.chrome.browser.safe_browsing;
+package org.chromium.components.safe_browsing;
 
 import android.content.Context;
 import android.support.annotation.IntDef;
@@ -11,8 +11,8 @@
 import java.lang.annotation.RetentionPolicy;
 
 /**
- * Java interface that a SafeBrowsingApiHander must implement when used with
- * {@code SafeBrowsignApiBridge}
+ * Java interface that a SafeBrowsingApiHandler must implement when used with
+ * {@code SafeBrowsingApiBridge}
  */
 public interface SafeBrowsingApiHandler {
     // Implementors must provide a no-arg constructor to be instantiated via reflection.
@@ -26,17 +26,12 @@
 
     // Possible values for resultStatus. Native side has the same definitions.
     @Retention(RetentionPolicy.SOURCE)
-    @IntDef({
-            STATUS_INTERNAL_ERROR,
-            STATUS_SUCCESS,
-            STATUS_TIMEOUT
-    })
+    @IntDef({STATUS_INTERNAL_ERROR, STATUS_SUCCESS, STATUS_TIMEOUT})
     @interface SafeBrowsingResult {}
     static final int STATUS_INTERNAL_ERROR = -1;
     static final int STATUS_SUCCESS = 0;
     static final int STATUS_TIMEOUT = 1;
 
-
     /**
      * Verifies that SafeBrowsingApiHandler can operate and initializes if feasible.
      * Should be called on IO thread.
diff --git a/components/safe_browsing_db/android/jni_registrar.cc b/components/safe_browsing_db/android/jni_registrar.cc
new file mode 100644
index 0000000..f340ccf
--- /dev/null
+++ b/components/safe_browsing_db/android/jni_registrar.cc
@@ -0,0 +1,25 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/safe_browsing_db/android/jni_registrar.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_registrar.h"
+#include "base/macros.h"
+#include "components/safe_browsing_db/android/safe_browsing_api_handler_bridge.h"
+
+namespace safe_browsing {
+namespace android {
+
+static base::android::RegistrationMethod kSafeBrowsingRegisteredMethods[] = {
+    {"SafeBrowsingApiBridge", safe_browsing::RegisterSafeBrowsingApiBridge},
+};
+
+bool RegisterBrowserJNI(JNIEnv* env) {
+  return RegisterNativeMethods(env, kSafeBrowsingRegisteredMethods,
+                               arraysize(kSafeBrowsingRegisteredMethods));
+}
+
+}  // namespace android
+}  // namespace safe_browsing
diff --git a/components/safe_browsing_db/android/jni_registrar.h b/components/safe_browsing_db/android/jni_registrar.h
new file mode 100644
index 0000000..5299b4b
--- /dev/null
+++ b/components/safe_browsing_db/android/jni_registrar.h
@@ -0,0 +1,19 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SAFE_BROWSING_DB_ANDROID_JNI_REGISTRAR_H
+#define COMPONENTS_SAFE_BROWSING_DB_ANDROID_JNI_REGISTRAR_H
+
+#include <jni.h>
+
+namespace safe_browsing {
+namespace android {
+
+// Register all JNI bindings necessary for chrome browser process.
+bool RegisterBrowserJNI(JNIEnv* env);
+
+}  // namespace android
+}  // namespace safe_browsing
+
+#endif  // COMPONENTS_SAFE_BROWSING_DB_ANDROID_JNI_REGISTRAR_H
diff --git a/chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.cc b/components/safe_browsing_db/android/safe_browsing_api_handler_bridge.cc
similarity index 95%
rename from chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.cc
rename to components/safe_browsing_db/android/safe_browsing_api_handler_bridge.cc
index 679521b0..c51337c 100644
--- a/chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.cc
+++ b/components/safe_browsing_db/android/safe_browsing_api_handler_bridge.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.h"
+#include "components/safe_browsing_db/android/safe_browsing_api_handler_bridge.h"
 
 #include <memory>
 #include <string>
@@ -12,7 +12,6 @@
 #include "base/android/jni_array.h"
 #include "base/android/jni_string.h"
 #include "base/metrics/histogram_macros.h"
-#include "chrome/browser/safe_browsing/safe_browsing_util.h"
 #include "components/safe_browsing_db/safe_browsing_api_handler_util.h"
 #include "content/public/browser/browser_thread.h"
 #include "jni/SafeBrowsingApiBridge_jni.h"
@@ -73,7 +72,6 @@
 
 }  // namespace
 
-
 bool RegisterSafeBrowsingApiBridge(JNIEnv* env) {
   return RegisterNativesImpl(env);
 }
@@ -145,15 +143,14 @@
 SafeBrowsingApiHandlerBridge::SafeBrowsingApiHandlerBridge()
     : checked_api_support_(false) {}
 
-SafeBrowsingApiHandlerBridge::~SafeBrowsingApiHandlerBridge() {
-}
+SafeBrowsingApiHandlerBridge::~SafeBrowsingApiHandlerBridge() {}
 
 bool SafeBrowsingApiHandlerBridge::CheckApiIsSupported() {
   DCHECK_CURRENTLY_ON(BrowserThread::IO);
   if (!checked_api_support_) {
     DVLOG(1) << "Checking API support.";
-    j_api_handler_ = Java_SafeBrowsingApiBridge_create(
-        AttachCurrentThread(), GetApplicationContext());
+    j_api_handler_ = Java_SafeBrowsingApiBridge_create(AttachCurrentThread(),
+                                                       GetApplicationContext());
     checked_api_support_ = true;
   }
   return j_api_handler_.obj() != nullptr;
diff --git a/chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.h b/components/safe_browsing_db/android/safe_browsing_api_handler_bridge.h
similarity index 85%
rename from chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.h
rename to components/safe_browsing_db/android/safe_browsing_api_handler_bridge.h
index ce5f0c58..678437a 100644
--- a/chrome/browser/android/safe_browsing/safe_browsing_api_handler_bridge.h
+++ b/components/safe_browsing_db/android/safe_browsing_api_handler_bridge.h
@@ -4,8 +4,8 @@
 //
 // Glue to pass Safe Browsing API requests between Chrome and GMSCore
 
-#ifndef CHROME_BROWSER_ANDROID_SAFE_BROWSING_SAFE_BROWSING_API_HANDLER_BRIDGE_H_
-#define CHROME_BROWSER_ANDROID_SAFE_BROWSING_SAFE_BROWSING_API_HANDLER_BRIDGE_H_
+#ifndef COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_BRIDGE_H_
+#define COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_BRIDGE_H_
 
 #include <jni.h>
 
@@ -45,4 +45,4 @@
 };
 
 }  // namespace safe_browsing
-#endif  // CHROME_BROWSER_ANDROID_SAFE_BROWSING_SAFE_BROWSING_API_HANDLER_BRIDGE_H_
+#endif  // COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_BRIDGE_H_
diff --git a/components/safe_browsing_db/v4_local_database_manager.cc b/components/safe_browsing_db/v4_local_database_manager.cc
index eaa1883..ffef84e 100644
--- a/components/safe_browsing_db/v4_local_database_manager.cc
+++ b/components/safe_browsing_db/v4_local_database_manager.cc
@@ -490,9 +490,11 @@
 void V4LocalDatabaseManager::GetSeverestThreatTypeAndMetadata(
     SBThreatType* result_threat_type,
     ThreatMetadata* metadata,
+    FullHash* matching_full_hash,
     const std::vector<FullHashInfo>& full_hash_infos) {
   DCHECK(result_threat_type);
   DCHECK(metadata);
+  DCHECK(matching_full_hash);
 
   ThreatSeverity most_severe_yet = kLeastSeverity;
   for (const FullHashInfo& fhi : full_hash_infos) {
@@ -501,6 +503,7 @@
       most_severe_yet = severity;
       *result_threat_type = GetSBThreatTypeForList(fhi.list_id);
       *metadata = fhi.metadata;
+      *matching_full_hash = fhi.full_hash;
     }
   }
 }
@@ -595,7 +598,8 @@
 
   // Find out the most severe threat, if any, to report to the client.
   GetSeverestThreatTypeAndMetadata(&check->result_threat_type,
-                                   &check->url_metadata, full_hash_infos);
+                                   &check->url_metadata,
+                                   &check->matching_full_hash, full_hash_infos);
   pending_checks_.erase(it);
   RespondToClient(std::move(check));
 }
@@ -649,21 +653,33 @@
     std::unique_ptr<PendingCheck> check) {
   DCHECK(check.get());
 
-  if (check->client_callback_type == ClientCallbackType::CHECK_BROWSE_URL) {
-    DCHECK_EQ(1u, check->urls.size());
-    check->client->OnCheckBrowseUrlResult(
-        check->urls[0], check->result_threat_type, check->url_metadata);
-  } else if (check->client_callback_type ==
-             ClientCallbackType::CHECK_DOWNLOAD_URLS) {
-    check->client->OnCheckDownloadUrlResult(check->urls,
-                                            check->result_threat_type);
-  } else if (check->client_callback_type ==
-             ClientCallbackType::CHECK_EXTENSION_IDS) {
-    const std::set<FullHash> extension_ids(check->full_hashes.begin(),
-                                           check->full_hashes.end());
-    check->client->OnCheckExtensionsResult(extension_ids);
-  } else {
-    NOTREACHED() << "Unexpected client_callback_type encountered";
+  switch (check->client_callback_type) {
+    case ClientCallbackType::CHECK_BROWSE_URL:
+      DCHECK_EQ(1u, check->urls.size());
+      check->client->OnCheckBrowseUrlResult(
+          check->urls[0], check->result_threat_type, check->url_metadata);
+      break;
+
+    case ClientCallbackType::CHECK_DOWNLOAD_URLS:
+      check->client->OnCheckDownloadUrlResult(check->urls,
+                                              check->result_threat_type);
+      break;
+
+    case ClientCallbackType::CHECK_RESOURCE_URL:
+      DCHECK_EQ(1u, check->urls.size());
+      check->client->OnCheckResourceUrlResult(
+          check->urls[0], check->result_threat_type, check->matching_full_hash);
+      break;
+
+    case ClientCallbackType::CHECK_EXTENSION_IDS: {
+      const std::set<FullHash> extension_ids(check->full_hashes.begin(),
+                                             check->full_hashes.end());
+      check->client->OnCheckExtensionsResult(extension_ids);
+      break;
+    }
+
+    case ClientCallbackType::CHECK_OTHER:
+      NOTREACHED() << "Unexpected client_callback_type encountered";
   }
 }
 
diff --git a/components/safe_browsing_db/v4_local_database_manager.h b/components/safe_browsing_db/v4_local_database_manager.h
index fe8ca73..7db100dc 100644
--- a/components/safe_browsing_db/v4_local_database_manager.h
+++ b/components/safe_browsing_db/v4_local_database_manager.h
@@ -148,6 +148,10 @@
     // The metadata associated with the full hash of the severest match found
     // for that URL.
     ThreatMetadata url_metadata;
+
+    // The full hash that matched for a blacklisted resource URL. Used only for
+    // |CheckResourceUrl| case.
+    FullHash matching_full_hash;
   };
 
   typedef std::vector<std::unique_ptr<PendingCheck>> QueuedChecks;
@@ -184,11 +188,12 @@
       const std::unique_ptr<PendingCheck>& check,
       FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes);
 
-  // Finds the most severe |SBThreatType| and the corresponding |metadata| from
-  // |full_hash_infos|.
+  // Finds the most severe |SBThreatType| and the corresponding |metadata|, and
+  // |matching_full_hash| from |full_hash_infos|.
   void GetSeverestThreatTypeAndMetadata(
       SBThreatType* result_threat_type,
       ThreatMetadata* metadata,
+      FullHash* matching_full_hash,
       const std::vector<FullHashInfo>& full_hash_infos);
 
   // Returns the SBThreatType for a given ListIdentifier.
diff --git a/components/safe_browsing_db/v4_local_database_manager_unittest.cc b/components/safe_browsing_db/v4_local_database_manager_unittest.cc
index 958fb2d..85df2f85 100644
--- a/components/safe_browsing_db/v4_local_database_manager_unittest.cc
+++ b/components/safe_browsing_db/v4_local_database_manager_unittest.cc
@@ -147,7 +147,8 @@
              V4LocalDatabaseManager* manager_to_cancel = nullptr)
       : expected_sb_threat_type(sb_threat_type),
         expected_url(url),
-        result_received_(false),
+        on_check_browse_url_result_called_(false),
+        on_check_resource_url_result_called_(false),
         manager_to_cancel_(manager_to_cancel) {}
 
   void OnCheckBrowseUrlResult(const GURL& url,
@@ -155,15 +156,27 @@
                               const ThreatMetadata& metadata) override {
     DCHECK_EQ(expected_url, url);
     DCHECK_EQ(expected_sb_threat_type, threat_type);
-    result_received_ = true;
+    on_check_browse_url_result_called_ = true;
     if (manager_to_cancel_) {
       manager_to_cancel_->CancelCheck(this);
     }
   }
 
+  void OnCheckResourceUrlResult(const GURL& url,
+                                SBThreatType threat_type,
+                                const std::string& threat_hash) override {
+    DCHECK_EQ(expected_url, url);
+    DCHECK_EQ(expected_sb_threat_type, threat_type);
+    // |threat_hash| is empty because GetFullHashes calls back with empty
+    // |full_hash_infos|.
+    DCHECK(threat_hash.empty());
+    on_check_resource_url_result_called_ = true;
+  }
+
   SBThreatType expected_sb_threat_type;
   GURL expected_url;
-  bool result_received_;
+  bool on_check_browse_url_result_called_;
+  bool on_check_resource_url_result_called_;
   V4LocalDatabaseManager* manager_to_cancel_;
 };
 
@@ -367,8 +380,8 @@
 TEST_F(V4LocalDatabaseManagerTest, TestGetSeverestThreatTypeAndMetadata) {
   WaitForTasksOnTaskRunner();
 
-  FullHashInfo fhi_malware(FullHash("Malware"), GetUrlMalwareId(),
-                           base::Time::Now());
+  FullHash full_hash("Malware");
+  FullHashInfo fhi_malware(full_hash, GetUrlMalwareId(), base::Time::Now());
   fhi_malware.metadata.population_id = "malware_popid";
 
   FullHashInfo fhi_api(FullHash("api"), GetChromeUrlApiId(), base::Time::Now());
@@ -378,18 +391,21 @@
 
   SBThreatType result_threat_type;
   ThreatMetadata metadata;
+  FullHash matching_full_hash;
 
   v4_local_database_manager_->GetSeverestThreatTypeAndMetadata(
-      &result_threat_type, &metadata, fhis);
+      &result_threat_type, &metadata, &matching_full_hash, fhis);
   EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, result_threat_type);
   EXPECT_EQ("malware_popid", metadata.population_id);
+  EXPECT_EQ(full_hash, matching_full_hash);
 
   // Reversing the list has no effect.
   std::reverse(std::begin(fhis), std::end(fhis));
   v4_local_database_manager_->GetSeverestThreatTypeAndMetadata(
-      &result_threat_type, &metadata, fhis);
+      &result_threat_type, &metadata, &matching_full_hash, fhis);
   EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, result_threat_type);
   EXPECT_EQ("malware_popid", metadata.population_id);
+  EXPECT_EQ(full_hash, matching_full_hash);
 }
 
 TEST_F(V4LocalDatabaseManagerTest, TestChecksAreQueued) {
@@ -435,9 +451,9 @@
   {
     TestClient client(SB_THREAT_TYPE_SAFE, url);
     EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl(url, &client));
-    EXPECT_FALSE(client.result_received_);
+    EXPECT_FALSE(client.on_check_browse_url_result_called_);
     WaitForTasksOnTaskRunner();
-    EXPECT_TRUE(client.result_received_);
+    EXPECT_TRUE(client.on_check_browse_url_result_called_);
   }
 
   // Test that cancel prevents the callback from being called.
@@ -445,9 +461,9 @@
     TestClient client(SB_THREAT_TYPE_SAFE, url);
     EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl(url, &client));
     v4_local_database_manager_->CancelCheck(&client);
-    EXPECT_FALSE(client.result_received_);
+    EXPECT_FALSE(client.on_check_browse_url_result_called_);
     WaitForTasksOnTaskRunner();
-    EXPECT_FALSE(client.result_received_);
+    EXPECT_FALSE(client.on_check_browse_url_result_called_);
   }
 }
 
@@ -462,11 +478,11 @@
   EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl(url, &client1));
   EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl(url, &client2));
   EXPECT_EQ(2ul, GetQueuedChecks().size());
-  EXPECT_FALSE(client1.result_received_);
-  EXPECT_FALSE(client2.result_received_);
+  EXPECT_FALSE(client1.on_check_browse_url_result_called_);
+  EXPECT_FALSE(client2.on_check_browse_url_result_called_);
   WaitForTasksOnTaskRunner();
-  EXPECT_TRUE(client1.result_received_);
-  EXPECT_TRUE(client2.result_received_);
+  EXPECT_TRUE(client1.on_check_browse_url_result_called_);
+  EXPECT_TRUE(client2.on_check_browse_url_result_called_);
 }
 
 // This test is somewhat similar to TestCheckBrowseUrlWithFakeDbReturnsMatch but
@@ -669,14 +685,40 @@
 
   // Wait for PerformFullHashCheck to complete.
   WaitForTasksOnTaskRunner();
-  // |result_received_| is true only if OnCheckBrowseUrlResult gets called with
-  // the |url| equal to |expected_url|, which is |second_url| in this test.
-  EXPECT_TRUE(client.result_received_);
+  // |on_check_browse_url_result_called_| is true only if OnCheckBrowseUrlResult
+  // gets called with the |url| equal to |expected_url|, which is |second_url|
+  // in
+  // this test.
+  EXPECT_TRUE(client.on_check_browse_url_result_called_);
+}
+
+TEST_F(V4LocalDatabaseManagerTest, TestCheckResourceUrl) {
+  // Setup to receive full-hash misses.
+  ScopedFakeGetHashProtocolManagerFactory pin;
+
+  // Reset the database manager so it picks up the replacement protocol manager.
+  ResetLocalDatabaseManager();
+  WaitForTasksOnTaskRunner();
+
+  // An URL and matching prefix.
+  const GURL url("http://example.com/a/");
+  const HashPrefix hash_prefix("eW\x1A\xF\xA9");
+
+  // Put a match in the db that will cause a protocol-manager request.
+  StoreAndHashPrefixes store_and_hash_prefixes;
+  store_and_hash_prefixes.emplace_back(GetChromeUrlClientIncidentId(),
+                                       hash_prefix);
+  ReplaceV4Database(store_and_hash_prefixes, true /* stores_available */);
+
+  TestClient client(SB_THREAT_TYPE_SAFE, url);
+  EXPECT_FALSE(v4_local_database_manager_->CheckResourceUrl(url, &client));
+  EXPECT_FALSE(client.on_check_resource_url_result_called_);
+  WaitForTasksOnTaskRunner();
+  EXPECT_TRUE(client.on_check_resource_url_result_called_);
 }
 
 // TODO(nparker): Add tests for
 //   CheckDownloadUrl()
 //   CheckExtensionIDs()
-//   CheckResourceUrl()
 
 }  // namespace safe_browsing
diff --git a/content/browser/blob_storage/blob_dispatcher_host_unittest.cc b/content/browser/blob_storage/blob_dispatcher_host_unittest.cc
index aca858f..f5ae770 100644
--- a/content/browser/blob_storage/blob_dispatcher_host_unittest.cc
+++ b/content/browser/blob_storage/blob_dispatcher_host_unittest.cc
@@ -115,7 +115,8 @@
     limits.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes;
     limits.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes;
     limits.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize;
-    limits.max_blob_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.desired_max_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.effective_max_disk_space = kTestBlobStorageMaxDiskSpace;
     limits.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
     limits.max_file_size = kTestBlobStorageMaxFileSizeBytes;
     context_->mutable_memory_controller()->set_limits_for_testing(limits);
diff --git a/content/browser/blob_storage/blob_flattener_unittest.cc b/content/browser/blob_storage/blob_flattener_unittest.cc
index b67066a..969fa8b6 100644
--- a/content/browser/blob_storage/blob_flattener_unittest.cc
+++ b/content/browser/blob_storage/blob_flattener_unittest.cc
@@ -118,7 +118,8 @@
     limits.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes;
     limits.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes;
     limits.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize;
-    limits.max_blob_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.desired_max_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.effective_max_disk_space = kTestBlobStorageMaxDiskSpace;
     limits.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
     limits.max_file_size = kTestBlobStorageMaxFileSizeBytes;
     context_->mutable_memory_controller()->set_limits_for_testing(limits);
diff --git a/content/browser/blob_storage/blob_memory_controller_unittest.cc b/content/browser/blob_storage/blob_memory_controller_unittest.cc
index ae0e796c..918315b3 100644
--- a/content/browser/blob_storage/blob_memory_controller_unittest.cc
+++ b/content/browser/blob_storage/blob_memory_controller_unittest.cc
@@ -9,6 +9,7 @@
 #include "base/files/scoped_temp_dir.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/sys_info.h"
 #include "base/test/test_simple_task_runner.h"
 #include "base/threading/thread_restrictions.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -34,6 +35,17 @@
 const uint64_t kTestBlobStorageMinFileSizeBytes = 10;
 const uint64_t kTestBlobStorageMaxFileSizeBytes = 100;
 
+const uint64_t kTestSmallBlobStorageMaxDiskSpace = 100;
+
+static int64_t sFakeDiskSpace = 0;
+static bool sFakeDiskSpaceCalled = true;
+
+int64_t FakeDiskSpaceMethod(const base::FilePath& path) {
+  EXPECT_FALSE(sFakeDiskSpaceCalled);
+  sFakeDiskSpaceCalled = true;
+  return sFakeDiskSpace;
+}
+
 class BlobMemoryControllerTest : public testing::Test {
  protected:
   BlobMemoryControllerTest() {}
@@ -53,6 +65,14 @@
     ASSERT_TRUE(temp_dir_.Delete());
   }
 
+  void AssertEnoughDiskSpace() {
+    base::ThreadRestrictions::SetIOAllowed(true);
+    ASSERT_GT(base::SysInfo::AmountOfFreeDiskSpace(temp_dir_.GetPath()),
+              static_cast<int64_t>(kTestBlobStorageMaxDiskSpace))
+        << "Bot doesn't have enough disk space to run these tests.";
+    base::ThreadRestrictions::SetIOAllowed(false);
+  }
+
   std::vector<scoped_refptr<ShareableBlobDataItem>> CreateSharedDataItems(
       const BlobDataBuilder& builder) {
     std::vector<scoped_refptr<ShareableBlobDataItem>> result;
@@ -68,7 +88,20 @@
     limits.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes;
     limits.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes;
     limits.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize;
-    limits.max_blob_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.desired_max_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.effective_max_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
+    limits.max_file_size = kTestBlobStorageMaxFileSizeBytes;
+    controller->set_limits_for_testing(limits);
+  }
+
+  void SetSmallDiskTestMemoryLimits(BlobMemoryController* controller) {
+    BlobStorageLimits limits;
+    limits.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes;
+    limits.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes;
+    limits.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize;
+    limits.desired_max_disk_space = kTestSmallBlobStorageMaxDiskSpace;
+    limits.effective_max_disk_space = kTestSmallBlobStorageMaxDiskSpace;
     limits.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
     limits.max_file_size = kTestBlobStorageMaxFileSizeBytes;
     controller->set_limits_for_testing(limits);
@@ -81,6 +114,10 @@
     }
   }
 
+  void SaveMemoryRequestToOutput(bool* output, bool success) {
+    ASSERT_TRUE(output);
+    *output = success;
+  }
   void SaveMemoryRequest(bool success) { memory_quota_result_ = success; }
 
   BlobMemoryController::FileQuotaRequestCallback GetFileCreationCallback() {
@@ -93,6 +130,12 @@
                       base::Unretained(this));
   }
 
+  BlobMemoryController::MemoryQuotaRequestCallback
+  GetMemoryRequestCallbackToOutput(bool* output) {
+    return base::Bind(&BlobMemoryControllerTest::SaveMemoryRequestToOutput,
+                      base::Unretained(this), output);
+  }
+
   void RunFileThreadTasks() {
     base::ThreadRestrictions::SetIOAllowed(true);
     file_runner_->RunPendingTasks();
@@ -103,6 +146,13 @@
     return static_cast<bool>(item->memory_allocation_);
   }
 
+  void set_disk_space(int64_t space) {
+    sFakeDiskSpaceCalled = false;
+    sFakeDiskSpace = space;
+  }
+
+  void ExpectDiskSpaceCalled() { EXPECT_TRUE(sFakeDiskSpaceCalled); }
+
   bool file_quota_result_ = false;
   base::ScopedTempDir temp_dir_;
   std::vector<FileCreationInfo> files_created_;
@@ -159,6 +209,16 @@
     EXPECT_EQ(Strategy::TOO_LARGE, controller.DetermineStrategy(
                                        0, kTestBlobStorageMaxDiskSpace + 1));
   }
+  {
+    BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+    SetSmallDiskTestMemoryLimits(&controller);
+
+    EXPECT_TRUE(controller.CanReserveQuota(kTestBlobStorageMaxBlobMemorySize));
+    // Since our disk is too small, this should be sent with shared memory.
+    EXPECT_EQ(
+        Strategy::SHARED_MEMORY,
+        controller.DetermineStrategy(0, kTestBlobStorageMaxBlobMemorySize));
+  }
 }
 
 TEST_F(BlobMemoryControllerTest, GrantMemory) {
@@ -215,6 +275,7 @@
   const std::string kId2 = "id2";
   BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
   SetTestMemoryLimits(&controller);
+  AssertEnoughDiskSpace();
 
   char kData[kTestBlobStorageMaxBlobMemorySize];
   std::memset(kData, 'e', kTestBlobStorageMaxBlobMemorySize);
@@ -281,7 +342,6 @@
 }
 
 TEST_F(BlobMemoryControllerTest, NoDiskTooLarge) {
-  const std::string kId = "id";
   BlobMemoryController controller(temp_dir_.GetPath(), nullptr);
   SetTestMemoryLimits(&controller);
 
@@ -291,7 +351,6 @@
 }
 
 TEST_F(BlobMemoryControllerTest, TooLargeForDisk) {
-  const std::string kId = "id";
   BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
   SetTestMemoryLimits(&controller);
 
@@ -441,11 +500,10 @@
 
   task->Cancel();
   EXPECT_FALSE(task);
-  EXPECT_EQ(kBlobSize, controller.disk_usage());
-  EXPECT_TRUE(file_runner_->HasPendingTask());
+  EXPECT_EQ(0ull, controller.disk_usage());
+
   RunFileThreadTasks();
   base::RunLoop().RunUntilIdle();
-  EXPECT_EQ(0u, controller.disk_usage());
 }
 
 TEST_F(BlobMemoryControllerTest, MultipleFilesPaged) {
@@ -467,6 +525,7 @@
 
   BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
   SetTestMemoryLimits(&controller);
+  AssertEnoughDiskSpace();
 
   // We add two items that should be their own files when we page to disk, and
   // then add the last item to trigger the paging.
@@ -543,6 +602,7 @@
 TEST_F(BlobMemoryControllerTest, FullEviction) {
   BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
   SetTestMemoryLimits(&controller);
+  AssertEnoughDiskSpace();
 
   char kData[1];
   kData[0] = 'e';
@@ -594,6 +654,132 @@
   EXPECT_TRUE(memory_quota_result_);
 }
 
+TEST_F(BlobMemoryControllerTest, PagingStopsWhenFull) {
+  BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+  SetTestMemoryLimits(&controller);
+  AssertEnoughDiskSpace();
+  const size_t kTotalBlobStorageSize =
+      kTestBlobStorageMaxDiskSpace + kTestBlobStorageMaxBlobMemorySize;
+
+  const size_t kDataSize = 10u;
+  const size_t kBlobsThatCanFit = kTotalBlobStorageSize / kDataSize;
+  const size_t kNumFastBlobs = kTestBlobStorageMaxBlobMemorySize / kDataSize;
+  char kData[10];
+  memset(kData, 'e', kDataSize);
+
+  // Create all of our blobs.
+  std::vector<scoped_refptr<ShareableBlobDataItem>> all_items;
+  std::vector<base::WeakPtr<QuotaAllocationTask>> memory_tasks;
+  bool memory_requested[kBlobsThatCanFit] = {};
+  for (size_t i = 0; i < kBlobsThatCanFit; i++) {
+    BlobDataBuilder builder("fake");
+    builder.AppendData(kData, kDataSize);
+    std::vector<scoped_refptr<ShareableBlobDataItem>> items =
+        CreateSharedDataItems(builder);
+    EXPECT_TRUE(controller.CanReserveQuota(kDataSize));
+    EXPECT_EQ((i < kNumFastBlobs) ? Strategy::NONE_NEEDED : Strategy::IPC,
+              controller.DetermineStrategy(kDataSize, kDataSize))
+        << i;
+    base::WeakPtr<QuotaAllocationTask> memory_task =
+        controller.ReserveMemoryQuota(
+            items, GetMemoryRequestCallbackToOutput(&memory_requested[i]));
+    if (memory_task) {
+      memory_tasks.push_back(std::move(memory_task));
+    }
+    all_items.insert(all_items.end(), items.begin(), items.end());
+  }
+  // We should have stored all of our memory quota, and no disk yet.
+  EXPECT_EQ(500u, controller.memory_usage());
+  EXPECT_EQ(0ull, controller.disk_usage());
+
+  EXPECT_FALSE(controller.CanReserveQuota(1u));
+  EXPECT_EQ(Strategy::TOO_LARGE, controller.DetermineStrategy(1u, 1ull));
+  EXPECT_FALSE(file_runner_->HasPendingTask());
+
+  for (size_t i = 0; i < kBlobsThatCanFit; i++) {
+    EXPECT_EQ(i < kBlobsThatCanFit / 3, memory_requested[i]) << i;
+    if (memory_requested[i] &&
+        all_items[i]->state() != ItemState::POPULATED_WITH_QUOTA) {
+      EXPECT_TRUE(memory_requested[i]);
+      all_items[i]->set_state(ItemState::POPULATED_WITH_QUOTA);
+      std::vector<scoped_refptr<ShareableBlobDataItem>> temp_vector;
+      temp_vector.push_back(all_items[i]);
+      controller.NotifyMemoryItemsUsed(temp_vector);
+    }
+  }
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+
+  // This will schedule one task. Paging starts as soon as there is enough
+  // memory to page, and multiple pagings can't happen at the same time.
+  EXPECT_EQ(10ull, controller.disk_usage());
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+  // The rest of the tasks should be scheduled.
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+  // Everything in memory should be on disk, and next batch of memory items
+  // should be granted.
+  EXPECT_EQ(500u, controller.memory_usage());
+  EXPECT_EQ(500ull, controller.disk_usage());
+
+  // Still can't add anything.
+  EXPECT_FALSE(controller.CanReserveQuota(1u));
+  EXPECT_EQ(Strategy::TOO_LARGE, controller.DetermineStrategy(1u, 1ull));
+
+  // Flag next batch for saving to disk.
+  for (size_t i = 0; i < kBlobsThatCanFit; i++) {
+    // Note: this can fail if the bot's disk is almost full.
+    EXPECT_EQ(i < kBlobsThatCanFit * 2 / 3, memory_requested[i]) << i;
+    if (memory_requested[i] &&
+        all_items[i]->state() != ItemState::POPULATED_WITH_QUOTA) {
+      all_items[i]->set_state(ItemState::POPULATED_WITH_QUOTA);
+      std::vector<scoped_refptr<ShareableBlobDataItem>> temp_vector;
+      temp_vector.push_back(all_items[i]);
+      controller.NotifyMemoryItemsUsed(temp_vector);
+    }
+  }
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+
+  // Same as before. One page task is scheduled, so run them twice.
+  EXPECT_EQ(510ull, controller.disk_usage());
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+  // We page one time first, as it blocks paging once it starts.
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+
+  // All quota should be allocated.
+  EXPECT_EQ(kTestBlobStorageMaxBlobMemorySize, controller.memory_usage());
+  EXPECT_EQ(kTestBlobStorageMaxDiskSpace, controller.disk_usage());
+  EXPECT_FALSE(controller.CanReserveQuota(1u));
+  EXPECT_EQ(Strategy::TOO_LARGE, controller.DetermineStrategy(1u, 1ull));
+
+  // Flag last batch as populated.
+  for (size_t i = 0; i < kBlobsThatCanFit; i++) {
+    // Note: this can fail if the bot's disk is almost full.
+    EXPECT_TRUE(memory_requested[i]);
+    if (memory_requested[i] &&
+        all_items[i]->state() != ItemState::POPULATED_WITH_QUOTA) {
+      all_items[i]->set_state(ItemState::POPULATED_WITH_QUOTA);
+      std::vector<scoped_refptr<ShareableBlobDataItem>> temp_vector;
+      temp_vector.push_back(all_items[i]);
+      controller.NotifyMemoryItemsUsed(temp_vector);
+    }
+  }
+
+  // There should be no more paging to disk, as we've reached the end.
+  EXPECT_FALSE(file_runner_->HasPendingTask());
+
+  // All quota should be allocated still.
+  EXPECT_EQ(500u, controller.memory_usage());
+  EXPECT_EQ(1000ull, controller.disk_usage());
+
+  // Still can't add anything.
+  EXPECT_FALSE(controller.CanReserveQuota(1u));
+  EXPECT_EQ(Strategy::TOO_LARGE, controller.DetermineStrategy(1u, 1ull));
+}
+
 TEST_F(BlobMemoryControllerTest, DisableDiskWithFileAndMemoryPending) {
   const std::string kFirstMemoryId = "id";
   const uint64_t kFirstMemorySize = kTestBlobStorageMaxBlobMemorySize;
@@ -677,4 +863,261 @@
   EXPECT_EQ(0ull, controller.disk_usage());
   EXPECT_EQ(0ull, controller.memory_usage());
 }
+
+TEST_F(BlobMemoryControllerTest, DiskSpaceTooSmallForItem) {
+  const std::string kFileId = "id2";
+  const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
+
+  BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+  controller.set_testing_disk_space(&FakeDiskSpaceMethod);
+
+  BlobDataBuilder file_builder(kFileId);
+  file_builder.AppendFutureFile(0, kFileBlobSize, 0);
+
+  // When we have < kFileBlobSize, then we cancel our request.
+  SetTestMemoryLimits(&controller);
+
+  std::vector<scoped_refptr<ShareableBlobDataItem>> items =
+      CreateSharedDataItems(file_builder);
+
+  file_quota_result_ = true;
+  controller.ReserveFileQuota(items, GetFileCreationCallback());
+
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  set_disk_space(kFileBlobSize - 1);
+
+  RunFileThreadTasks();
+  ExpectDiskSpaceCalled();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_FALSE(file_quota_result_);
+  EXPECT_TRUE(controller.limits().IsDiskSpaceConstrained());
+  EXPECT_EQ(0ull, controller.limits().effective_max_disk_space);
+
+  EXPECT_EQ(0ull, controller.disk_usage());
+  EXPECT_EQ(0ull, controller.memory_usage());
+}
+
+TEST_F(BlobMemoryControllerTest, DiskSpaceHitMinAvailable) {
+  const std::string kFileId = "id2";
+  const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
+
+  BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+  controller.set_testing_disk_space(&FakeDiskSpaceMethod);
+
+  BlobDataBuilder file_builder(kFileId);
+  file_builder.AppendFutureFile(0, kFileBlobSize, 0);
+  // When we have < limits.min_available_external_disk_space(), then we'll
+  // modify our effective disk space to match our current usage to stop using
+  // more disk.
+
+  SetTestMemoryLimits(&controller);
+
+  std::vector<scoped_refptr<ShareableBlobDataItem>> items =
+      CreateSharedDataItems(file_builder);
+
+  file_quota_result_ = false;
+  controller.ReserveFileQuota(items, GetFileCreationCallback());
+
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  set_disk_space(controller.limits().min_available_external_disk_space() - 1);
+
+  RunFileThreadTasks();
+  ExpectDiskSpaceCalled();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_TRUE(file_quota_result_);
+  EXPECT_TRUE(controller.limits().IsDiskSpaceConstrained());
+  EXPECT_EQ(kFileBlobSize, controller.limits().effective_max_disk_space);
+
+  items.clear();
+  files_created_.clear();
+
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_EQ(0ull, controller.disk_usage());
+  EXPECT_EQ(0ull, controller.memory_usage());
+}
+
+TEST_F(BlobMemoryControllerTest, DiskSpaceBeforeMinAvailable) {
+  const std::string kFileId = "id2";
+
+  BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+  controller.set_testing_disk_space(&FakeDiskSpaceMethod);
+
+  BlobDataBuilder file_builder(kFileId);
+  file_builder.AppendFutureFile(0, kTestBlobStorageMaxBlobMemorySize, 0);
+
+  // When our desired total disk space is less than we're allowed given the
+  //  minimum disk availability, we shorten the disk space.
+  SetTestMemoryLimits(&controller);
+
+  std::vector<scoped_refptr<ShareableBlobDataItem>> items =
+      CreateSharedDataItems(file_builder);
+
+  file_quota_result_ = false;
+  controller.ReserveFileQuota(items, GetFileCreationCallback());
+
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  set_disk_space(controller.limits().desired_max_disk_space +
+                 controller.limits().min_available_external_disk_space() + 1);
+
+  RunFileThreadTasks();
+  ExpectDiskSpaceCalled();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_TRUE(file_quota_result_);
+  EXPECT_FALSE(controller.limits().IsDiskSpaceConstrained())
+      << controller.limits().effective_max_disk_space;
+
+  items.clear();
+  files_created_.clear();
+
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_EQ(0ull, controller.disk_usage());
+  EXPECT_EQ(0ull, controller.memory_usage());
+}
+
+TEST_F(BlobMemoryControllerTest, DiskSpaceNearMinAvailable) {
+  const std::string kFileId = "id2";
+
+  BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+  controller.set_testing_disk_space(&FakeDiskSpaceMethod);
+
+  BlobDataBuilder file_builder(kFileId);
+  file_builder.AppendFutureFile(0, kTestBlobStorageMaxBlobMemorySize, 0);
+
+  // When our desired total disk space is less than we're allowed given the
+  //  minimum disk availability, we shorten the disk space.
+  SetTestMemoryLimits(&controller);
+
+  std::vector<scoped_refptr<ShareableBlobDataItem>> items =
+      CreateSharedDataItems(file_builder);
+
+  file_quota_result_ = false;
+  controller.ReserveFileQuota(items, GetFileCreationCallback());
+
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  set_disk_space(controller.limits().desired_max_disk_space +
+                 controller.limits().min_available_external_disk_space() - 1);
+
+  RunFileThreadTasks();
+  ExpectDiskSpaceCalled();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_TRUE(file_quota_result_);
+  EXPECT_TRUE(controller.limits().IsDiskSpaceConstrained());
+  EXPECT_EQ(controller.limits().desired_max_disk_space - 1,
+            controller.limits().effective_max_disk_space);
+
+  items.clear();
+  files_created_.clear();
+
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_EQ(0ull, controller.disk_usage());
+  EXPECT_EQ(0ull, controller.memory_usage());
+}
+
+TEST_F(BlobMemoryControllerTest, DiskSpaceResetAfterIncrease) {
+  const std::string kFileId = "id2";
+  const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
+
+  BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+  controller.set_testing_disk_space(&FakeDiskSpaceMethod);
+
+  BlobDataBuilder file_builder(kFileId);
+  file_builder.AppendFutureFile(0, kFileBlobSize, 0);
+
+  // When we do a file operation after disk has been freed (after we've been
+  // limited), our effective size grows correctly.
+  SetTestMemoryLimits(&controller);
+
+  std::vector<scoped_refptr<ShareableBlobDataItem>> items =
+      CreateSharedDataItems(file_builder);
+
+  controller.ReserveFileQuota(items, GetFileCreationCallback());
+
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  set_disk_space(controller.limits().min_available_external_disk_space() - 1);
+
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+
+  // Check the effective limit is constrained.
+  EXPECT_TRUE(controller.limits().IsDiskSpaceConstrained());
+  EXPECT_EQ(kFileBlobSize, controller.limits().effective_max_disk_space);
+
+  // Delete the item so we have disk quota.
+  items.clear();
+  files_created_.clear();
+
+  RunFileThreadTasks();
+  ExpectDiskSpaceCalled();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_EQ(0ull, controller.disk_usage());
+  EXPECT_EQ(0ull, controller.memory_usage());
+
+  // Create the same item, but have the disk space report the minimum amount
+  // needed to have the desired disk size.
+  items = CreateSharedDataItems(file_builder);
+
+  controller.ReserveFileQuota(items, GetFileCreationCallback());
+
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  set_disk_space(kTestBlobStorageMaxDiskSpace +
+                 controller.limits().min_available_external_disk_space());
+
+  RunFileThreadTasks();
+  ExpectDiskSpaceCalled();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_FALSE(controller.limits().IsDiskSpaceConstrained());
+  EXPECT_EQ(controller.limits().desired_max_disk_space,
+            controller.limits().effective_max_disk_space);
+
+  items.clear();
+  files_created_.clear();
+
+  RunFileThreadTasks();
+  base::RunLoop().RunUntilIdle();
+
+  EXPECT_EQ(0ull, controller.disk_usage());
+  EXPECT_EQ(0ull, controller.memory_usage());
+}
+
+TEST_F(BlobMemoryControllerTest, DiskSpaceUnknown) {
+  const std::string kFileId = "id2";
+  const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
+
+  BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
+  controller.set_testing_disk_space(&FakeDiskSpaceMethod);
+
+  BlobDataBuilder file_builder(kFileId);
+  file_builder.AppendFutureFile(0, kFileBlobSize, 0);
+
+  // If the disk space returns an error (-1), then we ignore that signal.
+  SetTestMemoryLimits(&controller);
+
+  std::vector<scoped_refptr<ShareableBlobDataItem>> items =
+      CreateSharedDataItems(file_builder);
+
+  controller.ReserveFileQuota(items, GetFileCreationCallback());
+
+  EXPECT_TRUE(file_runner_->HasPendingTask());
+  set_disk_space(-1ll);
+
+  RunFileThreadTasks();
+  ExpectDiskSpaceCalled();
+  base::RunLoop().RunUntilIdle();
+
+  // Check the effective limit is constrained.
+  EXPECT_FALSE(controller.limits().IsDiskSpaceConstrained());
+}
+
 }  // namespace storage
diff --git a/content/browser/blob_storage/blob_storage_browsertest.cc b/content/browser/blob_storage/blob_storage_browsertest.cc
index 4b315088..2510bb3 100644
--- a/content/browser/blob_storage/blob_storage_browsertest.cc
+++ b/content/browser/blob_storage/blob_storage_browsertest.cc
@@ -34,7 +34,8 @@
     limits_.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes;
     limits_.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes;
     limits_.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize;
-    limits_.max_blob_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits_.desired_max_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits_.effective_max_disk_space = kTestBlobStorageMaxDiskSpace;
     limits_.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
     limits_.max_file_size = kTestBlobStorageMaxFileSizeBytes;
   }
@@ -88,7 +89,7 @@
             static_cast<uint64_t>(memory_controller->memory_usage()));
   EXPECT_GT(limits_.max_blob_in_memory_space,
             memory_controller->memory_usage());
-  EXPECT_GT(limits_.max_blob_disk_space, memory_controller->disk_usage());
+  EXPECT_GT(limits_.effective_max_disk_space, memory_controller->disk_usage());
   shell()->Close();
 
   // Make sure we run all file / io tasks.
diff --git a/content/browser/blob_storage/blob_storage_context_unittest.cc b/content/browser/blob_storage/blob_storage_context_unittest.cc
index 44f18db2..2cb57283 100644
--- a/content/browser/blob_storage/blob_storage_context_unittest.cc
+++ b/content/browser/blob_storage/blob_storage_context_unittest.cc
@@ -142,7 +142,8 @@
     limits.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes;
     limits.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes;
     limits.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize;
-    limits.max_blob_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.desired_max_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.effective_max_disk_space = kTestBlobStorageMaxDiskSpace;
     limits.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
     limits.max_file_size = kTestBlobStorageMaxFileSizeBytes;
     context_->mutable_memory_controller()->set_limits_for_testing(limits);
diff --git a/content/browser/blob_storage/blob_transport_host_unittest.cc b/content/browser/blob_storage/blob_transport_host_unittest.cc
index 55877d9..481e2f0a 100644
--- a/content/browser/blob_storage/blob_transport_host_unittest.cc
+++ b/content/browser/blob_storage/blob_transport_host_unittest.cc
@@ -83,7 +83,8 @@
     limits.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes;
     limits.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes;
     limits.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize;
-    limits.max_blob_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.desired_max_disk_space = kTestBlobStorageMaxDiskSpace;
+    limits.effective_max_disk_space = kTestBlobStorageMaxDiskSpace;
     limits.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
     limits.max_file_size = kTestBlobStorageMaxFileSizeBytes;
     context_.mutable_memory_controller()->set_limits_for_testing(limits);
diff --git a/content/browser/blob_storage/chrome_blob_storage_context.cc b/content/browser/blob_storage/chrome_blob_storage_context.cc
index bd02e514..3192cd0d 100644
--- a/content/browser/blob_storage/chrome_blob_storage_context.cc
+++ b/content/browser/blob_storage/chrome_blob_storage_context.cc
@@ -20,6 +20,7 @@
 #include "content/public/browser/browser_thread.h"
 #include "storage/browser/blob/blob_data_builder.h"
 #include "storage/browser/blob/blob_data_handle.h"
+#include "storage/browser/blob/blob_memory_controller.h"
 #include "storage/browser/blob/blob_storage_context.h"
 
 using base::FilePath;
@@ -44,12 +45,15 @@
   base::FileEnumerator enumerator(blob_storage_parent, false /* recursive */,
                                   base::FileEnumerator::DIRECTORIES);
   bool success = true;
+  bool cleanup_needed = false;
   for (FilePath name = enumerator.Next(); !name.empty();
        name = enumerator.Next()) {
+    cleanup_needed = true;
     if (current_run_dir.empty() || name != current_run_dir)
       success &= base::DeleteFile(name, true /* recursive */);
   }
-  LOCAL_HISTOGRAM_BOOLEAN("Storage.Blob.CleanupSuccess", success);
+  if (cleanup_needed)
+    UMA_HISTOGRAM_BOOLEAN("Storage.Blob.CleanupSuccess", success);
 }
 
 class BlobHandleImpl : public BlobHandle {
@@ -123,6 +127,12 @@
   DCHECK_CURRENTLY_ON(BrowserThread::IO);
   context_.reset(new BlobStorageContext(std::move(blob_storage_dir),
                                         std::move(file_task_runner)));
+  // Signal the BlobMemoryController when it's appropriate to calculate its
+  // storage limits.
+  BrowserThread::PostAfterStartupTask(
+      FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
+      base::Bind(&storage::BlobMemoryController::CalculateBlobStorageLimits,
+                 context_->mutable_memory_controller()->GetWeakPtr()));
 }
 
 std::unique_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob(
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index e4ddf6e..8ba2b052 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -827,6 +827,9 @@
   DeleteContents();
   EXPECT_EQ(orig_rvh_delete_count, 1);
   EXPECT_EQ(pending_rvh_delete_count, 1);
+  // Since the ChromeBlobStorageContext posts a task to the BrowserThread, we
+  // must run out the loop so the thread bundle is destroyed after this happens.
+  base::RunLoop().RunUntilIdle();
 }
 
 // Regression test for http://crbug.com/386542 - variation of
@@ -874,6 +877,9 @@
 
   // Cleanup.
   DeleteContents();
+  // Since the ChromeBlobStorageContext posts a task to the BrowserThread, we
+  // must run out the loop so the thread bundle is destroyed after this happens.
+  base::RunLoop().RunUntilIdle();
 }
 
 // Complement for NavigateFromRestoredSitelessUrl, verifying that when a regular
@@ -919,6 +925,9 @@
 
   // Cleanup.
   DeleteContents();
+  // Since the ChromeBlobStorageContext posts a task to the BrowserThread, we
+  // must run out the loop so the thread bundle is destroyed after this happens.
+  base::RunLoop().RunUntilIdle();
 }
 
 // Test that we can find an opener RVH even if it's pending.
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
index a1fa2e8c..3741185 100644
--- a/content/public/common/content_features.cc
+++ b/content/public/common/content_features.cc
@@ -75,6 +75,10 @@
 const base::Feature kFeaturePolicy{"FeaturePolicy",
                                    base::FEATURE_DISABLED_BY_DEFAULT};
 
+// Enable filtering of same-origin tiny plugins
+const base::Feature kFilterSameOriginTinyPlugin{
+    "FilterSameOriginTinyPlugins", base::FEATURE_DISABLED_BY_DEFAULT};
+
 // Enables a blink::FontCache optimization that reuses a font to serve different
 // size of font.
 const base::Feature kFontCacheScaling{"FontCacheScaling",
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h
index 0aed60d..fad4b4ca 100644
--- a/content/public/common/content_features.h
+++ b/content/public/common/content_features.h
@@ -28,6 +28,7 @@
 CONTENT_EXPORT extern const base::Feature kExpensiveBackgroundTimerThrottling;
 CONTENT_EXPORT extern const base::Feature kFasterLocationReload;
 CONTENT_EXPORT extern const base::Feature kFeaturePolicy;
+CONTENT_EXPORT extern const base::Feature kFilterSameOriginTinyPlugin;
 CONTENT_EXPORT extern const base::Feature kFontCacheScaling;
 CONTENT_EXPORT extern const base::Feature
     kFramebustingNeedsSameOriginOrUserGesture;
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc
index 35a4dc3..7e6b1ae 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -20,9 +20,6 @@
 #include "base/strings/string_number_conversions.h"
 #include "base/synchronization/lock.h"
 #include "base/sys_info.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/task_scheduler/task_scheduler.h"
-#include "base/task_scheduler/task_traits.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "base/values.h"
@@ -248,14 +245,6 @@
     params.main_task_runner =
         compositor_deps_->GetCompositorMainThreadTaskRunner();
     params.mutator_host = animation_host_.get();
-    if (base::TaskScheduler::GetInstance()) {
-      params.image_worker_task_runner =
-          base::CreateSequencedTaskRunnerWithTraits(
-              base::TaskTraits()
-                  .WithPriority(base::TaskPriority::BACKGROUND)
-                  .WithShutdownBehavior(
-                      base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
-    }
     if (!threaded_) {
       // Single-threaded layout tests.
       layer_tree_host_ =
diff --git a/content/renderer/media/render_media_log.cc b/content/renderer/media/render_media_log.cc
index f1b32b4..1b3eeb5 100644
--- a/content/renderer/media/render_media_log.cc
+++ b/content/renderer/media/render_media_log.cc
@@ -31,6 +31,7 @@
                << media::MediaLog::MediaEventToLogString(*event);
   } else if (event->type != media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED &&
              event->type != media::MediaLogEvent::PROPERTY_CHANGE &&
+             event->type != media::MediaLogEvent::WATCH_TIME_UPDATE &&
              event->type != media::MediaLogEvent::NETWORK_ACTIVITY_SET) {
     MEDIA_EVENT_LOG_UTILITY << "MediaEvent: "
                             << media::MediaLog::MediaEventToLogString(*event);
diff --git a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
index 1fbdb82..9ba79d4a 100644
--- a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
+++ b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
@@ -127,6 +127,13 @@
   return channel_token_;
 }
 
+int32_t RendererGpuVideoAcceleratorFactories::GetCommandBufferRouteId() {
+  DCHECK(task_runner_->BelongsToCurrentThread());
+  if (CheckContextLost())
+    return 0;
+  return context_provider_->GetCommandBufferProxy()->route_id();
+}
+
 std::unique_ptr<media::VideoDecodeAccelerator>
 RendererGpuVideoAcceleratorFactories::CreateVideoDecodeAccelerator() {
   DCHECK(video_accelerator_enabled_);
diff --git a/content/renderer/media/renderer_gpu_video_accelerator_factories.h b/content/renderer/media/renderer_gpu_video_accelerator_factories.h
index edc6759..b968dc3e 100644
--- a/content/renderer/media/renderer_gpu_video_accelerator_factories.h
+++ b/content/renderer/media/renderer_gpu_video_accelerator_factories.h
@@ -59,6 +59,7 @@
   // media::GpuVideoAcceleratorFactories implementation.
   bool IsGpuVideoAcceleratorEnabled() override;
   base::UnguessableToken GetChannelToken() override;
+  int32_t GetCommandBufferRouteId() override;
   std::unique_ptr<media::VideoDecodeAccelerator> CreateVideoDecodeAccelerator()
       override;
   std::unique_ptr<media::VideoEncodeAccelerator> CreateVideoEncodeAccelerator()
diff --git a/content/renderer/peripheral_content_heuristic.cc b/content/renderer/peripheral_content_heuristic.cc
index e6cbcce..b9b7e9b 100644
--- a/content/renderer/peripheral_content_heuristic.cc
+++ b/content/renderer/peripheral_content_heuristic.cc
@@ -6,6 +6,8 @@
 
 #include <cmath>
 
+#include "base/feature_list.h"
+#include "content/public/common/content_features.h"
 #include "ui/gfx/geometry/size.h"
 
 namespace content {
@@ -29,6 +31,16 @@
 const double kAspectRatioEpsilon = 0.01;
 const int kEssentialVideoMinimumArea = 120000;
 
+bool IsTiny(const gfx::Size& unobscured_size) {
+  // Empty plugins can't be classified as tiny - they might just be of unknown
+  // size.
+  if (unobscured_size.IsEmpty())
+    return false;
+
+  return unobscured_size.width() <= kTinyContentSize &&
+         unobscured_size.height() <= kTinyContentSize;
+}
+
 }  // namespace
 
 // static
@@ -38,6 +50,11 @@
     const url::Origin& main_frame_origin,
     const url::Origin& content_origin,
     const gfx::Size& unobscured_size) {
+  if (base::FeatureList::IsEnabled(features::kFilterSameOriginTinyPlugin) &&
+      IsTiny(unobscured_size)) {
+    return RenderFrame::CONTENT_STATUS_TINY;
+  }
+
   if (main_frame_origin.IsSameOriginWith(content_origin))
     return RenderFrame::CONTENT_STATUS_ESSENTIAL_SAME_ORIGIN;
 
@@ -47,10 +64,8 @@
   if (unobscured_size.IsEmpty())
     return RenderFrame::CONTENT_STATUS_UNKNOWN_SIZE;
 
-  if (unobscured_size.width() <= kTinyContentSize &&
-      unobscured_size.height() <= kTinyContentSize) {
+  if (IsTiny(unobscured_size))
     return RenderFrame::CONTENT_STATUS_TINY;
-  }
 
   if (IsLargeContent(unobscured_size))
     return RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG;
diff --git a/content/renderer/peripheral_content_heuristic_unittest.cc b/content/renderer/peripheral_content_heuristic_unittest.cc
index 57396a7..f65cde7 100644
--- a/content/renderer/peripheral_content_heuristic_unittest.cc
+++ b/content/renderer/peripheral_content_heuristic_unittest.cc
@@ -4,6 +4,8 @@
 
 #include "content/renderer/peripheral_content_heuristic.h"
 
+#include "base/test/scoped_feature_list.h"
+#include "content/public/common/content_features.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/size.h"
 #include "url/gurl.h"
@@ -59,6 +61,16 @@
                 url::Origin(GURL(kOtherOrigin)), gfx::Size(10, 10)));
 }
 
+TEST(PeripheralContentHeuristic, FilterSameOriginTinyPlugins) {
+  base::test::ScopedFeatureList feature_list;
+  feature_list.InitAndEnableFeature(features::kFilterSameOriginTinyPlugin);
+
+  EXPECT_EQ(RenderFrame::CONTENT_STATUS_TINY,
+            PeripheralContentHeuristic::GetPeripheralStatus(
+                std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)),
+                url::Origin(GURL(kSameOrigin)), gfx::Size(1, 1)));
+}
+
 TEST(PeripheralContentHeuristic, TemporaryOriginWhitelist) {
   EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL,
             PeripheralContentHeuristic::GetPeripheralStatus(
diff --git a/content/test/gpu/generate_buildbot_json.py b/content/test/gpu/generate_buildbot_json.py
index fca3765..46de5e2 100755
--- a/content/test/gpu/generate_buildbot_json.py
+++ b/content/test/gpu/generate_buildbot_json.py
@@ -1366,7 +1366,7 @@
         'build_configs': ['Release'],
         'fyi_only': True,
         'run_on_optional': False,
-        # Only run on the NVIDIA Release and New Intel Release Linux bots
+        # Only run on the NVIDIA Release and Intel Release Linux bots
         'swarming_dimension_sets': [
           {
             'gpu': '10de:104a',
@@ -1376,6 +1376,10 @@
             'gpu': '8086:0412',
             'os': 'Linux'
           },
+          {
+            'gpu': '8086:1912',
+            'os': 'Linux'
+          },
         ],
       },
     ],
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 9723a52..ba0efe7 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -800,6 +800,12 @@
 
   data = [
     "test/data/",
+
+    # Needed for isolate script to execute.
+    "//testing/scripts/common.py",
+    "//testing/xvfb.py",
+    "//testing/scripts/run_gtest_perf_test.py",
+    "//tools/perf/generate_legacy_perf_dashboard_json.py",
   ]
 }
 
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc
index 723c6da..124f8c0b 100644
--- a/media/filters/gpu_video_decoder.cc
+++ b/media/filters/gpu_video_decoder.cc
@@ -121,6 +121,7 @@
       factories_(factories),
       request_surface_cb_(request_surface_cb),
       media_log_(media_log),
+      vda_initialized_(false),
       state_(kNormal),
       decoder_texture_target_(0),
       pixel_format_(PIXEL_FORMAT_UNKNOWN),
@@ -327,32 +328,34 @@
   CompleteInitialization(SurfaceManager::kNoSurfaceID);
 }
 
+// OnSurfaceAvailable() might be called at any time between Initialize() and
+// ~GpuVideoDecoder() so we have to be careful to not make assumptions about
+// the current state.
 void GpuVideoDecoder::OnSurfaceAvailable(int surface_id) {
   DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
 
-  // It's possible for the vda to become null if NotifyError is called.
-  if (!vda_) {
-    if (!init_cb_.is_null())
-      base::ResetAndReturn(&init_cb_).Run(false);
+  if (!vda_)
+    return;
+
+  // If the VDA has not been initialized, we were waiting for the first surface
+  // so it can be passed to Initialize() via the config. We can't call
+  // SetSurface() before initializing because there is no remote VDA to handle
+  // the call yet.
+  if (!vda_initialized_) {
+    CompleteInitialization(surface_id);
     return;
   }
 
-  // If initialization has already completed, there's nothing to do but try to
-  // set the surface. If we're still initializing, we must pass the surface via
-  // the config since the remote VDA has not yet been created.
-  if (init_cb_.is_null()) {
-    vda_->SetSurface(surface_id);
-    return;
-  }
-
-  // Otherwise initialization was waiting for the surface, so complete it now.
-  CompleteInitialization(surface_id);
+  // The VDA must be already initialized (or async initialization is in
+  // progress) so we can call SetSurface().
+  vda_->SetSurface(surface_id);
 }
 
 void GpuVideoDecoder::CompleteInitialization(int surface_id) {
   DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
   DCHECK(vda_);
   DCHECK(!init_cb_.is_null());
+  DCHECK(!vda_initialized_);
 
   VideoDecodeAccelerator::Config vda_config;
   vda_config.profile = config_.profile();
@@ -369,8 +372,12 @@
     ExtractSpsAndPps(config_.extra_data(), &vda_config.sps, &vda_config.pps);
 #endif
 
+  vda_initialized_ = true;
   if (!vda_->Initialize(vda_config, this)) {
     DVLOG(1) << "VDA::Initialize failed.";
+    // It's important to set |vda_| to null so that OnSurfaceAvailable() will
+    // not call SetSurface() on a nonexistent remote VDA.
+    DestroyVDA();
     base::ResetAndReturn(&init_cb_).Run(false);
     return;
   }
@@ -384,9 +391,9 @@
 
 void GpuVideoDecoder::NotifyInitializationComplete(bool success) {
   DVLOG_IF(1, !success) << __func__ << " Deferred initialization failed.";
-  DCHECK(!init_cb_.is_null());
 
-  base::ResetAndReturn(&init_cb_).Run(success);
+  if (init_cb_)
+    base::ResetAndReturn(&init_cb_).Run(success);
 }
 
 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) {
@@ -861,6 +868,9 @@
   if (!vda_)
     return;
 
+  if (init_cb_)
+    base::ResetAndReturn(&init_cb_).Run(false);
+
   // If we have any bitstream buffers, then notify one that an error has
   // occurred.  This guarantees that somebody finds out about the error.  If
   // we don't do this, and if the max decodes are already in flight, then there
diff --git a/media/filters/gpu_video_decoder.h b/media/filters/gpu_video_decoder.h
index 1f999cb..45c5b20 100644
--- a/media/filters/gpu_video_decoder.h
+++ b/media/filters/gpu_video_decoder.h
@@ -178,6 +178,10 @@
   // occurs.
   std::unique_ptr<VideoDecodeAccelerator> vda_;
 
+  // Whether |vda_->Initialize()| has been called. This is used to avoid
+  // calling Initialize() again while a deferred initialization is in progress.
+  bool vda_initialized_;
+
   InitCB init_cb_;
   OutputCB output_cb_;
 
diff --git a/media/gpu/ipc/service/media_gpu_channel.cc b/media/gpu/ipc/service/media_gpu_channel.cc
index 6a53bd0..e9abe18 100644
--- a/media/gpu/ipc/service/media_gpu_channel.cc
+++ b/media/gpu/ipc/service/media_gpu_channel.cc
@@ -89,9 +89,10 @@
   base::UnguessableToken channel_token_;
 };
 
-MediaGpuChannel::MediaGpuChannel(gpu::GpuChannel* channel) : channel_(channel) {
-  channel_->AddFilter(
-      new MediaGpuChannelFilter(base::UnguessableToken::Create()));
+MediaGpuChannel::MediaGpuChannel(gpu::GpuChannel* channel,
+                                 const base::UnguessableToken& channel_token)
+    : channel_(channel) {
+  channel_->AddFilter(new MediaGpuChannelFilter(channel_token));
 }
 
 MediaGpuChannel::~MediaGpuChannel() {}
diff --git a/media/gpu/ipc/service/media_gpu_channel.h b/media/gpu/ipc/service/media_gpu_channel.h
index 3b0799e4..547b26a 100644
--- a/media/gpu/ipc/service/media_gpu_channel.h
+++ b/media/gpu/ipc/service/media_gpu_channel.h
@@ -7,6 +7,7 @@
 
 #include <memory>
 
+#include "base/unguessable_token.h"
 #include "ipc/ipc_listener.h"
 #include "ipc/ipc_sender.h"
 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h"
@@ -26,7 +27,8 @@
 
 class MediaGpuChannel : public IPC::Listener, public IPC::Sender {
  public:
-  explicit MediaGpuChannel(gpu::GpuChannel* channel);
+  MediaGpuChannel(gpu::GpuChannel* channel,
+                  const base::UnguessableToken& channel_token);
   ~MediaGpuChannel() override;
 
   // IPC::Sender implementation:
@@ -49,6 +51,7 @@
                             IPC::Message* reply_message);
 
   gpu::GpuChannel* const channel_;
+  base::UnguessableToken channel_token_;
   std::unique_ptr<GpuJpegDecodeAccelerator> jpeg_decoder_;
   DISALLOW_COPY_AND_ASSIGN(MediaGpuChannel);
 };
diff --git a/media/gpu/ipc/service/media_gpu_channel_manager.cc b/media/gpu/ipc/service/media_gpu_channel_manager.cc
index 684c05a..0a7e7c8 100644
--- a/media/gpu/ipc/service/media_gpu_channel_manager.cc
+++ b/media/gpu/ipc/service/media_gpu_channel_manager.cc
@@ -26,18 +26,36 @@
 void MediaGpuChannelManager::AddChannel(int32_t client_id) {
   gpu::GpuChannel* gpu_channel = channel_manager_->LookupChannel(client_id);
   DCHECK(gpu_channel);
+  base::UnguessableToken channel_token = base::UnguessableToken::Create();
   std::unique_ptr<MediaGpuChannel> media_gpu_channel(
-      new MediaGpuChannel(gpu_channel));
+      new MediaGpuChannel(gpu_channel, channel_token));
   gpu_channel->SetUnhandledMessageListener(media_gpu_channel.get());
   media_gpu_channels_[client_id] = std::move(media_gpu_channel);
+  channel_to_token_[client_id] = channel_token;
+  token_to_channel_[channel_token] = client_id;
 }
 
 void MediaGpuChannelManager::RemoveChannel(int32_t client_id) {
   media_gpu_channels_.erase(client_id);
+  const auto it = channel_to_token_.find(client_id);
+  if (it != channel_to_token_.end()) {
+    token_to_channel_.erase(it->second);
+    channel_to_token_.erase(it);
+  }
 }
 
 void MediaGpuChannelManager::DestroyAllChannels() {
   media_gpu_channels_.clear();
+  token_to_channel_.clear();
+  channel_to_token_.clear();
+}
+
+gpu::GpuChannel* MediaGpuChannelManager::LookupChannel(
+    const base::UnguessableToken& channel_token) {
+  const auto it = token_to_channel_.find(channel_token);
+  if (it == token_to_channel_.end())
+    return nullptr;
+  return channel_manager_->LookupChannel(it->second);
 }
 
 }  // namespace media
diff --git a/media/gpu/ipc/service/media_gpu_channel_manager.h b/media/gpu/ipc/service/media_gpu_channel_manager.h
index 01aa42e..8cc3f2f 100644
--- a/media/gpu/ipc/service/media_gpu_channel_manager.h
+++ b/media/gpu/ipc/service/media_gpu_channel_manager.h
@@ -12,11 +12,13 @@
 
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
+#include "base/unguessable_token.h"
 #include "ipc/ipc_listener.h"
 #include "ipc/ipc_sender.h"
 #include "media/video/video_decode_accelerator.h"
 
 namespace gpu {
+class GpuChannel;
 class GpuChannelManager;
 }
 
@@ -34,10 +36,15 @@
   void RemoveChannel(int32_t client_id);
   void DestroyAllChannels();
 
+  // TODO(sandersd): Should we expose the MediaGpuChannel instead?
+  gpu::GpuChannel* LookupChannel(const base::UnguessableToken& channel_token);
+
  private:
   gpu::GpuChannelManager* const channel_manager_;
   std::unordered_map<int32_t, std::unique_ptr<MediaGpuChannel>>
       media_gpu_channels_;
+  std::map<base::UnguessableToken, int32_t> token_to_channel_;
+  std::map<int32_t, base::UnguessableToken> channel_to_token_;
   DISALLOW_COPY_AND_ASSIGN(MediaGpuChannelManager);
 };
 
diff --git a/media/mojo/clients/mojo_video_decoder.cc b/media/mojo/clients/mojo_video_decoder.cc
index efa695d0..c608bdc 100644
--- a/media/mojo/clients/mojo_video_decoder.cc
+++ b/media/mojo/clients/mojo_video_decoder.cc
@@ -10,11 +10,14 @@
 #include "base/location.h"
 #include "base/logging.h"
 #include "base/single_thread_task_runner.h"
+#include "base/unguessable_token.h"
 #include "media/base/decoder_buffer.h"
 #include "media/base/demuxer_stream.h"
 #include "media/base/video_frame.h"
 #include "media/mojo/common/media_type_converters.h"
 #include "media/mojo/common/mojo_decoder_buffer_converter.h"
+#include "media/mojo/interfaces/media_types.mojom.h"
+#include "media/renderers/gpu_video_accelerator_factories.h"
 
 namespace media {
 
@@ -23,10 +26,9 @@
     GpuVideoAcceleratorFactories* gpu_factories,
     mojom::VideoDecoderPtr remote_decoder)
     : task_runner_(task_runner),
-      gpu_factories_(gpu_factories),
       remote_decoder_info_(remote_decoder.PassInterface()),
+      gpu_factories_(gpu_factories),
       client_binding_(this) {
-  (void)gpu_factories_;
   DVLOG(1) << __func__;
 }
 
@@ -180,8 +182,19 @@
   mojo_decoder_buffer_writer_ = MojoDecoderBufferWriter::Create(
       DemuxerStream::VIDEO, &remote_consumer_handle);
 
+  media::mojom::CommandBufferIdPtr command_buffer_id;
+  if (gpu_factories_) {
+    base::UnguessableToken channel_token = gpu_factories_->GetChannelToken();
+    if (channel_token) {
+      command_buffer_id = media::mojom::CommandBufferId::New();
+      command_buffer_id->channel_token = std::move(channel_token);
+      command_buffer_id->route_id = gpu_factories_->GetCommandBufferRouteId();
+    }
+  }
+
   remote_decoder_->Construct(std::move(client_ptr_info),
-                             std::move(remote_consumer_handle));
+                             std::move(remote_consumer_handle),
+                             std::move(command_buffer_id));
 }
 
 void MojoVideoDecoder::Stop() {
diff --git a/media/mojo/clients/mojo_video_decoder.h b/media/mojo/clients/mojo_video_decoder.h
index 78d36c3..bb13271 100644
--- a/media/mojo/clients/mojo_video_decoder.h
+++ b/media/mojo/clients/mojo_video_decoder.h
@@ -61,13 +61,15 @@
   // Cleans up callbacks and blocks future calls.
   void Stop();
 
+  // Task runner that the decoder runs on (media thread).
   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
-  GpuVideoAcceleratorFactories* gpu_factories_;
 
   // Used to pass the remote decoder from the constructor (on the main thread)
   // to Initialize() (on the media thread).
   mojom::VideoDecoderPtrInfo remote_decoder_info_;
 
+  GpuVideoAcceleratorFactories* gpu_factories_ = nullptr;
+
   InitCB init_cb_;
   OutputCB output_cb_;
   uint64_t decode_counter_ = 0;
diff --git a/media/mojo/interfaces/video_decoder.mojom b/media/mojo/interfaces/video_decoder.mojom
index b0bcf94..42261246 100644
--- a/media/mojo/interfaces/video_decoder.mojom
+++ b/media/mojo/interfaces/video_decoder.mojom
@@ -5,17 +5,30 @@
 module media.mojom;
 
 import "media/mojo/interfaces/media_types.mojom";
+import "mojo/common/unguessable_token.mojom";
+
+// Identifies a GpuCommandBufferStub. MediaGpuChannelManager is responsible
+// for minting |channel_token| objects.
+struct CommandBufferId {
+  mojo.common.mojom.UnguessableToken channel_token;
+  int32 route_id;
+};
 
 interface VideoDecoder {
   // Initialize the decoder. This must be called before any other method.
   //
+  // |command_buffer_id|, when present, identifies a GpuCommandBufferStub that
+  // the decoder can use for GL operations. Implementations that require GL will
+  // fail Initialize() if |command_buffer_id| is not provided.
+  //
   // |decoder_buffer_pipe| will be used to transfer encoded data for each
   // DecoderBuffer.
   //
   // TODO(sandersd): Rename to Initialize() if/when
   // media::VideoDecoder::Initialize() is renamed to Configure().
   Construct(associated VideoDecoderClient client,
-            handle<data_pipe_consumer> decoder_buffer_pipe);
+            handle<data_pipe_consumer> decoder_buffer_pipe,
+            CommandBufferId? command_buffer_id);
 
   // Configure (or reconfigure) the decoder. This must be called before decoding
   // any frames, and must not be called while there are pending Initialize(),
diff --git a/media/mojo/services/gpu_mojo_media_client.cc b/media/mojo/services/gpu_mojo_media_client.cc
index 1c0e2f9..1c7643c 100644
--- a/media/mojo/services/gpu_mojo_media_client.cc
+++ b/media/mojo/services/gpu_mojo_media_client.cc
@@ -51,7 +51,8 @@
 }
 
 std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
-    scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+    scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+    mojom::CommandBufferIdPtr command_buffer_id) {
   static_cast<void>(media_gpu_channel_manager_);
 
   // TODO(sandersd): Factory for VideoDecoders.
diff --git a/media/mojo/services/gpu_mojo_media_client.h b/media/mojo/services/gpu_mojo_media_client.h
index 1e5c4b1..3ed67ae 100644
--- a/media/mojo/services/gpu_mojo_media_client.h
+++ b/media/mojo/services/gpu_mojo_media_client.h
@@ -30,7 +30,8 @@
   std::unique_ptr<AudioDecoder> CreateAudioDecoder(
       scoped_refptr<base::SingleThreadTaskRunner> task_runner) final;
   std::unique_ptr<VideoDecoder> CreateVideoDecoder(
-      scoped_refptr<base::SingleThreadTaskRunner> task_runner) final;
+      scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+      mojom::CommandBufferIdPtr command_buffer_id) final;
   std::unique_ptr<CdmFactory> CreateCdmFactory(
       service_manager::mojom::InterfaceProvider* interface_provider) final;
 
diff --git a/media/mojo/services/mojo_media_client.cc b/media/mojo/services/mojo_media_client.cc
index 62081a2..9ced9b2 100644
--- a/media/mojo/services/mojo_media_client.cc
+++ b/media/mojo/services/mojo_media_client.cc
@@ -27,7 +27,8 @@
 }
 
 std::unique_ptr<VideoDecoder> MojoMediaClient::CreateVideoDecoder(
-    scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+    scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+    mojom::CommandBufferIdPtr command_buffer_id) {
   return nullptr;
 }
 
diff --git a/media/mojo/services/mojo_media_client.h b/media/mojo/services/mojo_media_client.h
index ce83b51..f376ffd 100644
--- a/media/mojo/services/mojo_media_client.h
+++ b/media/mojo/services/mojo_media_client.h
@@ -9,6 +9,7 @@
 #include <string>
 
 #include "base/memory/ref_counted.h"
+#include "media/mojo/interfaces/video_decoder.mojom.h"
 #include "media/mojo/services/media_mojo_export.h"
 
 namespace base {
@@ -47,7 +48,8 @@
       scoped_refptr<base::SingleThreadTaskRunner> task_runner);
 
   virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder(
-      scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+      scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+      mojom::CommandBufferIdPtr command_buffer_id);
 
   // Returns the output sink used for rendering audio on |audio_device_id|.
   // May be null if the RendererFactory doesn't need an audio sink.
diff --git a/media/mojo/services/mojo_video_decoder_service.cc b/media/mojo/services/mojo_video_decoder_service.cc
index 7a94c57..84b0308 100644
--- a/media/mojo/services/mojo_video_decoder_service.cc
+++ b/media/mojo/services/mojo_video_decoder_service.cc
@@ -31,15 +31,17 @@
 
 void MojoVideoDecoderService::Construct(
     mojom::VideoDecoderClientAssociatedPtrInfo client,
-    mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) {
+    mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe,
+    mojom::CommandBufferIdPtr command_buffer_id) {
   DVLOG(1) << __func__;
 
+  // TODO(sandersd): Enter an error state.
   if (decoder_)
     return;
 
   // TODO(sandersd): Provide callback for requesting a GpuCommandBufferStub.
   decoder_ = mojo_media_client_->CreateVideoDecoder(
-      base::ThreadTaskRunnerHandle::Get());
+      base::ThreadTaskRunnerHandle::Get(), std::move(command_buffer_id));
 
   client_.Bind(std::move(client));
 
diff --git a/media/mojo/services/mojo_video_decoder_service.h b/media/mojo/services/mojo_video_decoder_service.h
index d975229a..ce824eee 100644
--- a/media/mojo/services/mojo_video_decoder_service.h
+++ b/media/mojo/services/mojo_video_decoder_service.h
@@ -28,7 +28,8 @@
 
   // mojom::VideoDecoder implementation
   void Construct(mojom::VideoDecoderClientAssociatedPtrInfo client,
-                 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) final;
+                 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe,
+                 mojom::CommandBufferIdPtr command_buffer_id) final;
   void Initialize(mojom::VideoDecoderConfigPtr config,
                   bool low_delay,
                   const InitializeCallback& callback) final;
diff --git a/media/renderers/gpu_video_accelerator_factories.h b/media/renderers/gpu_video_accelerator_factories.h
index 59695ac..ad27ada 100644
--- a/media/renderers/gpu_video_accelerator_factories.h
+++ b/media/renderers/gpu_video_accelerator_factories.h
@@ -73,6 +73,9 @@
   // Return the channel token, or an empty token if the channel is unusable.
   virtual base::UnguessableToken GetChannelToken() = 0;
 
+  // Returns the |route_id| of the command buffer, or 0 if there is none.
+  virtual int32_t GetCommandBufferRouteId() = 0;
+
   // Caller owns returned pointer, but should call Destroy() on it (instead of
   // directly deleting) for proper destruction, as per the
   // VideoDecodeAccelerator interface.
diff --git a/media/renderers/mock_gpu_video_accelerator_factories.h b/media/renderers/mock_gpu_video_accelerator_factories.h
index 1fb64cf3..ef4c799d 100644
--- a/media/renderers/mock_gpu_video_accelerator_factories.h
+++ b/media/renderers/mock_gpu_video_accelerator_factories.h
@@ -32,6 +32,7 @@
   bool IsGpuVideoAcceleratorEnabled() override;
 
   MOCK_METHOD0(GetChannelToken, base::UnguessableToken());
+  MOCK_METHOD0(GetCommandBufferRouteId, int32_t());
 
   // CreateVideo{Decode,Encode}Accelerator returns scoped_ptr, which the mocking
   // framework does not want.  Trampoline them.
diff --git a/net/quic/chromium/quic_chromium_client_session.cc b/net/quic/chromium/quic_chromium_client_session.cc
index fac5b9e7..96a8eea 100644
--- a/net/quic/chromium/quic_chromium_client_session.cc
+++ b/net/quic/chromium/quic_chromium_client_session.cc
@@ -312,7 +312,6 @@
     CloseAllObservers(ERR_UNEXPECTED);
 
     connection()->set_debug_visitor(nullptr);
-    net_log_.EndEvent(NetLogEventType::QUIC_SESSION);
 
     UMA_HISTOGRAM_COUNTS_1000("Net.QuicSession.AbortedPendingStreamRequests",
                               stream_requests_.size());
@@ -425,6 +424,7 @@
   UMA_HISTOGRAM_COUNTS(
       "Net.QuicSession.MaxReordering",
       static_cast<base::HistogramBase::Sample>(stats.max_sequence_reordering));
+  net_log_.EndEvent(NetLogEventType::QUIC_SESSION);
 }
 
 void QuicChromiumClientSession::Initialize() {
diff --git a/net/socket/client_socket_handle.cc b/net/socket/client_socket_handle.cc
index be58c729..983efa7c 100644
--- a/net/socket/client_socket_handle.cc
+++ b/net/socket/client_socket_handle.cc
@@ -134,9 +134,8 @@
 }
 
 void ClientSocketHandle::DumpMemoryStats(
-    base::trace_event::ProcessMemoryDump* pmd,
-    const std::string& parent_absolute_name) const {
-  socket_->DumpMemoryStats(pmd, parent_absolute_name);
+    StreamSocket::SocketMemoryStats* stats) const {
+  socket_->DumpMemoryStats(stats);
 }
 
 void ClientSocketHandle::SetSocket(std::unique_ptr<StreamSocket> s) {
diff --git a/net/socket/client_socket_handle.h b/net/socket/client_socket_handle.h
index de0381f..7c17882 100644
--- a/net/socket/client_socket_handle.h
+++ b/net/socket/client_socket_handle.h
@@ -26,12 +26,6 @@
 #include "net/socket/connection_attempts.h"
 #include "net/socket/stream_socket.h"
 
-namespace base {
-namespace trace_event {
-class ProcessMemoryDump;
-}
-}
-
 namespace net {
 
 // A container for a StreamSocket.
@@ -128,10 +122,10 @@
   bool GetLoadTimingInfo(bool is_reused,
                          LoadTimingInfo* load_timing_info) const;
 
-  // Dumps memory allocation stats. |parent_dump_absolute_name| is the name
-  // used by the parent MemoryAllocatorDump in the memory dump hierarchy.
-  void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd,
-                       const std::string& parent_dump_absolute_name) const;
+  // Dumps memory allocation stats into |stats|. |stats| can be assumed as being
+  // default initialized upon entry. Implementation overrides fields in
+  // |stats|.
+  void DumpMemoryStats(StreamSocket::SocketMemoryStats* stats) const;
 
   // Used by ClientSocketPool to initialize the ClientSocketHandle.
   //
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 252ca29..c5427ccf 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -704,23 +704,43 @@
 void ClientSocketPoolBaseHelper::DumpMemoryStats(
     base::trace_event::ProcessMemoryDump* pmd,
     const std::string& parent_dump_absolute_name) const {
-  base::trace_event::MemoryAllocatorDump* socket_pool_dump = nullptr;
   size_t socket_count = 0;
+  size_t total_size = 0;
+  size_t buffer_size = 0;
+  size_t cert_count = 0;
+  size_t serialized_cert_size = 0;
   for (const auto& kv : group_map_) {
     for (const auto& socket : kv.second->idle_sockets()) {
-      // Only create a MemoryAllocatorDump if there is at least one idle socket
-      if (!socket_pool_dump) {
-        socket_pool_dump = pmd->CreateAllocatorDump(base::StringPrintf(
-            "%s/socket_pool", parent_dump_absolute_name.c_str()));
-      }
-      socket.socket->DumpMemoryStats(pmd, socket_pool_dump->absolute_name());
+      StreamSocket::SocketMemoryStats stats;
+      socket.socket->DumpMemoryStats(&stats);
+      total_size += stats.total_size;
+      buffer_size += stats.buffer_size;
+      cert_count += stats.cert_count;
+      serialized_cert_size += stats.serialized_cert_size;
       ++socket_count;
     }
   }
-  if (socket_pool_dump) {
+  // Only create a MemoryAllocatorDump if there is at least one idle socket
+  if (socket_count > 0) {
+    base::trace_event::MemoryAllocatorDump* socket_pool_dump =
+        pmd->CreateAllocatorDump(base::StringPrintf(
+            "%s/socket_pool", parent_dump_absolute_name.c_str()));
+    socket_pool_dump->AddScalar(
+        base::trace_event::MemoryAllocatorDump::kNameSize,
+        base::trace_event::MemoryAllocatorDump::kUnitsBytes, total_size);
     socket_pool_dump->AddScalar(
         base::trace_event::MemoryAllocatorDump::kNameObjectCount,
         base::trace_event::MemoryAllocatorDump::kUnitsObjects, socket_count);
+    socket_pool_dump->AddScalar(
+        "buffer_size", base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+        buffer_size);
+    socket_pool_dump->AddScalar(
+        "cert_count", base::trace_event::MemoryAllocatorDump::kUnitsObjects,
+        cert_count);
+    socket_pool_dump->AddScalar(
+        "serialized_cert_size",
+        base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+        serialized_cert_size);
   }
 }
 
diff --git a/net/socket/ssl_client_socket_impl.cc b/net/socket/ssl_client_socket_impl.cc
index 4e3f713..4e01ea2 100644
--- a/net/socket/ssl_client_socket_impl.cc
+++ b/net/socket/ssl_client_socket_impl.cc
@@ -25,7 +25,6 @@
 #include "base/strings/stringprintf.h"
 #include "base/synchronization/lock.h"
 #include "base/threading/thread_local.h"
-#include "base/trace_event/memory_allocator_dump.h"
 #include "base/trace_event/process_memory_dump.h"
 #include "base/trace_event/trace_event.h"
 #include "base/values.h"
@@ -811,42 +810,20 @@
   return transport_->socket()->GetTotalReceivedBytes();
 }
 
-void SSLClientSocketImpl::DumpMemoryStats(
-    base::trace_event::ProcessMemoryDump* pmd,
-    const std::string& parent_dump_absolute_name) const {
-  size_t total_size = 0;
-  base::trace_event::MemoryAllocatorDump* socket_dump =
-      pmd->CreateAllocatorDump(base::StringPrintf(
-          "%s/ssl_socket_%p", parent_dump_absolute_name.c_str(), this));
-  if (transport_adapter_) {
-    size_t bio_buffers_size = transport_adapter_->GetAllocationSize();
-    socket_dump->AddScalar("buffer_size",
-                           base::trace_event::MemoryAllocatorDump::kUnitsBytes,
-                           bio_buffers_size);
-    total_size += bio_buffers_size;
-  }
-  size_t total_cert_size = 0;
-  size_t certs_count = 0;
+void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const {
+  if (transport_adapter_)
+    stats->buffer_size = transport_adapter_->GetAllocationSize();
   if (server_cert_chain_) {
-    certs_count = server_cert_chain_->size();
-    for (size_t i = 0; i < certs_count; ++i) {
+    for (size_t i = 0; i < server_cert_chain_->size(); ++i) {
       X509* cert = server_cert_chain_->Get(i);
-      total_cert_size += i2d_X509(cert, nullptr);
+      // This measures the lower bound of the serialized certificate. It doesn't
+      // measure the actual memory used, which is 4x this amount (see
+      // crbug.com/671420 for more details).
+      stats->serialized_cert_size += i2d_X509(cert, nullptr);
     }
+    stats->cert_count = server_cert_chain_->size();
   }
-  total_size += total_cert_size;
-  // This measures the lower bound of the serialized certificate. It doesn't
-  // measure the actual memory used, which is 4x this amount (see
-  // crbug.com/671420 for more details).
-  socket_dump->AddScalar("serialized_cert_size",
-                         base::trace_event::MemoryAllocatorDump::kUnitsBytes,
-                         total_cert_size);
-  socket_dump->AddScalar("cert_count",
-                         base::trace_event::MemoryAllocatorDump::kUnitsObjects,
-                         certs_count);
-  socket_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
-                         base::trace_event::MemoryAllocatorDump::kUnitsBytes,
-                         total_size);
+  stats->total_size = stats->buffer_size + stats->serialized_cert_size;
 }
 
 // static
diff --git a/net/socket/ssl_client_socket_impl.h b/net/socket/ssl_client_socket_impl.h
index 4d44008..d010852 100644
--- a/net/socket/ssl_client_socket_impl.h
+++ b/net/socket/ssl_client_socket_impl.h
@@ -117,9 +117,7 @@
   void ClearConnectionAttempts() override {}
   void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
   int64_t GetTotalReceivedBytes() const override;
-  void DumpMemoryStats(
-      base::trace_event::ProcessMemoryDump* pmd,
-      const std::string& parent_dump_absolute_name) const override;
+  void DumpMemoryStats(SocketMemoryStats* stats) const override;
 
   // Dumps memory allocation stats. |pmd| is the browser process memory dump.
   static void DumpSSLClientSessionMemoryStats(
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 75f3f4f..58c7fa8 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -18,9 +18,6 @@
 #include "base/single_thread_task_runner.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
-#include "base/trace_event/memory_allocator_dump.h"
-#include "base/trace_event/process_memory_dump.h"
-#include "base/trace_event/trace_event_argument.h"
 #include "base/values.h"
 #include "net/base/address_list.h"
 #include "net/base/io_buffer.h"
@@ -47,6 +44,7 @@
 #include "net/socket/client_socket_factory.h"
 #include "net/socket/client_socket_handle.h"
 #include "net/socket/socket_test_util.h"
+#include "net/socket/stream_socket.h"
 #include "net/socket/tcp_client_socket.h"
 #include "net/ssl/channel_id_service.h"
 #include "net/ssl/default_channel_id_store.h"
@@ -3627,15 +3625,12 @@
   int rv;
   ASSERT_TRUE(CreateAndConnectSSLClientSocket(SSLConfig(), &rv));
   EXPECT_THAT(rv, IsOk());
-
-  base::trace_event::MemoryDumpArgs dump_args = {
-      base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
-  std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
-      new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
-  base::trace_event::MemoryAllocatorDump* parent_dump1 =
-      process_memory_dump->CreateAllocatorDump("parent1");
-  sock_->DumpMemoryStats(process_memory_dump.get(),
-                         parent_dump1->absolute_name());
+  StreamSocket::SocketMemoryStats stats;
+  sock_->DumpMemoryStats(&stats);
+  EXPECT_EQ(0u, stats.buffer_size);
+  EXPECT_EQ(1u, stats.cert_count);
+  EXPECT_LT(0u, stats.serialized_cert_size);
+  EXPECT_EQ(stats.serialized_cert_size, stats.total_size);
 
   // Read the response without writing a request, so the read will be pending.
   TestCompletionCallback read_callback;
@@ -3644,40 +3639,12 @@
   EXPECT_EQ(ERR_IO_PENDING, rv);
 
   // Dump memory again and check that |buffer_size| contain the read buffer.
-  base::trace_event::MemoryAllocatorDump* parent_dump2 =
-      process_memory_dump->CreateAllocatorDump("parent2");
-  sock_->DumpMemoryStats(process_memory_dump.get(),
-                         parent_dump2->absolute_name());
-
-  const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
-      allocator_dumps = process_memory_dump->allocator_dumps();
-  bool did_dump[] = {false, false};
-  // Checks that there are two dumps because DumpMemoryStats() is invoked twice.
-  for (const auto& pair : allocator_dumps) {
-    const std::string& dump_name = pair.first;
-    if (dump_name.find("ssl_socket") == std::string::npos)
-      continue;
-    std::unique_ptr<base::Value> raw_attrs =
-        pair.second->attributes_for_testing()->ToBaseValue();
-    base::DictionaryValue* attrs;
-    ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs));
-    base::DictionaryValue* buffer_size_attrs;
-    ASSERT_TRUE(attrs->GetDictionary("buffer_size", &buffer_size_attrs));
-    std::string buffer_size;
-    ASSERT_TRUE(buffer_size_attrs->GetString("value", &buffer_size));
-    ASSERT_TRUE(attrs->HasKey("serialized_cert_size"));
-    ASSERT_TRUE(attrs->HasKey("cert_count"));
-    if (dump_name.find("parent1/ssl_socket") != std::string::npos) {
-      did_dump[0] = true;
-      ASSERT_EQ("0", buffer_size);
-    }
-    if (dump_name.find("parent2/ssl_socket") != std::string::npos) {
-      did_dump[1] = true;
-      // The read buffer is not released, so |buffer_size| can't be 0.
-      ASSERT_NE("0", buffer_size);
-    }
-  }
-  EXPECT_THAT(did_dump, testing::ElementsAre(true, true));
+  StreamSocket::SocketMemoryStats stats2;
+  sock_->DumpMemoryStats(&stats2);
+  EXPECT_EQ(17 * 1024u, stats2.buffer_size);
+  EXPECT_EQ(1u, stats2.cert_count);
+  EXPECT_LT(0u, stats2.serialized_cert_size);
+  EXPECT_LT(17 * 1024u, stats2.total_size);
 }
 
 }  // namespace net
diff --git a/net/socket/stream_socket.cc b/net/socket/stream_socket.cc
index 650f388..d435fc3 100644
--- a/net/socket/stream_socket.cc
+++ b/net/socket/stream_socket.cc
@@ -98,4 +98,9 @@
   UMA_HISTOGRAM_ENUMERATION("Net.PreconnectUtilization2", result, 9);
 }
 
+StreamSocket::SocketMemoryStats::SocketMemoryStats()
+    : total_size(0), buffer_size(0), cert_count(0), serialized_cert_size(0) {}
+
+StreamSocket::SocketMemoryStats::~SocketMemoryStats() {}
+
 }  // namespace net
diff --git a/net/socket/stream_socket.h b/net/socket/stream_socket.h
index a55859d..fe2f0a6 100644
--- a/net/socket/stream_socket.h
+++ b/net/socket/stream_socket.h
@@ -13,12 +13,6 @@
 #include "net/socket/next_proto.h"
 #include "net/socket/socket.h"
 
-namespace base {
-namespace trace_event {
-class ProcessMemoryDump;
-}
-}
-
 namespace net {
 
 class IPEndPoint;
@@ -27,6 +21,25 @@
 
 class NET_EXPORT_PRIVATE StreamSocket : public Socket {
  public:
+  // This is used in DumpMemoryStats() to track the estimate of memory usage of
+  // a socket.
+  struct NET_EXPORT_PRIVATE SocketMemoryStats {
+   public:
+    SocketMemoryStats();
+    ~SocketMemoryStats();
+    // Estimated total memory usage of this socket in bytes.
+    size_t total_size;
+    // Size of all buffers used by this socket in bytes.
+    size_t buffer_size;
+    // Number of certs used by this socket.
+    size_t cert_count;
+    // Total size of certs used by this socket in bytes.
+    size_t serialized_cert_size;
+
+   private:
+    DISALLOW_COPY_AND_ASSIGN(SocketMemoryStats);
+  };
+
   ~StreamSocket() override {}
 
   // Called to establish a connection.  Returns OK if the connection could be
@@ -116,12 +129,10 @@
   // Disconnect() is called.
   virtual int64_t GetTotalReceivedBytes() const = 0;
 
-  // Dumps memory allocation stats. |parent_dump_absolute_name| is the name
-  // used by the parent MemoryAllocatorDump in the memory dump hierarchy.
-  // Default implementation does nothing.
-  virtual void DumpMemoryStats(
-      base::trace_event::ProcessMemoryDump* pmd,
-      const std::string& parent_dump_absolute_name) const {};
+  // Dumps memory allocation stats into |stats|. |stats| can be assumed as being
+  // default initialized upon entry. Implementations should override fields in
+  // |stats|. Default implementation does nothing.
+  virtual void DumpMemoryStats(SocketMemoryStats* stats) const {}
 
  protected:
   // The following class is only used to gather statistics about the history of
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 0740862..36793c9 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -25,8 +25,6 @@
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
-#include "base/trace_event/memory_allocator_dump.h"
-#include "base/trace_event/process_memory_dump.h"
 #include "base/trace_event/trace_event.h"
 #include "base/values.h"
 #include "crypto/ec_private_key.h"
@@ -1061,15 +1059,10 @@
   return false;
 }
 
-void SpdySession::DumpMemoryStats(
-    base::trace_event::ProcessMemoryDump* pmd,
-    const std::string& parent_absolute_name) const {
-  std::string name =
-      base::StringPrintf("%s/session_%p", parent_absolute_name.c_str(), this);
-  base::trace_event::MemoryAllocatorDump* session_dump =
-      pmd->CreateAllocatorDump(name);
-  session_dump->AddString("active", "", is_active() ? "1" : "0");
-  connection_->DumpMemoryStats(pmd, name);
+void SpdySession::DumpMemoryStats(StreamSocket::SocketMemoryStats* stats,
+                                  bool* is_session_active) const {
+  *is_session_active = is_active();
+  connection_->DumpMemoryStats(stats);
 }
 
 void SpdySession::EnqueueStreamWrite(
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 6ccb9182..6bdb5fca 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -47,12 +47,6 @@
 #include "url/gurl.h"
 #include "url/scheme_host_port.h"
 
-namespace base {
-namespace trace_event {
-class ProcessMemoryDump;
-}
-}
-
 namespace net {
 
 namespace test {
@@ -566,10 +560,12 @@
   // HigherLayeredPool implementation:
   bool CloseOneIdleConnection() override;
 
-  // Dumps memory allocation stats. |parent_dump_absolute_name| is the name
-  // used by the parent MemoryAllocatorDump in the memory dump hierarchy.
-  void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd,
-                       const std::string& parent_dump_absolute_name) const;
+  // Dumps memory allocation stats to |stats|. Sets |*is_session_active| to
+  // indicate whether session is active.
+  // |stats| can be assumed as being default initialized upon entry.
+  // Implementation overrides fields in |stats|.
+  void DumpMemoryStats(StreamSocket::SocketMemoryStats* stats,
+                       bool* is_session_active) const;
 
  private:
   friend class test::SpdyStreamTest;
diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc
index 7f09792..bba42692 100644
--- a/net/spdy/spdy_session_pool.cc
+++ b/net/spdy/spdy_session_pool.cc
@@ -373,10 +373,42 @@
     const std::string& parent_dump_absolute_name) const {
   std::string dump_name = base::StringPrintf("%s/spdy_session_pool",
                                              parent_dump_absolute_name.c_str());
-  pmd->CreateAllocatorDump(dump_name);
+  base::trace_event::MemoryAllocatorDump* dump =
+      pmd->CreateAllocatorDump(dump_name);
+  size_t total_size = 0;
+  size_t buffer_size = 0;
+  size_t cert_count = 0;
+  size_t serialized_cert_size = 0;
+  size_t num_active_sessions = 0;
   for (const auto& session : sessions_) {
-    session->DumpMemoryStats(pmd, dump_name);
+    StreamSocket::SocketMemoryStats stats;
+    bool is_session_active = false;
+    session->DumpMemoryStats(&stats, &is_session_active);
+    total_size += stats.total_size;
+    buffer_size += stats.buffer_size;
+    cert_count += stats.cert_count;
+    serialized_cert_size += stats.serialized_cert_size;
+    if (is_session_active)
+      num_active_sessions++;
   }
+  dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+                  base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+                  total_size);
+  dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount,
+                  base::trace_event::MemoryAllocatorDump::kUnitsObjects,
+                  sessions_.size());
+  dump->AddScalar("active_session_count",
+                  base::trace_event::MemoryAllocatorDump::kUnitsObjects,
+                  num_active_sessions);
+  dump->AddScalar("buffer_size",
+                  base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+                  buffer_size);
+  dump->AddScalar("cert_count",
+                  base::trace_event::MemoryAllocatorDump::kUnitsObjects,
+                  cert_count);
+  dump->AddScalar("serialized_cert_size",
+                  base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+                  serialized_cert_size);
 }
 
 bool SpdySessionPool::IsSessionAvailable(
diff --git a/net/spdy/spdy_session_pool_unittest.cc b/net/spdy/spdy_session_pool_unittest.cc
index 6bfb95d..51362da 100644
--- a/net/spdy/spdy_session_pool_unittest.cc
+++ b/net/spdy/spdy_session_pool_unittest.cc
@@ -707,18 +707,20 @@
       allocator_dumps = process_memory_dump->allocator_dumps();
   for (const auto& pair : allocator_dumps) {
     const std::string& dump_name = pair.first;
-    if (dump_name.find("spdy_session_pool/session") == std::string::npos)
+    if (dump_name.find("spdy_session_pool") == std::string::npos)
       continue;
     std::unique_ptr<base::Value> raw_attrs =
         pair.second->attributes_for_testing()->ToBaseValue();
     base::DictionaryValue* attrs;
     ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs));
-    base::DictionaryValue* is_active_attrs;
-    ASSERT_TRUE(attrs->GetDictionary("active", &is_active_attrs));
-    std::string is_active;
-    ASSERT_TRUE(is_active_attrs->GetString("value", &is_active));
+    base::DictionaryValue* active_session_count_attr;
+    ASSERT_TRUE(attrs->GetDictionary("active_session_count",
+                                     &active_session_count_attr));
+    std::string active_session_count;
+    ASSERT_TRUE(
+        active_session_count_attr->GetString("value", &active_session_count));
     // No created stream so the session should be idle.
-    ASSERT_EQ("0", is_active);
+    ASSERT_EQ("0", active_session_count);
     did_dump = true;
   }
   EXPECT_TRUE(did_dump);
diff --git a/services/service_manager/connect_params.h b/services/service_manager/connect_params.h
index a2104cd..8c8787a 100644
--- a/services/service_manager/connect_params.h
+++ b/services/service_manager/connect_params.h
@@ -52,6 +52,22 @@
     return std::move(pid_receiver_request_);
   }
 
+  void set_interface_request_info(
+      const std::string& interface_name,
+      mojo::ScopedMessagePipeHandle interface_pipe) {
+    interface_name_ = interface_name;
+    interface_pipe_ = std::move(interface_pipe);
+  }
+  const std::string& interface_name() const {
+    return interface_name_;
+  }
+  bool HasInterfaceRequestInfo() const {
+    return !interface_name_.empty() && interface_pipe_.is_valid();
+  }
+  mojo::ScopedMessagePipeHandle TakeInterfaceRequestPipe() {
+    return std::move(interface_pipe_);
+  }
+
   void set_connect_callback(const mojom::Connector::ConnectCallback& value) {
     connect_callback_ = value;
   }
@@ -59,6 +75,15 @@
     return connect_callback_;
   }
 
+  void set_bind_interface_callback(
+      const mojom::Connector::BindInterfaceCallback& callback) {
+    bind_interface_callback_ = callback;
+  }
+  const mojom::Connector::BindInterfaceCallback&
+      bind_interface_callback() const {
+    return bind_interface_callback_;
+  }
+
  private:
   // It may be null (i.e., is_null() returns true) which indicates that there is
   // no source (e.g., for the first application or in tests).
@@ -69,7 +94,10 @@
   mojom::InterfaceProviderRequest remote_interfaces_;
   mojom::ServicePtr service_;
   mojom::PIDReceiverRequest pid_receiver_request_;
+  std::string interface_name_;
+  mojo::ScopedMessagePipeHandle interface_pipe_;
   mojom::Connector::ConnectCallback connect_callback_;
+  mojom::Connector::BindInterfaceCallback bind_interface_callback_;
 
   DISALLOW_COPY_AND_ASSIGN(ConnectParams);
 };
diff --git a/services/service_manager/public/cpp/interface_registry.h b/services/service_manager/public/cpp/interface_registry.h
index 5872478..e9851f9 100644
--- a/services/service_manager/public/cpp/interface_registry.h
+++ b/services/service_manager/public/cpp/interface_registry.h
@@ -24,6 +24,16 @@
 class Connection;
 class InterfaceBinder;
 
+// Returns the set of capabilities required from the target.
+CapabilitySet GetRequestedCapabilities(const InterfaceProviderSpec& source_spec,
+                                       const Identity& target);
+
+// Generates a single set of interfaces that is the union of all interfaces
+// exposed by the target for the capabilities requested by the source.
+InterfaceSet GetInterfacesToExpose(const InterfaceProviderSpec& source_spec,
+                                   const Identity& target,
+                                   const InterfaceProviderSpec& target_spec);
+
 // An implementation of mojom::InterfaceProvider that allows the user to
 // register services to be exposed to another application.
 //
diff --git a/services/service_manager/public/cpp/lib/interface_registry.cc b/services/service_manager/public/cpp/lib/interface_registry.cc
index 91314a6e..a903dc3 100644
--- a/services/service_manager/public/cpp/lib/interface_registry.cc
+++ b/services/service_manager/public/cpp/lib/interface_registry.cc
@@ -13,51 +13,6 @@
 namespace service_manager {
 namespace {
 
-// Returns the set of capabilities required from the target.
-CapabilitySet GetRequestedCapabilities(const InterfaceProviderSpec& source_spec,
-                                       const Identity& target) {
-  CapabilitySet capabilities;
-
-  // Start by looking for specs specific to the supplied identity.
-  auto it = source_spec.requires.find(target.name());
-  if (it != source_spec.requires.end()) {
-    std::copy(it->second.begin(), it->second.end(),
-              std::inserter(capabilities, capabilities.begin()));
-  }
-
-  // Apply wild card rules too.
-  it = source_spec.requires.find("*");
-  if (it != source_spec.requires.end()) {
-    std::copy(it->second.begin(), it->second.end(),
-              std::inserter(capabilities, capabilities.begin()));
-  }
-  return capabilities;
-}
-
-// Generates a single set of interfaces that is the union of all interfaces
-// exposed by the target for the capabilities requested by the source.
-InterfaceSet GetInterfacesToExpose(
-    const InterfaceProviderSpec& source_spec,
-    const Identity& target,
-    const InterfaceProviderSpec& target_spec) {
-  InterfaceSet exposed_interfaces;
-  // TODO(beng): remove this once we can assert that an InterfaceRegistry must
-  //             always be constructed with a valid identity.
-  if (!target.IsValid()) {
-    exposed_interfaces.insert("*");
-    return exposed_interfaces;
-  }
-  CapabilitySet capabilities = GetRequestedCapabilities(source_spec, target);
-  for (const auto& capability : capabilities) {
-    auto it = target_spec.provides.find(capability);
-    if (it != target_spec.provides.end()) {
-      for (const auto& interface_name : it->second)
-        exposed_interfaces.insert(interface_name);
-    }
-  }
-  return exposed_interfaces;
-}
-
 void SerializeIdentity(const Identity& identity, std::stringstream* stream) {
   *stream << identity.name() << "@" << identity.instance() << " run as: "
           << identity.user_id();
@@ -81,6 +36,48 @@
 
 }  // namespace
 
+CapabilitySet GetRequestedCapabilities(const InterfaceProviderSpec& source_spec,
+                                       const Identity& target) {
+  CapabilitySet capabilities;
+
+  // Start by looking for specs specific to the supplied identity.
+  auto it = source_spec.requires.find(target.name());
+  if (it != source_spec.requires.end()) {
+    std::copy(it->second.begin(), it->second.end(),
+              std::inserter(capabilities, capabilities.begin()));
+  }
+
+  // Apply wild card rules too.
+  it = source_spec.requires.find("*");
+  if (it != source_spec.requires.end()) {
+    std::copy(it->second.begin(), it->second.end(),
+              std::inserter(capabilities, capabilities.begin()));
+  }
+  return capabilities;
+}
+
+InterfaceSet GetInterfacesToExpose(
+    const InterfaceProviderSpec& source_spec,
+    const Identity& target,
+    const InterfaceProviderSpec& target_spec) {
+  InterfaceSet exposed_interfaces;
+  // TODO(beng): remove this once we can assert that an InterfaceRegistry must
+  //             always be constructed with a valid identity.
+  if (!target.IsValid()) {
+    exposed_interfaces.insert("*");
+    return exposed_interfaces;
+  }
+  CapabilitySet capabilities = GetRequestedCapabilities(source_spec, target);
+  for (const auto& capability : capabilities) {
+    auto it = target_spec.provides.find(capability);
+    if (it != target_spec.provides.end()) {
+      for (const auto& interface_name : it->second)
+        exposed_interfaces.insert(interface_name);
+    }
+  }
+  return exposed_interfaces;
+}
+
 InterfaceRegistry::InterfaceRegistry(const std::string& name)
     : binding_(this),
       name_(name),
diff --git a/services/service_manager/public/cpp/lib/service_context.cc b/services/service_manager/public/cpp/lib/service_context.cc
index 88074a7..ed133376 100644
--- a/services/service_manager/public/cpp/lib/service_context.cc
+++ b/services/service_manager/public/cpp/lib/service_context.cc
@@ -98,14 +98,46 @@
                            local_info_.interface_provider_specs, &target_spec);
   GetInterfaceProviderSpec(mojom::kServiceManager_ConnectorSpec,
                            source_info.interface_provider_specs, &source_spec);
+
+  // Acknowledge the request regardless of whether it's accepted.
+  callback.Run();
+
+  CallOnConnect(source_info, source_spec, target_spec, std::move(interfaces));
+}
+
+void ServiceContext::OnBindInterface(
+    const ServiceInfo& source_info,
+    const std::string& interface_name,
+    mojo::ScopedMessagePipeHandle interface_pipe,
+    const OnBindInterfaceCallback& callback) {
+  // Acknowledge the request regardless of whether it's accepted.
+  callback.Run();
+
+  mojom::InterfaceProviderPtr interface_provider;
+  // TODO(beng): This should be replaced with a call to OnBindInterface() in a
+  //             subsequent change.
+  InterfaceProviderSpec source_spec, target_spec;
+  GetInterfaceProviderSpec(mojom::kServiceManager_ConnectorSpec,
+                           local_info_.interface_provider_specs, &target_spec);
+  GetInterfaceProviderSpec(mojom::kServiceManager_ConnectorSpec,
+                           source_info.interface_provider_specs, &source_spec);
+  CallOnConnect(source_info, source_spec, target_spec,
+                MakeRequest(&interface_provider));
+  interface_provider->GetInterface(interface_name, std::move(interface_pipe));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ServiceContext, private:
+
+void ServiceContext::CallOnConnect(const ServiceInfo& source_info,
+                                   const InterfaceProviderSpec& source_spec,
+                                   const InterfaceProviderSpec& target_spec,
+                                   mojom::InterfaceProviderRequest interfaces) {
   auto registry =
       base::MakeUnique<InterfaceRegistry>(mojom::kServiceManager_ConnectorSpec);
   registry->Bind(std::move(interfaces), local_info_.identity, target_spec,
                  source_info.identity, source_spec);
 
-  // Acknowledge the request regardless of whether it's accepted.
-  callback.Run();
-
   if (!service_->OnConnect(source_info, registry.get()))
     return;
 
@@ -117,9 +149,6 @@
       std::make_pair(raw_registry, std::move(registry)));
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// ServiceContext, private:
-
 void ServiceContext::OnConnectionError() {
   // Note that the Service doesn't technically have to quit now, it may live
   // on to service existing connections. All existing Connectors however are
diff --git a/services/service_manager/public/cpp/service_context.h b/services/service_manager/public/cpp/service_context.h
index 20e11e2c..7f3a152 100644
--- a/services/service_manager/public/cpp/service_context.h
+++ b/services/service_manager/public/cpp/service_context.h
@@ -112,6 +112,16 @@
   void OnConnect(const ServiceInfo& source_info,
                  mojom::InterfaceProviderRequest interfaces,
                  const OnConnectCallback& callback) override;
+  void OnBindInterface(
+      const ServiceInfo& source_info,
+      const std::string& interface_name,
+      mojo::ScopedMessagePipeHandle interface_pipe,
+      const OnBindInterfaceCallback& callback) override;
+
+  void CallOnConnect(const ServiceInfo& source_info,
+                     const InterfaceProviderSpec& source_spec,
+                     const InterfaceProviderSpec& target_spec,
+                     mojom::InterfaceProviderRequest request);
 
   void OnConnectionError();
   void OnRegistryConnectionError(InterfaceRegistry* registry);
diff --git a/services/service_manager/public/interfaces/service.mojom b/services/service_manager/public/interfaces/service.mojom
index e5f8d68..207da8cd 100644
--- a/services/service_manager/public/interfaces/service.mojom
+++ b/services/service_manager/public/interfaces/service.mojom
@@ -67,4 +67,32 @@
   //    seek to bind interface implementations exported by the target.
   //
   OnConnect(ServiceInfo source_info, InterfaceProvider&? interfaces) => ();
+
+  // Called when a request to bind an interface is received from another
+  // ("source") service. This is the result of that service calling
+  // BindInterface() on a Connector. By the time this method is called, the
+  // service manager has already completed a policy check to determine that this
+  // interface can be bound.
+  //
+  // The Service must respond to acknowledge receipt of the request.
+  //
+  // Parameters:
+  //
+  //  source_info
+  //    Contains the source identity and interface provider specs.
+  //
+  //  interface_name
+  //    The name of the interface to be bound.
+  //
+  //  interface_pipe
+  //    The message pipe to bind the interface implementation to.
+  //
+  // TODO(beng): It occurs to me that |source_info| leaks all metadata about
+  //             the source's capability requirements to the target. This seems
+  //             undesirable. The metadata supplied here should be germane to
+  //             fulfilling this request and no more.
+  // TODO(beng): This should replace OnConnect().
+  OnBindInterface(ServiceInfo source_info,
+                  string interface_name,
+                  handle<message_pipe> interface_pipe) => ();
 };
diff --git a/services/service_manager/service_manager.cc b/services/service_manager/service_manager.cc
index 63a0d7c..73f76e9 100644
--- a/services/service_manager/service_manager.cc
+++ b/services/service_manager/service_manager.cc
@@ -47,6 +47,21 @@
     "service_manager:instance_per_child";
 const char kCapability_ServiceManager[] = "service_manager:service_manager";
 
+bool Succeeded(mojom::ConnectResult result) {
+  return result == mojom::ConnectResult::SUCCEEDED;
+}
+
+void RunCallback(ConnectParams* params,
+                 mojom::ConnectResult result,
+                 const std::string& user_id) {
+  if (!params->connect_callback().is_null()) {
+    params->connect_callback().Run(result, user_id);
+    return;
+  }
+  if (!params->bind_interface_callback().is_null())
+    params->bind_interface_callback().Run(result, user_id);
+}
+
 }  // namespace
 
 Identity CreateServiceManagerIdentity() {
@@ -125,18 +140,19 @@
     Stop();
   }
 
-  bool ConnectToService(std::unique_ptr<ConnectParams>* connect_params) {
+  bool OnConnect(std::unique_ptr<ConnectParams>* in_params) {
     if (!service_.is_bound())
       return false;
 
-    std::unique_ptr<ConnectParams> params(std::move(*connect_params));
+    std::unique_ptr<ConnectParams> params(std::move(*in_params));
     if (!params->connect_callback().is_null()) {
       params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED,
                                      identity_.user_id());
     }
 
     InterfaceProviderSpecMap specs;
-    Instance* source = service_manager_->GetExistingInstance(params->source());
+    Instance* source =
+        service_manager_->GetExistingInstance(params->source());
     if (source)
       specs = source->interface_provider_specs_;
 
@@ -148,6 +164,48 @@
     return true;
   }
 
+  bool OnBindInterface(std::unique_ptr<ConnectParams>* in_params) {
+    if (!service_.is_bound())
+      return false;
+
+    std::unique_ptr<ConnectParams> params(std::move(*in_params));
+    InterfaceProviderSpecMap source_specs;
+    InterfaceProviderSpec source_connection_spec;
+    Instance* source =
+        service_manager_->GetExistingInstance(params->source());
+    if (source) {
+      source_specs = source->interface_provider_specs_;
+      source_connection_spec = source->GetConnectionSpec();
+    }
+
+    InterfaceSet exposed = GetInterfacesToExpose(source_connection_spec,
+                                                 identity_,
+                                                 GetConnectionSpec());
+    bool allowed = (exposed.size() == 1 && exposed.count("*") == 1) ||
+        exposed.count(params->interface_name()) > 0;
+    if (!allowed) {
+      std::stringstream ss;
+      ss << "Connection InterfaceProviderSpec prevented service: "
+         << params->source().name() << " from binding interface: "
+         << params->interface_name() << " exposed by: " << identity_.name();
+      LOG(ERROR) << ss.str();
+      params->bind_interface_callback().Run(mojom::ConnectResult::ACCESS_DENIED,
+                                            identity_.user_id());
+      return false;
+    }
+
+    params->bind_interface_callback().Run(mojom::ConnectResult::SUCCEEDED,
+                                          identity_.user_id());
+
+    pending_service_connections_++;
+    service_->OnBindInterface(
+        ServiceInfo(params->source(), source_specs),
+        params->interface_name(),
+        params->TakeInterfaceRequestPipe(),
+        base::Bind(&Instance::OnConnectComplete, base::Unretained(this)));
+    return true;
+  }
+
   void OnConnectComplete() {
     DCHECK_GT(pending_service_connections_, 0);
     pending_service_connections_--;
@@ -229,76 +287,69 @@
 
   // mojom::Connector implementation:
   void StartService(
-      const Identity& target,
+      const Identity& in_target,
       mojo::ScopedMessagePipeHandle service_handle,
       mojom::PIDReceiverRequest pid_receiver_request) override {
-    mojom::ServicePtr service;
-    service.Bind(mojom::ServicePtrInfo(std::move(service_handle), 0));
-    ConnectImpl(
-        target,
-        mojom::InterfaceProviderRequest(),
-        std::move(service),
-        std::move(pid_receiver_request),
-        base::Bind(
-            &service_manager::ServiceManager::Instance::EmptyConnectCallback,
-            weak_factory_.GetWeakPtr()));
-  }
-
-  void Connect(const service_manager::Identity& target,
-               mojom::InterfaceProviderRequest remote_interfaces,
-               const ConnectCallback& callback) override {
-    ConnectImpl(target, std::move(remote_interfaces), mojom::ServicePtr(),
-                mojom::PIDReceiverRequest(), callback);
-  }
-
-  void BindInterface(const service_manager::Identity& target,
-                     const std::string& interface_name,
-                     mojo::ScopedMessagePipeHandle interface_pipe,
-                     const BindInterfaceCallback& callback) override {
-    mojom::InterfaceProviderPtr remote_interfaces;
-    ConnectImpl(
-        target,
-        MakeRequest(&remote_interfaces),
-        mojom::ServicePtr(),
-        mojom::PIDReceiverRequest(),
-        base::Bind(
-            &service_manager::ServiceManager::Instance::BindCallbackWrapper,
-            weak_factory_.GetWeakPtr(),
-            callback));
-    remote_interfaces->GetInterface(interface_name, std::move(interface_pipe));
-    // TODO(beng): Rather than just forwarding thru to InterfaceProvider, do
-    //             manifest policy intersection here.
-  }
-
-  void ConnectImpl(const service_manager::Identity& in_target,
-                   mojom::InterfaceProviderRequest remote_interfaces,
-                   mojom::ServicePtr service,
-                   mojom::PIDReceiverRequest pid_receiver_request,
-                   const ConnectCallback& callback) {
     Identity target = in_target;
-    if (target.user_id() == mojom::kInheritUserID)
-      target.set_user_id(identity_.user_id());
-
-    if (!ValidateIdentity(target, callback))
-      return;
-    if (!ValidateClientProcessInfo(&service, &pid_receiver_request, target,
-                                   callback)) {
-      return;
-    }
-    if (!ValidateConnectionSpec(target, callback))
+    mojom::ConnectResult result =
+        ValidateConnectParams(&target, nullptr, nullptr);
+    if (!Succeeded(result))
       return;
 
     std::unique_ptr<ConnectParams> params(new ConnectParams);
     params->set_source(identity_);
     params->set_target(target);
-    params->set_remote_interfaces(std::move(remote_interfaces));
+
+    mojom::ServicePtr service;
+    service.Bind(mojom::ServicePtrInfo(std::move(service_handle), 0));
     params->set_client_process_info(std::move(service),
                                     std::move(pid_receiver_request));
+    service_manager_->Connect(
+        std::move(params), nullptr, weak_factory_.GetWeakPtr());
+  }
+
+  void Connect(const service_manager::Identity& in_target,
+               mojom::InterfaceProviderRequest remote_interfaces,
+               const ConnectCallback& callback) override {
+    Identity target = in_target;
+    mojom::ConnectResult result =
+        ValidateConnectParams(&target, nullptr, nullptr);
+    if (!Succeeded(result)) {
+      callback.Run(result, mojom::kInheritUserID);
+      return;
+    }
+
+    std::unique_ptr<ConnectParams> params(new ConnectParams);
+    params->set_source(identity_);
+    params->set_target(target);
+    params->set_remote_interfaces(std::move(remote_interfaces));
     params->set_connect_callback(callback);
     service_manager_->Connect(
         std::move(params), nullptr, weak_factory_.GetWeakPtr());
   }
 
+  void BindInterface(const service_manager::Identity& in_target,
+                     const std::string& interface_name,
+                     mojo::ScopedMessagePipeHandle interface_pipe,
+                     const BindInterfaceCallback& callback) override {
+    Identity target = in_target;
+    mojom::ConnectResult result =
+        ValidateConnectParams(&target, nullptr, nullptr);
+    if (!Succeeded(result)) {
+      callback.Run(result, mojom::kInheritUserID);
+      return;
+    }
+
+    std::unique_ptr<ConnectParams> params(new ConnectParams);
+    params->set_source(identity_);
+    params->set_target(target);
+    params->set_interface_request_info(interface_name,
+                                       std::move(interface_pipe));
+    params->set_bind_interface_callback(callback);
+    service_manager_->Connect(
+        std::move(params), nullptr, weak_factory_.GetWeakPtr());
+  }
+
   void Clone(mojom::ConnectorRequest request) override {
     connectors_.AddBinding(this, std::move(request));
   }
@@ -321,61 +372,66 @@
     service_manager_->AddListener(std::move(listener));
   }
 
-  bool ValidateIdentity(const Identity& identity,
-                        const ConnectCallback& callback) {
+  mojom::ConnectResult ValidateConnectParams(
+      Identity* target,
+      mojom::ServicePtr* service,
+      mojom::PIDReceiverRequest* pid_receiver_request) {
+    if (target->user_id() == mojom::kInheritUserID)
+      target->set_user_id(identity_.user_id());
+
+    mojom::ConnectResult result = ValidateIdentity(*target);
+    if (!Succeeded(result))
+      return result;
+
+    result = ValidateClientProcessInfo(service, pid_receiver_request, *target);
+    if (!Succeeded(result))
+      return result;
+    return ValidateConnectionSpec(*target);
+  }
+
+  mojom::ConnectResult ValidateIdentity(const Identity& identity) {
     if (identity.name().empty()) {
       LOG(ERROR) << "Error: empty service name.";
-      callback.Run(mojom::ConnectResult::INVALID_ARGUMENT,
-                   mojom::kInheritUserID);
-      return false;
+      return mojom::ConnectResult::INVALID_ARGUMENT;
     }
     if (!base::IsValidGUID(identity.user_id())) {
       LOG(ERROR) << "Error: invalid user_id: " << identity.user_id();
-      callback.Run(mojom::ConnectResult::INVALID_ARGUMENT,
-                   mojom::kInheritUserID);
-      return false;
+      return mojom::ConnectResult::INVALID_ARGUMENT;
     }
-    return true;
+    return mojom::ConnectResult::SUCCEEDED;
   }
 
-  bool ValidateClientProcessInfo(
+  mojom::ConnectResult ValidateClientProcessInfo(
       mojom::ServicePtr* service,
       mojom::PIDReceiverRequest* pid_receiver_request,
-      const Identity& target,
-      const ConnectCallback& callback) {
-    if (service->is_bound() || pid_receiver_request->is_pending()) {
+      const Identity& target) {
+    if (service && pid_receiver_request &&
+        (service->is_bound() || pid_receiver_request->is_pending())) {
       if (!HasCapability(GetConnectionSpec(), kCapability_ClientProcess)) {
         LOG(ERROR) << "Instance: " << identity_.name() << " attempting "
                    << "to register an instance for a process it created for "
                    << "target: " << target.name() << " without the "
                    << "service_manager{client_process} capability "
                    << "class.";
-        callback.Run(mojom::ConnectResult::ACCESS_DENIED,
-                     mojom::kInheritUserID);
-        return false;
+        return mojom::ConnectResult::ACCESS_DENIED;
       }
 
       if (!service->is_bound() || !pid_receiver_request->is_pending()) {
         LOG(ERROR) << "Must supply both service AND "
                    << "pid_receiver_request when sending client process info";
-        callback.Run(mojom::ConnectResult::INVALID_ARGUMENT,
-                     mojom::kInheritUserID);
-        return false;
+        return mojom::ConnectResult::INVALID_ARGUMENT;
       }
       if (service_manager_->GetExistingInstance(target)) {
         LOG(ERROR) << "Cannot client process matching existing identity:"
                    << "Name: " << target.name() << " User: "
                    << target.user_id() << " Instance: " << target.instance();
-        callback.Run(mojom::ConnectResult::INVALID_ARGUMENT,
-                     mojom::kInheritUserID);
-        return false;
+        return mojom::ConnectResult::INVALID_ARGUMENT;
       }
     }
-    return true;
+    return mojom::ConnectResult::SUCCEEDED;
   }
 
-  bool ValidateConnectionSpec(const Identity& target,
-                              const ConnectCallback& callback) {
+  mojom::ConnectResult ValidateConnectionSpec(const Identity& target) {
     InterfaceProviderSpec connection_spec = GetConnectionSpec();
     // TODO(beng): Need to do the following additional policy validation of
     // whether this instance is allowed to connect using:
@@ -388,9 +444,7 @@
                  << " attempting to connect to: " << target.name()
                  << " as: " << target.user_id() << " without "
                  << " the service:service_manager{user_id} capability.";
-      callback.Run(mojom::ConnectResult::ACCESS_DENIED,
-                   mojom::kInheritUserID);
-      return false;
+      return mojom::ConnectResult::ACCESS_DENIED;
     }
     if (!target.instance().empty() &&
         target.instance() != target.name() &&
@@ -400,19 +454,17 @@
                  << " using Instance name: " << target.instance()
                  << " without the "
                  << "service_manager{instance_name} capability.";
-      callback.Run(mojom::ConnectResult::ACCESS_DENIED, mojom::kInheritUserID);
-      return false;
+      return mojom::ConnectResult::ACCESS_DENIED;
     }
 
     if (allow_any_application_ ||
         connection_spec.requires.find(target.name()) !=
             connection_spec.requires.end()) {
-      return true;
+      return mojom::ConnectResult::SUCCEEDED;
     }
     LOG(ERROR) << "InterfaceProviderSpec prevented connection from: "
                << identity_.name() << " to: " << target.name();
-    callback.Run(mojom::ConnectResult::ACCESS_DENIED, mojom::kInheritUserID);
-    return false;
+    return mojom::ConnectResult::ACCESS_DENIED;
   }
 
   uint32_t GenerateUniqueID() const {
@@ -782,7 +834,14 @@
 bool ServiceManager::ConnectToExistingInstance(
     std::unique_ptr<ConnectParams>* params) {
   Instance* instance = GetExistingInstance((*params)->target());
-  return instance && instance->ConnectToService(params);
+  if (instance) {
+    if ((*params)->HasInterfaceRequestInfo()) {
+      instance->OnBindInterface(params);
+      return true;
+    }
+    return instance->OnConnect(params);
+  }
+  return false;
 }
 
 ServiceManager::Instance* ServiceManager::CreateInstance(
@@ -868,10 +927,7 @@
   // If name resolution failed, we drop the connection.
   if (!result) {
     LOG(ERROR) << "Failed to resolve service name: " << params->target().name();
-    if (!params->connect_callback().is_null()) {
-      params->connect_callback().Run(
-          mojom::ConnectResult::INVALID_ARGUMENT, "");
-    }
+    RunCallback(params.get(), mojom::ConnectResult::INVALID_ARGUMENT, "");
     return;
   }
 
@@ -941,8 +997,7 @@
       LOG(ERROR)
           << "Error: The catalog was unable to read a manifest for service \""
           << result->name << "\".";
-      if (!params->connect_callback().is_null())
-        params->connect_callback().Run(mojom::ConnectResult::ACCESS_DENIED, "");
+      RunCallback(params.get(), mojom::ConnectResult::ACCESS_DENIED, "");
       return;
     }
 
@@ -980,18 +1035,19 @@
 
       if (!instance->StartWithFilePath(package_path)) {
         OnInstanceError(instance);
-        if (!params->connect_callback().is_null()) {
-          params->connect_callback().Run(
-              mojom::ConnectResult::INVALID_ARGUMENT, "");
-        }
+        RunCallback(params.get(), mojom::ConnectResult::INVALID_ARGUMENT, "");
         return;
       }
     }
   }
 
   // Now that the instance has a Service, we can connect to it.
-  bool connected = instance->ConnectToService(&params);
-  DCHECK(connected);
+  if (params->HasInterfaceRequestInfo()) {
+    instance->OnBindInterface(&params);
+  } else {
+    bool connected = instance->OnConnect(&params);
+    DCHECK(connected);
+  }
 }
 
 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() {
diff --git a/storage/browser/blob/blob_memory_controller.cc b/storage/browser/blob/blob_memory_controller.cc
index f4a002fc..298037c 100644
--- a/storage/browser/blob/blob_memory_controller.cc
+++ b/storage/browser/blob/blob_memory_controller.cc
@@ -7,6 +7,8 @@
 #include <algorithm>
 #include <numeric>
 
+#include "base/bind.h"
+#include "base/bind_helpers.h"
 #include "base/callback.h"
 #include "base/callback_helpers.h"
 #include "base/containers/small_map.h"
@@ -20,12 +22,12 @@
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
+#include "base/sys_info.h"
 #include "base/task_runner.h"
 #include "base/task_runner_util.h"
 #include "base/threading/thread_restrictions.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
-#include "base/tuple.h"
 #include "storage/browser/blob/blob_data_builder.h"
 #include "storage/browser/blob/blob_data_item.h"
 #include "storage/browser/blob/shareable_blob_data_item.h"
@@ -37,9 +39,59 @@
 
 namespace storage {
 namespace {
+constexpr int64_t kUnknownDiskAvailability = -1ll;
+constexpr uint64_t kMegabyte = 1024ull * 1024;
+
 using FileCreationInfo = BlobMemoryController::FileCreationInfo;
 using MemoryAllocation = BlobMemoryController::MemoryAllocation;
 using QuotaAllocationTask = BlobMemoryController::QuotaAllocationTask;
+using DiskSpaceFuncPtr = BlobMemoryController::DiskSpaceFuncPtr;
+
+// CrOS:
+// * Ram -  20%
+// * Disk - 50%
+//   Note: The disk is the user partition, so the operating system can still
+//   function if this is full.
+// Android:
+// * RAM -  20%
+// * Disk -  5%
+// Desktop:
+// * Ram -  20%, or 2 GB if x64.
+// * Disk - 10%
+BlobStorageLimits CalculateBlobStorageLimitsImpl(const FilePath& storage_dir,
+                                                 bool disk_enabled) {
+  int64_t disk_size =
+      disk_enabled ? base::SysInfo::AmountOfTotalDiskSpace(storage_dir) : 0ull;
+  int64_t memory_size = base::SysInfo::AmountOfPhysicalMemory();
+
+  BlobStorageLimits limits;
+
+  // Don't do specialty configuration for error size (-1).
+  if (memory_size > 0) {
+#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && defined(ARCH_CPU_64_BITS)
+    constexpr size_t kTwoGigabytes = 2ull * 1024 * 1024 * 1024;
+    limits.max_blob_in_memory_space = kTwoGigabytes;
+#else
+    limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 5ll);
+#endif
+  }
+
+  // Don't do specialty configuration for error size (-1). Allow no disk.
+  if (disk_size >= 0) {
+#if defined(OS_CHROMEOS)
+    limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 2ll);
+#elif defined(OS_ANDROID)
+    limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 20ll);
+#else
+    limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 10ll);
+#endif
+  }
+  UMA_HISTOGRAM_COUNTS_1M("Storage.Blob.MaxDiskSpace",
+                          limits.desired_max_disk_space / kMegabyte);
+  limits.effective_max_disk_space = limits.desired_max_disk_space;
+
+  return limits;
+}
 
 File::Error CreateBlobDirectory(const FilePath& blob_storage_dir) {
   File::Error error = File::FILE_OK;
@@ -53,17 +105,47 @@
 
 void DestructFile(File infos_without_references) {}
 
+void DeleteFiles(std::vector<FileCreationInfo> files) {
+  for (FileCreationInfo& file_info : files) {
+    file_info.file.Close();
+    base::DeleteFile(file_info.path, false);
+  }
+}
+
+struct EmptyFilesResult {
+  EmptyFilesResult() {}
+  EmptyFilesResult(std::vector<FileCreationInfo> files,
+                   File::Error file_error,
+                   int64_t disk_availability)
+      : files(std::move(files)),
+        file_error(file_error),
+        disk_availability(disk_availability) {}
+  ~EmptyFilesResult() {}
+  EmptyFilesResult(EmptyFilesResult&& o) = default;
+  EmptyFilesResult& operator=(EmptyFilesResult&& other) = default;
+
+  std::vector<FileCreationInfo> files;
+  File::Error file_error = File::FILE_ERROR_FAILED;
+  int64_t disk_availability = 0;
+};
+
 // Used for new unpopulated file items. Caller must populate file reference in
-// returned FileCreationInfos.
-std::pair<std::vector<FileCreationInfo>, File::Error> CreateEmptyFiles(
+// returned FileCreationInfos. Also returns the currently available disk space
+// (without the future size of these files).
+EmptyFilesResult CreateEmptyFiles(
     const FilePath& blob_storage_dir,
+    DiskSpaceFuncPtr disk_space_function,
     scoped_refptr<base::TaskRunner> file_task_runner,
     std::vector<base::FilePath> file_paths) {
   base::ThreadRestrictions::AssertIOAllowed();
 
   File::Error dir_create_status = CreateBlobDirectory(blob_storage_dir);
-  if (dir_create_status != File::FILE_OK)
-    return std::make_pair(std::vector<FileCreationInfo>(), dir_create_status);
+  if (dir_create_status != File::FILE_OK) {
+    return EmptyFilesResult(std::vector<FileCreationInfo>(), dir_create_status,
+                            kUnknownDiskAvailability);
+  }
+
+  int64_t free_disk_space = disk_space_function(blob_storage_dir);
 
   std::vector<FileCreationInfo> result;
   for (const base::FilePath& file_path : file_paths) {
@@ -74,20 +156,22 @@
     creation_info.file_deletion_runner = file_task_runner;
     creation_info.error = file.error_details();
     if (creation_info.error != File::FILE_OK) {
-      return std::make_pair(std::vector<FileCreationInfo>(),
-                            creation_info.error);
+      return EmptyFilesResult(std::vector<FileCreationInfo>(),
+                              creation_info.error, free_disk_space);
     }
     creation_info.file = std::move(file);
 
     result.push_back(std::move(creation_info));
   }
-  return std::make_pair(std::move(result), File::FILE_OK);
+  return EmptyFilesResult(std::move(result), File::FILE_OK, free_disk_space);
 }
 
 // Used to evict multiple memory items out to a single file. Caller must
-// populate file reference in returned FileCreationInfo.
-FileCreationInfo CreateFileAndWriteItems(
+// populate file reference in returned FileCreationInfo. Also returns the free
+// disk space AFTER creating this file.
+std::pair<FileCreationInfo, int64_t> CreateFileAndWriteItems(
     const FilePath& blob_storage_dir,
+    DiskSpaceFuncPtr disk_space_function,
     const FilePath& file_path,
     scoped_refptr<base::TaskRunner> file_task_runner,
     std::vector<DataElement*> items,
@@ -100,14 +184,27 @@
   creation_info.file_deletion_runner = std::move(file_task_runner);
   creation_info.error = CreateBlobDirectory(blob_storage_dir);
   if (creation_info.error != File::FILE_OK)
-    return creation_info;
+    return std::make_pair(std::move(creation_info), kUnknownDiskAvailability);
+
+  int64_t free_disk_space = disk_space_function(blob_storage_dir);
+
+  // Fail early instead of creating the files if we fill the disk.
+  if (free_disk_space != kUnknownDiskAvailability &&
+      free_disk_space < static_cast<int64_t>(total_size_bytes)) {
+    creation_info.error = File::FILE_ERROR_NO_SPACE;
+    return std::make_pair(std::move(creation_info), free_disk_space);
+  }
+  int64_t disk_availability =
+      free_disk_space == kUnknownDiskAvailability
+          ? kUnknownDiskAvailability
+          : free_disk_space - static_cast<int64_t>(total_size_bytes);
 
   // Create the page file.
   File file(file_path, File::FLAG_CREATE_ALWAYS | File::FLAG_WRITE);
   creation_info.path = file_path;
   creation_info.error = file.error_details();
   if (creation_info.error != File::FILE_OK)
-    return creation_info;
+    return std::make_pair(std::move(creation_info), free_disk_space);
 
   // Write data.
   file.SetLength(total_size_bytes);
@@ -129,8 +226,10 @@
       break;
   }
   if (!file.Flush()) {
+    file.Close();
+    base::DeleteFile(file_path, false);
     creation_info.error = File::FILE_ERROR_FAILED;
-    return creation_info;
+    return std::make_pair(std::move(creation_info), free_disk_space);
   }
 
   File::Info info;
@@ -138,7 +237,7 @@
   creation_info.error =
       bytes_written < 0 || !success ? File::FILE_ERROR_FAILED : File::FILE_OK;
   creation_info.last_modified = info.last_modified;
-  return creation_info;
+  return std::make_pair(std::move(creation_info), disk_availability);
 }
 
 uint64_t GetTotalSizeAndFileSizes(
@@ -255,15 +354,15 @@
   // We post a task to create the file for the items right away.
   FileQuotaAllocationTask(
       BlobMemoryController* memory_controller,
+      DiskSpaceFuncPtr disk_space_function,
       std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items,
       const FileQuotaRequestCallback& done_callback)
       : controller_(memory_controller),
         done_callback_(done_callback),
         weak_factory_(this) {
     // Get the file sizes and total size.
-    std::vector<uint64_t> file_sizes;
     uint64_t total_size =
-        GetTotalSizeAndFileSizes(unreserved_file_items, &file_sizes);
+        GetTotalSizeAndFileSizes(unreserved_file_items, &file_sizes_);
     DCHECK_LE(total_size, controller_->GetAvailableFileSpaceForBlobs());
     allocation_size_ = total_size;
 
@@ -279,23 +378,21 @@
     controller_->disk_used_ += allocation_size_;
     std::vector<base::FilePath> file_paths;
     std::vector<scoped_refptr<ShareableFileReference>> references;
-    for (size_t i = 0; i < file_sizes.size(); i++) {
+    for (size_t i = 0; i < file_sizes_.size(); i++) {
       file_paths.push_back(controller_->GenerateNextPageFileName());
       references.push_back(ShareableFileReference::GetOrCreate(
           file_paths.back(), ShareableFileReference::DELETE_ON_FINAL_RELEASE,
           controller_->file_runner_.get()));
-      references.back()->AddFinalReleaseCallback(
-          base::Bind(&BlobMemoryController::OnBlobFileDelete,
-                     controller_->weak_factory_.GetWeakPtr(), file_sizes[i]));
     }
-
     // Send file creation task to file thread.
     base::PostTaskAndReplyWithResult(
         controller_->file_runner_.get(), FROM_HERE,
         base::Bind(&CreateEmptyFiles, controller_->blob_storage_dir_,
-                   controller_->file_runner_, base::Passed(&file_paths)),
+                   disk_space_function, controller_->file_runner_,
+                   base::Passed(&file_paths)),
         base::Bind(&FileQuotaAllocationTask::OnCreateEmptyFiles,
-                   weak_factory_.GetWeakPtr(), base::Passed(&references)));
+                   weak_factory_.GetWeakPtr(), base::Passed(&references),
+                   allocation_size_));
     controller_->RecordTracingCounters();
   }
   ~FileQuotaAllocationTask() override {}
@@ -308,6 +405,13 @@
     // successful.
     std::unique_ptr<FileQuotaAllocationTask> this_object;
     if (success) {
+      // Register the disk space accounting callback.
+      DCHECK_EQ(file_info.size(), file_sizes_.size());
+      for (size_t i = 0; i < file_sizes_.size(); i++) {
+        file_info[i].file_reference->AddFinalReleaseCallback(base::Bind(
+            &BlobMemoryController::OnBlobFileDelete,
+            controller_->weak_factory_.GetWeakPtr(), file_sizes_[i]));
+      }
       for (auto& item : pending_items_) {
         item->set_state(ShareableBlobDataItem::QUOTA_GRANTED);
       }
@@ -323,27 +427,49 @@
   }
 
   void Cancel() override {
-    // This call destroys this object. We rely on ShareableFileReference's
-    // final release callback for disk_usage_ accounting.
+    DCHECK_GE(controller_->disk_used_, allocation_size_);
+    controller_->disk_used_ -= allocation_size_;
+    // This call destroys this object.
     controller_->pending_file_quota_tasks_.erase(my_list_position_);
   }
 
   void OnCreateEmptyFiles(
       std::vector<scoped_refptr<ShareableFileReference>> references,
-      std::pair<std::vector<FileCreationInfo>, File::Error> files_and_error) {
-    auto& files = files_and_error.first;
-    if (files.empty()) {
+      uint64_t new_files_total_size,
+      EmptyFilesResult result) {
+    int64_t avail_disk_space = result.disk_availability;
+    if (result.files.empty()) {
+      DCHECK_NE(result.file_error, File::FILE_OK);
       DCHECK_GE(controller_->disk_used_, allocation_size_);
       controller_->disk_used_ -= allocation_size_;
       // This will call our callback and delete the object correctly.
-      controller_->DisableFilePaging(files_and_error.second);
+      controller_->DisableFilePaging(result.file_error);
       return;
     }
-    DCHECK_EQ(files.size(), references.size());
-    for (size_t i = 0; i < files.size(); i++) {
-      files[i].file_reference = std::move(references[i]);
+    // The allocation won't fit at all. Cancel this request. The disk will be
+    // decremented when the file is deleted through AddFinalReleaseCallback.
+    if (avail_disk_space != kUnknownDiskAvailability &&
+        base::checked_cast<uint64_t>(avail_disk_space) < new_files_total_size) {
+      DCHECK_GE(controller_->disk_used_, allocation_size_);
+      controller_->disk_used_ -= allocation_size_;
+      controller_->AdjustDiskUsage(static_cast<uint64_t>(avail_disk_space));
+      controller_->file_runner_->PostTask(
+          FROM_HERE, base::Bind(&DeleteFiles, base::Passed(&result.files)));
+      std::unique_ptr<FileQuotaAllocationTask> this_object =
+          std::move(*my_list_position_);
+      controller_->pending_file_quota_tasks_.erase(my_list_position_);
+      RunDoneCallback(std::vector<FileCreationInfo>(), false);
+      return;
     }
-    RunDoneCallback(std::move(files), true);
+    if (avail_disk_space != kUnknownDiskAvailability) {
+      controller_->AdjustDiskUsage(base::checked_cast<uint64_t>(
+          avail_disk_space - new_files_total_size));
+    }
+    DCHECK_EQ(result.files.size(), references.size());
+    for (size_t i = 0; i < result.files.size(); i++) {
+      result.files[i].file_reference = std::move(references[i]);
+    }
+    RunDoneCallback(std::move(result.files), true);
   }
 
   // The my_list_position_ iterator is stored so that we can remove ourself
@@ -353,10 +479,12 @@
     my_list_position_ = my_list_position;
   }
 
+  size_t allocation_size() const { return allocation_size_; }
+
  private:
   BlobMemoryController* controller_;
+  std::vector<uint64_t> file_sizes_;
   std::vector<scoped_refptr<ShareableBlobDataItem>> pending_items_;
-  scoped_refptr<base::TaskRunner> file_runner_;
   FileQuotaRequestCallback done_callback_;
 
   uint64_t allocation_size_;
@@ -372,6 +500,7 @@
     : file_paging_enabled_(file_runner.get() != nullptr),
       blob_storage_dir_(storage_directory),
       file_runner_(std::move(file_runner)),
+      disk_space_function_(&base::SysInfo::AmountOfFreeDiskSpace),
       populated_memory_items_(
           base::MRUCache<uint64_t, ShareableBlobDataItem*>::NO_AUTO_EVICT),
       weak_factory_(this) {}
@@ -401,6 +530,9 @@
     memory_request->RunDoneCallback(false);
   }
   for (auto& file_request : old_file_tasks) {
+    // OnBlobFileDelete is registered when RunDoneCallback is called with
+    // |true|, so manually do disk accounting.
+    disk_used_ -= file_request->allocation_size();
     file_request->RunDoneCallback(std::vector<FileCreationInfo>(), false);
   }
 }
@@ -417,11 +549,12 @@
   // we can also fit them.
   if (preemptive_transported_bytes == total_transportation_bytes &&
       pending_memory_quota_tasks_.empty() &&
-      preemptive_transported_bytes < GetAvailableMemoryForBlobs()) {
+      preemptive_transported_bytes <= GetAvailableMemoryForBlobs()) {
     return Strategy::NONE_NEEDED;
   }
   if (file_paging_enabled_ &&
-      (total_transportation_bytes > limits_.memory_limit_before_paging())) {
+      total_transportation_bytes <= GetAvailableFileSpaceForBlobs() &&
+      total_transportation_bytes > limits_.memory_limit_before_paging()) {
     return Strategy::FILE;
   }
   if (total_transportation_bytes > limits_.max_ipc_memory_size)
@@ -488,7 +621,8 @@
     std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items,
     const FileQuotaRequestCallback& done_callback) {
   pending_file_quota_tasks_.push_back(base::MakeUnique<FileQuotaAllocationTask>(
-      this, std::move(unreserved_file_items), done_callback));
+      this, disk_space_function_, std::move(unreserved_file_items),
+      done_callback));
   pending_file_quota_tasks_.back()->set_my_list_position(
       --pending_file_quota_tasks_.end());
   return pending_file_quota_tasks_.back()->GetWeakPtr();
@@ -516,6 +650,92 @@
   MaybeScheduleEvictionUntilSystemHealthy();
 }
 
+void BlobMemoryController::CalculateBlobStorageLimits() {
+  if (file_runner_) {
+    PostTaskAndReplyWithResult(
+        file_runner_.get(), FROM_HERE,
+        base::Bind(&CalculateBlobStorageLimitsImpl, blob_storage_dir_, true),
+        base::Bind(&BlobMemoryController::OnStorageLimitsCalculated,
+                   weak_factory_.GetWeakPtr()));
+  } else {
+    OnStorageLimitsCalculated(
+        CalculateBlobStorageLimitsImpl(blob_storage_dir_, false));
+  }
+}
+
+base::WeakPtr<BlobMemoryController> BlobMemoryController::GetWeakPtr() {
+  return weak_factory_.GetWeakPtr();
+}
+
+void BlobMemoryController::OnStorageLimitsCalculated(BlobStorageLimits limits) {
+  if (!limits.IsValid() || manual_limits_set_)
+    return;
+  limits_ = limits;
+}
+
+namespace {
+// Used in UMA metrics, do not change values.
+enum DiskSpaceAdjustmentType {
+  FREEZE_HIT_MIN_AVAILABLE = 0,
+  LOWERED_NEAR_MIN_AVAILABLE = 1,
+  RAISED_NEAR_MIN_AVAILABLE = 2,
+  RESTORED = 3,
+  MAX_ADJUSTMENT_TYPE
+};
+
+enum DiskSpaceAdjustmentStatus { FROZEN, ADJUSTED, NORMAL };
+}  // namespace
+
+void BlobMemoryController::AdjustDiskUsage(uint64_t avail_disk) {
+  DCHECK_LE(disk_used_, limits_.desired_max_disk_space +
+                            limits_.min_available_external_disk_space());
+
+  DiskSpaceAdjustmentStatus curr_status;
+  if (limits_.effective_max_disk_space == limits_.desired_max_disk_space) {
+    curr_status = NORMAL;
+  } else if (limits_.effective_max_disk_space == disk_used_) {
+    curr_status = FROZEN;
+  } else {
+    curr_status = ADJUSTED;
+  }
+  uint64_t old_effective_max_disk_space = limits_.effective_max_disk_space;
+  uint64_t avail_disk_without_blobs = avail_disk + disk_used_;
+
+  // Note: The UMA metrics here intended to record state change between frozen,
+  // adjusted, and normal states.
+
+  if (avail_disk <= limits_.min_available_external_disk_space()) {
+    limits_.effective_max_disk_space = disk_used_;
+    if (curr_status != FROZEN &&
+        limits_.effective_max_disk_space != old_effective_max_disk_space) {
+      UMA_HISTOGRAM_ENUMERATION("Storage.Blob.MaxDiskSpaceAdjustment",
+                                FREEZE_HIT_MIN_AVAILABLE, MAX_ADJUSTMENT_TYPE);
+    }
+  } else if (avail_disk_without_blobs <
+             limits_.min_available_external_disk_space() +
+                 limits_.desired_max_disk_space) {
+    // |effective_max_disk_space| is guaranteed to be less than
+    // |desired_max_disk_space| by the if statement.
+    limits_.effective_max_disk_space =
+        avail_disk_without_blobs - limits_.min_available_external_disk_space();
+    if (curr_status != ADJUSTED &&
+        limits_.effective_max_disk_space != old_effective_max_disk_space) {
+      UMA_HISTOGRAM_ENUMERATION("Storage.Blob.MaxDiskSpaceAdjustment",
+                                curr_status == NORMAL
+                                    ? LOWERED_NEAR_MIN_AVAILABLE
+                                    : RAISED_NEAR_MIN_AVAILABLE,
+                                MAX_ADJUSTMENT_TYPE);
+    }
+  } else {
+    limits_.effective_max_disk_space = limits_.desired_max_disk_space;
+    if (curr_status != NORMAL &&
+        limits_.effective_max_disk_space != old_effective_max_disk_space) {
+      UMA_HISTOGRAM_ENUMERATION("Storage.Blob.MaxDiskSpaceAdjustment", RESTORED,
+                                MAX_ADJUSTMENT_TYPE);
+    }
+  }
+}
+
 base::WeakPtr<QuotaAllocationTask> BlobMemoryController::AppendMemoryTask(
     uint64_t total_bytes_needed,
     std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_memory_items,
@@ -574,10 +794,16 @@
   if (pending_evictions_ != 0 || !file_paging_enabled_)
     return;
 
+  uint64_t total_memory_usage =
+      static_cast<uint64_t>(pending_memory_quota_total_size_) +
+      blob_memory_used_;
+
   // We try to page items to disk until our current system size + requested
   // memory is below our size limit.
-  while (pending_memory_quota_total_size_ + blob_memory_used_ >
-         limits_.memory_limit_before_paging()) {
+  // Size limit is a lower |memory_limit_before_paging()| if we have disk space.
+  while (total_memory_usage > limits_.effective_max_disk_space ||
+         (disk_used_ < limits_.effective_max_disk_space &&
+          total_memory_usage > limits_.memory_limit_before_paging())) {
     // We only page when we have enough items to fill a whole page file.
     if (populated_memory_items_bytes_ < limits_.min_page_file_size)
       break;
@@ -616,8 +842,9 @@
     base::PostTaskAndReplyWithResult(
         file_runner_.get(), FROM_HERE,
         base::Bind(&CreateFileAndWriteItems, blob_storage_dir_,
-                   base::Passed(&page_file_path), file_runner_,
-                   base::Passed(&items_for_paging), total_items_size),
+                   disk_space_function_, base::Passed(&page_file_path),
+                   file_runner_, base::Passed(&items_for_paging),
+                   total_items_size),
         base::Bind(&BlobMemoryController::OnEvictionComplete,
                    weak_factory_.GetWeakPtr(), base::Passed(&file_reference),
                    base::Passed(&items_to_swap), total_items_size));
@@ -629,15 +856,22 @@
     scoped_refptr<ShareableFileReference> file_reference,
     std::vector<scoped_refptr<ShareableBlobDataItem>> items,
     size_t total_items_size,
-    FileCreationInfo result) {
+    std::pair<FileCreationInfo, int64_t /* avail_disk */> result) {
   if (!file_paging_enabled_)
     return;
 
-  if (result.error != File::FILE_OK) {
-    DisableFilePaging(result.error);
+  FileCreationInfo& file_info = std::get<0>(result);
+  int64_t avail_disk_space = std::get<1>(result);
+
+  if (file_info.error != File::FILE_OK) {
+    DisableFilePaging(file_info.error);
     return;
   }
 
+  if (avail_disk_space != kUnknownDiskAvailability) {
+    AdjustDiskUsage(static_cast<uint64_t>(avail_disk_space));
+  }
+
   DCHECK_LT(0, pending_evictions_);
   pending_evictions_--;
 
@@ -648,7 +882,7 @@
         new BlobDataItem(base::WrapUnique(new DataElement()), file_reference));
     new_item->data_element_ptr()->SetToFilePathRange(
         file_reference->path(), offset, shareable_item->item()->length(),
-        result.last_modified);
+        file_info.last_modified);
     DCHECK(shareable_item->memory_allocation_);
     shareable_item->set_memory_allocation(nullptr);
     shareable_item->set_item(new_item);
@@ -696,9 +930,9 @@
     total_disk_used +=
         pending_memory_quota_total_size_ - in_flight_memory_used_;
   }
-  if (limits_.max_blob_disk_space < total_disk_used)
+  if (limits_.effective_max_disk_space < total_disk_used)
     return 0;
-  return limits_.max_blob_disk_space - total_disk_used;
+  return limits_.effective_max_disk_space - total_disk_used;
 }
 
 void BlobMemoryController::GrantMemoryAllocations(
diff --git a/storage/browser/blob/blob_memory_controller.h b/storage/browser/blob/blob_memory_controller.h
index 6f9e15f..eb29518 100644
--- a/storage/browser/blob/blob_memory_controller.h
+++ b/storage/browser/blob/blob_memory_controller.h
@@ -16,7 +16,7 @@
 #include <utility>
 #include <vector>
 
-#include "base/callback.h"
+#include "base/callback_forward.h"
 #include "base/callback_helpers.h"
 #include "base/containers/mru_cache.h"
 #include "base/files/file.h"
@@ -33,6 +33,10 @@
 class TaskRunner;
 }
 
+namespace content {
+class ChromeBlobStorageContext;
+}
+
 namespace storage {
 class ShareableBlobDataItem;
 class ShareableFileReference;
@@ -156,20 +160,43 @@
   size_t memory_usage() const { return blob_memory_used_; }
   uint64_t disk_usage() const { return disk_used_; }
 
+  base::WeakPtr<BlobMemoryController> GetWeakPtr();
+
   const BlobStorageLimits& limits() const { return limits_; }
   void set_limits_for_testing(const BlobStorageLimits& limits) {
+    manual_limits_set_ = true;
     limits_ = limits;
   }
 
+  using DiskSpaceFuncPtr = int64_t (*)(const base::FilePath&);
+
+  void set_testing_disk_space(DiskSpaceFuncPtr disk_space_function) {
+    disk_space_function_ = disk_space_function;
+  }
+
  private:
   class FileQuotaAllocationTask;
   class MemoryQuotaAllocationTask;
 
+  // So this (and only this) class can call CalculateBlobStorageLimits().
+  friend class content::ChromeBlobStorageContext;
+
+  // Schedules a task on the file runner to calculate blob storage quota limits.
+  // This should only be called once per storage partition initialization as we
+  // emit UMA stats with that expectation.
+  void CalculateBlobStorageLimits();
+
   using PendingMemoryQuotaTaskList =
       std::list<std::unique_ptr<MemoryQuotaAllocationTask>>;
   using PendingFileQuotaTaskList =
       std::list<std::unique_ptr<FileQuotaAllocationTask>>;
 
+  void OnStorageLimitsCalculated(BlobStorageLimits limits);
+
+  // Adjusts the effective disk usage based on the available space. We try to
+  // keep at least BlobSorageLimits::min_available_disk_space() free.
+  void AdjustDiskUsage(uint64_t avail_disk_space);
+
   base::WeakPtr<QuotaAllocationTask> AppendMemoryTask(
       uint64_t total_bytes_needed,
       std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_memory_items,
@@ -189,7 +216,7 @@
       scoped_refptr<ShareableFileReference> file_reference,
       std::vector<scoped_refptr<ShareableBlobDataItem>> items,
       size_t total_items_size,
-      FileCreationInfo result);
+      std::pair<FileCreationInfo, int64_t /* disk_avail */> result);
 
   size_t GetAvailableMemoryForBlobs() const;
   uint64_t GetAvailableFileSpaceForBlobs() const;
@@ -209,6 +236,9 @@
   // changes.
   void RecordTracingCounters() const;
 
+  // Store that we set manual limits so we don't accidentally override them with
+  // our configuration task.
+  bool manual_limits_set_ = false;
   BlobStorageLimits limits_;
 
   // Memory bookkeeping. These numbers are all disjoint.
@@ -233,6 +263,8 @@
   bool file_paging_enabled_ = false;
   base::FilePath blob_storage_dir_;
   scoped_refptr<base::TaskRunner> file_runner_;
+  // This defaults to calling base::SysInfo::AmountOfFreeDiskSpace.
+  DiskSpaceFuncPtr disk_space_function_;
 
   // Lifetime of the ShareableBlobDataItem objects is handled externally in the
   // BlobStorageContext class.
diff --git a/storage/browser/blob/blob_storage_context.h b/storage/browser/blob/blob_storage_context.h
index 3dc5a03..35069692 100644
--- a/storage/browser/blob/blob_storage_context.h
+++ b/storage/browser/blob/blob_storage_context.h
@@ -31,6 +31,7 @@
 class BlobDispatcherHost;
 class BlobDispatcherHostTest;
 class BlobStorageBrowserTest;
+class ChromeBlobStorageContext;
 }
 
 namespace storage {
@@ -123,6 +124,7 @@
   friend class content::BlobDispatcherHost;
   friend class content::BlobDispatcherHostTest;
   friend class content::BlobStorageBrowserTest;
+  friend class content::ChromeBlobStorageContext;
   friend class BlobTransportHost;
   friend class BlobTransportHostTest;
   friend class BlobDataHandle;
diff --git a/storage/common/blob_storage/blob_storage_constants.cc b/storage/common/blob_storage/blob_storage_constants.cc
index 2d825f45..72411a7f 100644
--- a/storage/common/blob_storage/blob_storage_constants.cc
+++ b/storage/common/blob_storage/blob_storage_constants.cc
@@ -8,6 +8,20 @@
 
 namespace storage {
 
+static_assert(kDefaultIPCMemorySize < kDefaultSharedMemorySize,
+              "IPC transport size must be smaller than shared memory size.");
+static_assert(kDefaultMinPageFileSize < kDefaultMaxPageFileSize,
+              "Min page file size must be less than max.");
+static_assert(kDefaultMinPageFileSize < kDefaultMaxBlobInMemorySpace,
+              "Page file size must be less than in-memory space.");
+
+bool BlobStorageLimits::IsValid() const {
+  return max_ipc_memory_size < max_shared_memory_size &&
+         min_page_file_size < max_file_size &&
+         min_page_file_size < max_blob_in_memory_space &&
+         effective_max_disk_space <= desired_max_disk_space;
+}
+
 bool BlobStatusIsError(BlobStatus status) {
   return static_cast<int>(status) <= static_cast<int>(BlobStatus::LAST_ERROR);
 }
diff --git a/storage/common/blob_storage/blob_storage_constants.h b/storage/common/blob_storage/blob_storage_constants.h
index b94e886..a606397 100644
--- a/storage/common/blob_storage/blob_storage_constants.h
+++ b/storage/common/blob_storage/blob_storage_constants.h
@@ -13,29 +13,49 @@
 
 namespace storage {
 
+constexpr size_t kDefaultIPCMemorySize = 250u * 1024;
+constexpr size_t kDefaultSharedMemorySize = 10u * 1024 * 1024;
+constexpr size_t kDefaultMaxBlobInMemorySpace = 500u * 1024 * 1024;
+constexpr uint64_t kDefaultMaxBlobDiskSpace = 0ull;
+constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024;
+constexpr uint64_t kDefaultMaxPageFileSize = 100ull * 1024 * 1024;
+
 // All sizes are in bytes.
-struct BlobStorageLimits {
+struct STORAGE_COMMON_EXPORT BlobStorageLimits {
+  // Returns if the current configuration is valid.
+  bool IsValid() const;
+
   size_t memory_limit_before_paging() const {
     return max_blob_in_memory_space - min_page_file_size;
   }
 
+  // If disk space goes less than this we stop allocating more disk quota.
+  uint64_t min_available_external_disk_space() const {
+    return 2ull * memory_limit_before_paging();
+  }
+
+  bool IsDiskSpaceConstrained() const {
+    return desired_max_disk_space != effective_max_disk_space;
+  }
+
   // This is the maximum amount of memory we can send in an IPC.
-  size_t max_ipc_memory_size = 250 * 1024;
+  size_t max_ipc_memory_size = kDefaultIPCMemorySize;
   // This is the maximum size of a shared memory handle.
-  size_t max_shared_memory_size = 10 * 1024 * 1024;
+  size_t max_shared_memory_size = kDefaultSharedMemorySize;
 
   // This is the maximum amount of memory we can use to store blobs.
-  size_t max_blob_in_memory_space = 500 * 1024 * 1024;
+  size_t max_blob_in_memory_space = kDefaultMaxBlobInMemorySpace;
 
   // This is the maximum amount of disk space we can use.
-  // TODO(dmurph): Determine initial heuristic based on disk usage & arch.
-  uint64_t max_blob_disk_space = 0ull;
+  uint64_t desired_max_disk_space = kDefaultMaxBlobDiskSpace;
+  // This value will change based on the amount of free space on the device.
+  uint64_t effective_max_disk_space = kDefaultMaxBlobDiskSpace;
 
   // This is the minimum file size we can use when paging blob items to disk.
   // We combine items until we reach at least this size.
-  uint64_t min_page_file_size = 5 * 1024 * 1024;
+  uint64_t min_page_file_size = kDefaultMinPageFileSize;
   // This is the maximum file size we can create.
-  uint64_t max_file_size = 100 * 1024 * 1024;
+  uint64_t max_file_size = kDefaultMaxPageFileSize;
 };
 
 enum class IPCBlobItemRequestStrategy {
diff --git a/testing/android/native_test/main_runner.cc b/testing/android/native_test/main_runner.cc
index 629721f..2dc41f3 100644
--- a/testing/android/native_test/main_runner.cc
+++ b/testing/android/native_test/main_runner.cc
@@ -8,6 +8,7 @@
 #include "base/logging.h"
 #include "base/posix/global_descriptors.h"
 #include "jni/MainRunner_jni.h"
+#include "testing/android/native_test/native_test_util.h"
 
 extern int main(int argc, char** argv);
 
@@ -44,12 +45,9 @@
   std::vector<std::string> cpp_command_line;
   AppendJavaStringArrayToStringVector(env, command_line, &cpp_command_line);
 
-  std::vector<char*> c_command_line;
-  for (auto& entry : cpp_command_line) {
-    c_command_line.push_back(&entry[0]);
-  }
-
-  return main(c_command_line.size(), &c_command_line[0]);
+  std::vector<char*> argv;
+  int argc = ArgsToArgv(cpp_command_line, &argv);
+  return main(argc, &argv[0]);
 }
 
 }  // namespace android
diff --git a/testing/buildbot/chromium.android.json b/testing/buildbot/chromium.android.json
index 70f3e4a..9c4668e 100644
--- a/testing/buildbot/chromium.android.json
+++ b/testing/buildbot/chromium.android.json
@@ -2911,6 +2911,7 @@
           "chrome_public_test_apk"
         ],
         "override_isolate_target": "chrome_public_test_apk",
+        "render_results_dir": "chrome/test/data/android/render_tests",
         "swarming": {
           "can_use_on_swarming_builders": true,
           "cipd_packages": [
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json
index ab677514..734e3c0 100644
--- a/testing/buildbot/chromium.gpu.fyi.json
+++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -4652,6 +4652,32 @@
           "--show-stdout",
           "--browser=release",
           "-v",
+          "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle",
+          "--webgl-conformance-version=2.0.1",
+          "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl2_conformance_tests_output.json"
+        ],
+        "isolate_name": "telemetry_gpu_integration_test",
+        "name": "webgl2_conformance_angle_tests",
+        "override_compile_targets": [
+          "telemetry_gpu_integration_test_run"
+        ],
+        "swarming": {
+          "can_use_on_swarming_builders": true,
+          "dimension_sets": [
+            {
+              "gpu": "8086:1912",
+              "os": "Linux"
+            }
+          ],
+          "shards": 15
+        }
+      },
+      {
+        "args": [
+          "webgl_conformance",
+          "--show-stdout",
+          "--browser=release",
+          "-v",
           "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
           "--webgl-conformance-version=2.0.1",
           "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl2_conformance_tests_output.json"
diff --git a/testing/buildbot/chromium.perf.json b/testing/buildbot/chromium.perf.json
index 2cfec2b..a64266a6 100644
--- a/testing/buildbot/chromium.perf.json
+++ b/testing/buildbot/chromium.perf.json
@@ -3425,6 +3425,25 @@
         }
       },
       {
+        "args": [],
+        "isolate_name": "media_perftests",
+        "name": "media_perftests",
+        "swarming": {
+          "can_use_on_swarming_builders": true,
+          "dimension_sets": [
+            {
+              "gpu": "102b:0534",
+              "id": "build151-m1",
+              "os": "Ubuntu-14.04",
+              "pool": "Chrome-perf"
+            }
+          ],
+          "expiration": 21600,
+          "hard_timeout": 7200,
+          "io_timeout": 3600
+        }
+      },
+      {
         "args": [
           "memory.blink_memory_mobile",
           "-v",
diff --git a/testing/buildbot/gn_isolate_map.pyl b/testing/buildbot/gn_isolate_map.pyl
index 0f2d3c9f..de26dd5 100644
--- a/testing/buildbot/gn_isolate_map.pyl
+++ b/testing/buildbot/gn_isolate_map.pyl
@@ -844,6 +844,14 @@
       "cc_perftests",
     ],
   },
+  "media_perftests": {
+    "label": "//media:media_perftests",
+    "type": "script",
+    "script": "//testing/scripts/run_gtest_perf_test.py",
+    "args": [
+      "media_perftests",
+    ],
+  },
   "load_library_perf_tests": {
     "label": "//chrome/test:load_library_perf_tests",
     "type": "script",
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index fa4cf9c..7573a12 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -1707,6 +1707,37 @@
 crbug.com/490015 virtual/stable/http/tests/navigation/same-and-different-back.html [ Skip ]
 
 # ====== New tests from w3c-test-autoroller added here ======
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-002.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-020.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-020.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-004.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-008.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-008.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-002.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-006.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-004.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-016.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-020.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-006.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-013.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-008.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-020.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-002.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-005.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-008.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-004.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-016.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-005.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-004.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-001.xht [ Failure ]
+crbug.com/626703 [ Trusty Mac10.11 Mac10.10 Retina Win7 Win10 Mac10.9 ] imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-002.xht [ Failure ]
 crbug.com/626703 imported/wpt/web-animations/animation-model/animation-types/spacing-keyframes-transform.html [ Failure ]
 crbug.com/626703 imported/wpt/web-animations/animation-model/animation-types/interpolation-per-property.html [ Timeout ]
 crbug.com/626703 imported/wpt/web-animations/interfaces/KeyframeEffectReadOnly/copy-contructor.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/fast/css/invalidation/independent-inheritance-fast-path.html b/third_party/WebKit/LayoutTests/fast/css/invalidation/independent-inheritance-fast-path.html
index 0658d836b..8afe959 100644
--- a/third_party/WebKit/LayoutTests/fast/css/invalidation/independent-inheritance-fast-path.html
+++ b/third_party/WebKit/LayoutTests/fast/css/invalidation/independent-inheritance-fast-path.html
@@ -21,7 +21,6 @@
     ["listStylePosition", "outside", "inside"],
     ["webkitBoxDirection", "normal", "reverse"],
     ["webkitPrintColorAdjust", "economy", "exact"],
-    ["textAlign", "start", "left"],
     ["textTransform", "capitalize", "uppercase"],
     ["webkitRtlOrdering", "logical", "visual"],
 ];
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-019.html b/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-019.html
index 367539c..adb5d80 100644
--- a/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-019.html
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-019.html
@@ -5,7 +5,7 @@
 <link rel="help" href="http://www.w3.org/TR/css3-ui/#caret-color">
 <link rel="help" href="https://www.w3.org/TR/web-animations-1/#dom-animatable-animate">
 <link rel="help" href="https://www.w3.org/TR/css3-color/#color0">
-<meta name="assert" content="Test checks that 'auto' value for caret-color property is not interpolatible.">
+<meta name="assert" content="Test checks that 'auto' value for caret-color property is not interpolable.">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <style>
@@ -34,6 +34,6 @@
         player.pause();
         player.currentTime = 5;
         assert_equals(getComputedStyle(textarea).caretColor, 'rgb(0, 255, 0)');
-      }, "caret-color: auto is not interpolatible");
+      }, "caret-color: auto is not interpolable");
 </script>
 </body>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-020.html b/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-020.html
index 7f2f2f05..4e80c2f1 100644
--- a/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-020.html
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-020.html
@@ -5,7 +5,7 @@
 <link rel="help" href="http://www.w3.org/TR/css3-ui/#caret-color">
 <link rel="help" href="https://www.w3.org/TR/web-animations-1/#dom-animatable-animate">
 <link rel="help" href="https://www.w3.org/TR/css3-color/#color0">
-<meta name="assert" content="Test checks that 'currentcolor' value for caret-color property is interpolatible.">
+<meta name="assert" content="Test checks that 'currentcolor' value for caret-color property is interpolable.">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <style>
@@ -34,6 +34,6 @@
         player.pause();
         player.currentTime = 5;
         assert_equals(getComputedStyle(textarea).caretColor, 'rgb(128, 128, 128)');
-      }, "caret-color: currentcolor is interpolatible");
+      }, "caret-color: currentcolor is interpolable");
 </script>
 </body>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-021.html b/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-021.html
index 36d5cd4..176519bd 100644
--- a/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-021.html
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-ui-3/caret-color-021.html
@@ -27,7 +27,7 @@
       function(){
         var textarea = document.getElementById("textarea");
         assert_equals(getComputedStyle(textarea).caretColor, 'rgb(0, 255, 0)');
-      }, "Default caret-color is not interpolatible");
+      }, "Default caret-color is not interpolable");
 </script>
 </body>
 
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-001-expected.xht
new file mode 100644
index 0000000..da3bce8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-001-expected.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      width: calc(136px + 100vw + 136px);
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      padding: 0px 84px;
+      width: calc(136px + 100% + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-001.xht
new file mode 100644
index 0000000..1f2d1f1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-001.xht
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-003-expected.xht
new file mode 100644
index 0000000..479a5fb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-003-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: 0px;
+      padding: 0px 84px;
+      position: absolute;
+      width: calc(136px + 3px + 15ch + 3px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-003.xht
new file mode 100644
index 0000000..7e5b672
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-003.xht
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. In this test, the max-content will be less than the width of the initial containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-004-expected.xht
new file mode 100644
index 0000000..7bb0a06
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-004-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      width: calc(100px + 100vw + 100px);
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      margin: 0px 100px;
+      width: 100vw;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-004.xht
new file mode 100644
index 0000000..859d704
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-004.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-006-expected.xht
new file mode 100644
index 0000000..c4182d5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-006-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+      margin-left: 92px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-006.xht
new file mode 100644
index 0000000..dde973c5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-006.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. In this test, the max-content will be less than the width of the initial containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-007-expected.xht
new file mode 100644
index 0000000..1eb3567
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-007-expected.xht
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: 0px;
+      padding: 0px 84px;
+      position: absolute;
+      width: 672px;
+      /*
+      136px :
+    +
+      400px :
+    +
+      136px :
+   ===========
+      672px
+      */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-007.xht
new file mode 100644
index 0000000..d76033e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-007.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-008-expected.xht
new file mode 100644
index 0000000..596b09d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-008-expected.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: 0px;
+      padding: 0px 84px;
+      position: absolute;
+      width: calc(136px + 3px + 50ch + 3px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01020304050607080910111213141516171819202122232425</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-008.xht
new file mode 100644
index 0000000..70a66a4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-008.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, min-content inline size (50ch) is greater than the width (400px) of the containing block. Therefore, the inline size of the orthogonal block will be the min-content inline size." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-009-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-009-expected.xht
new file mode 100644
index 0000000..479a5fb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-009-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: 0px;
+      padding: 0px 84px;
+      position: absolute;
+      width: calc(136px + 3px + 15ch + 3px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-009.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-009.xht
new file mode 100644
index 0000000..1749520
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-009.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, the max-content will be less than the width of the containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-010-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-010-expected.xht
new file mode 100644
index 0000000..4c11ea2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-010-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+      margin-left: 92px;
+      width: 394px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-010.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-010.xht
new file mode 100644
index 0000000..716a81ae
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-010.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-010-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-011-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-011-expected.xht
new file mode 100644
index 0000000..6e6b8a2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-011-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+      margin-left: 92px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-011.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-011.xht
new file mode 100644
index 0000000..a7d0cef4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-011.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-011-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, we assume that the 50 characters long word is wider than the div#sized-400px-vlr-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-012-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-012-expected.xht
new file mode 100644
index 0000000..c4182d5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-012-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+      margin-left: 92px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-012.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-012.xht
new file mode 100644
index 0000000..d838466
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-012.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, the max-content will be less than the width of the containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-013-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-013-expected.xht
new file mode 100644
index 0000000..c0435589
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-013-expected.xht
@@ -0,0 +1,77 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      width: calc(52px + 100vw + 52px);
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      width: calc(52px + 100% + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-013.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-013.xht
new file mode 100644
index 0000000..645746c1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-013.xht
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-013-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-015-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-015-expected.xht
new file mode 100644
index 0000000..5f70b50
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-015-expected.xht
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      width: calc(52px + 3px + 15ch + 3px + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-015.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-015.xht
new file mode 100644
index 0000000..cab989a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-015.xht
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-015-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. In this test, the max-content will be less than the width of the initial containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-016-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-016-expected.xht
new file mode 100644
index 0000000..654cdf7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-016-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      box-sizing: border-box;
+      width: 100vw;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-016.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-016.xht
new file mode 100644
index 0000000..57059d2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-016.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-016-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 35px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-018-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-018-expected.xht
new file mode 100644
index 0000000..bb0aab0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-018-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-018.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-018.xht
new file mode 100644
index 0000000..8502cf0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-018.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. In this test, the max-content will be less than the width of the initial containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-019-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-019-expected.xht
new file mode 100644
index 0000000..92be04d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-019-expected.xht
@@ -0,0 +1,81 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      width: 504px;
+      /*
+       52px :
+    +
+      400px :
+    +
+       52px :
+   ============
+      504px
+      */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-019.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-019.xht
new file mode 100644
index 0000000..5490888
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-019.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-019-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-020-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-020-expected.xht
new file mode 100644
index 0000000..4dacaba
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-020-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      width: calc(52px + 3px + 50ch + 3px + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01020304050607080910111213141516171819202122232425</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-020.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-020.xht
new file mode 100644
index 0000000..d0fb09e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-020.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-020-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width (inline-size) of the containing block is definite in this test, then the constrain is the width (inline-size) of such containing block which is, in this test, 400px. But the min-content inline size of the orthogonal block is greater than the width (inline-size) of the containing block. Therefore, the min-content inline-size will become the width of the orthogonal block." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-021-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-021-expected.xht
new file mode 100644
index 0000000..5f70b50
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-021-expected.xht
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      width: calc(52px + 3px + 15ch + 3px + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-021.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-021.xht
new file mode 100644
index 0000000..ef18ccb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-021.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-015-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, the max-content will be less than the width of the containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-022-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-022-expected.xht
new file mode 100644
index 0000000..e825e0f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-022-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+      width: 394px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-022.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-022.xht
new file mode 100644
index 0000000..c9451682
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-022.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-022-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then the constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-023-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-023-expected.xht
new file mode 100644
index 0000000..079fd2b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-023-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-023.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-023.xht
new file mode 100644
index 0000000..21e84bdd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-023.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-023-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, we assume that the 50 characters long word is wider than the div#sized-400px-vlr-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-024-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-024-expected.xht
new file mode 100644
index 0000000..bb0aab0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-024-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: left;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-024.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-024.xht
new file mode 100644
index 0000000..125ce024
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vlr-024.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, the max-content will be less than the width of the containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vlr tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' its max-content inline-size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-001-expected.xht
new file mode 100644
index 0000000..c2a476e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-001-expected.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      width: calc(136px + 100vw + 136px);
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      padding: 0px 84px;
+      position: absolute;
+      width: calc(136px + 100% + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-001.xht
new file mode 100644
index 0000000..94f5128
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-001.xht
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-13T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  size (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-003-expected.xht
new file mode 100644
index 0000000..45e80937
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-003-expected.xht
@@ -0,0 +1,76 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 136px - 3px - 15ch - 3px - 136px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      padding: 0px 84px;
+      position: absolute;
+      width: calc(136px + 3px + 15ch + 3px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-003.xht
new file mode 100644
index 0000000..a59172d5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-003.xht
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. In this test, the max-content will be less than the width of the initial containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-004-expected.xht
new file mode 100644
index 0000000..7bb0a06
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-004-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      width: calc(100px + 100vw + 100px);
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      margin: 0px 100px;
+      width: 100vw;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-004.xht
new file mode 100644
index 0000000..9ac176a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-004.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-006-expected.xht
new file mode 100644
index 0000000..df84a84
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-006-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+      margin-right: 92px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-006.xht
new file mode 100644
index 0000000..c1e3f57c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-006.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. In this test, the max-content will be less than the width of the initial containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-007-expected.xht
new file mode 100644
index 0000000..1fdc3e0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-007-expected.xht
@@ -0,0 +1,84 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 136px - 400px - 136px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      padding: 0px 84px;
+      position: absolute;
+      width: 672px;
+      /*
+      136px :
+    +
+      400px :
+    +
+      136px :
+   ===========
+      672px
+      */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-007.xht
new file mode 100644
index 0000000..7bda42b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-007.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-008-expected.xht
new file mode 100644
index 0000000..80ebacd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-008-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 136px - 3px - 50ch - 3px - 136px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      padding: 0px 84px;
+      position: absolute;
+      width: calc(136px + 3px + 50ch + 3px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01020304050607080910111213141516171819202122232425</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-008.xht
new file mode 100644
index 0000000..75b59c3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-008.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, min-content inline size (50ch) is greater than the width (400px) of the containing block. Therefore, the inline size of the orthogonal block will be the min-content inline size." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-009-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-009-expected.xht
new file mode 100644
index 0000000..45e80937
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-009-expected.xht
@@ -0,0 +1,76 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 136px - 3px - 15ch - 3px - 136px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      padding: 0px 84px;
+      position: absolute;
+      width: calc(136px + 3px + 15ch + 3px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-009.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-009.xht
new file mode 100644
index 0000000..d262bb6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-009.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. In this test, the max-content inline size of the orthogonal block will be smaller than the width of its containing block. Therefore the inline size of div#ortho-block-htb will be its max-content inline-size." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-010-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-010-expected.xht
new file mode 100644
index 0000000..0539a533
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-010-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+      margin-right: 92px;
+      width: 394px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-010.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-010.xht
new file mode 100644
index 0000000..842ab97
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-010.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-010-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. Therefore, the outer edges of the inline-axis of the orthogonal block becomes '400px'." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-011-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-011-expected.xht
new file mode 100644
index 0000000..f65d70a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-011-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+      margin-right: 92px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-011.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-011.xht
new file mode 100644
index 0000000..c843969
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-011.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-011-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. But the min-content inline size of the orthogonal block is greater than '400px' and less than the width of the initial containing block. In such case, the inline-size content edges of the orthogonal block becomes its min-content. In this test, we assume that the 50 characters long word is wider than the div#sized-400px-vrl-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-012-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-012-expected.xht
new file mode 100644
index 0000000..df84a84
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-012-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+      margin-right: 92px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-012.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-012.xht
new file mode 100644
index 0000000..a218bdf6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-012.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. The max-content is narrower than the definite-sized width of the containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-013-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-013-expected.xht
new file mode 100644
index 0000000..3b1fef0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-013-expected.xht
@@ -0,0 +1,77 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      width: calc(52px + 100vw + 52px);
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      width: calc(52px + 100% + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-013.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-013.xht
new file mode 100644
index 0000000..1fb1eac
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-013.xht
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-013-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-015-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-015-expected.xht
new file mode 100644
index 0000000..6570a04
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-015-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 52px - 3px - 15ch - 3px - 52px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      position: absolute;
+      width: calc(52px + 3px + 15ch + 3px + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-015.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-015.xht
new file mode 100644
index 0000000..8c4193c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-015.xht
@@ -0,0 +1,109 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-015-ref.xht" />
+
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. But the max-content inline size of the orthogonal block is less than the width of the initial containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-016-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-016-expected.xht
new file mode 100644
index 0000000..654cdf7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-016-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      box-sizing: border-box;
+      width: 100vw;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-016.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-016.xht
new file mode 100644
index 0000000..20ec7730
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-016.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vlr-016-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 35px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-018-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-018-expected.xht
new file mode 100644
index 0000000..384ade6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-018-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-right: 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-018.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-018.xht
new file mode 100644
index 0000000..c0a77d88
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-018.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the width of the containing block is indefinite in this test, then constrain is the width of initial containing block which is, in this test, equal to the width of the viewport. In this test, the max-content inline size of the orthogonal block is less than the width of the initial containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-019-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-019-expected.xht
new file mode 100644
index 0000000..55d35cf
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-019-expected.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 52px - 400px - 52px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      position: absolute;
+      width: 504px; /* 52px + 400px + 52px == 504px */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-019.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-019.xht
new file mode 100644
index 0000000..6b168bf
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-019.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-019-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-020-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-020-expected.xht
new file mode 100644
index 0000000..465e662c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-020-expected.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 52px - 3px - 50ch - 3px - 52px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      position: absolute;
+      width: calc(52px + 3px + 50ch + 3px + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01020304050607080910111213141516171819202122232425</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-020.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-020.xht
new file mode 100644
index 0000000..5195dc9
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-020.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-020-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. min-content inline size is greater than 400px. Therefore, the inline size of the orthogonal block will be its min-content. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-021-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-021-expected.xht
new file mode 100644
index 0000000..6570a04
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-021-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 52px - 3px - 15ch - 3px - 52px);
+      /* or more elegantly right: 0px; Chrome 57+ has a bug here */
+      position: absolute;
+      width: calc(52px + 3px + 15ch + 3px + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+      width: 15ch;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">123456789012345</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-021.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-021.xht
new file mode 100644
index 0000000..5e8acd5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-021.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-015-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, the max-content will be less than the width of the containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-022-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-022-expected.xht
new file mode 100644
index 0000000..efd3036
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-022-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+      width: 394px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-022.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-022.xht
new file mode 100644
index 0000000..6c30cf7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-022.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-022-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-023-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-023-expected.xht
new file mode 100644
index 0000000..0d9bf32
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-023-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-023.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-023.xht
new file mode 100644
index 0000000..47ed5af4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-023.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-023-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, we assume that the 50 characters long word is wider than the div#sized-400px-vrl-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-024-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-024-expected.xht
new file mode 100644
index 0000000..384ade6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-024-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-30T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-right: 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      float: right;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-024.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-024.xht
new file mode 100644
index 0000000..7b06bd8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-htb-in-vrl-024.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with 'auto' inline size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-htb-in-vrl-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the width of the containing block is definite in this test, then constrain is the width of such containing block which is, in this test, 400px. This test presumes that the initial containing block's width is greater than 400px. In this test, the max-content will be less than the width of the containing block. Therefore the inline size of div#ortho-block-htb will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-htb-in-vrl tests:
+  001-012 : body has 100px margin-left and 100px margin-right
+  013-024 : body has no horizontal margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's width is 'auto' therefore indefinite
+  007-012: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's width is 'auto'
+  002: orthogonal block's width is 'auto' and its min-content
+  inline size (1 very long word) is wider than constraint
+  003: orthogonal block's width is 'auto' and its max-content inline size
+  is narrower than max(min-content, constraint)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: auto;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-001-expected.xht
new file mode 100644
index 0000000..03df218
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-001-expected.xht
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-27T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      padding: 0px 84px;
+      width: calc(136px + 35px + 50vw + 35px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 35px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-001.xht
new file mode 100644
index 0000000..a38a050
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-001.xht
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 35px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-002-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-002-expected.xht
new file mode 100644
index 0000000..8296ce8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-002-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-27T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      margin-left: 92px;
+      width: 50vw;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-002.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-002.xht
new file mode 100644
index 0000000..4bbc2ae
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-002.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-002-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-003-expected.xht
new file mode 100644
index 0000000..a87db28d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-003-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-27T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      padding: 0px 84px;
+      width: calc(136px + 3px + 200px + 3px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-003.xht
new file mode 100644
index 0000000..c4f3eb8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-003.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-004-expected.xht
new file mode 100644
index 0000000..510f498d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-004-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-27T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      margin: 0px 92px;
+      width: 200px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-004.xht
new file mode 100644
index 0000000..d599782
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-004.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-005-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-005-expected.xht
new file mode 100644
index 0000000..3c4412a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-005-expected.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-27T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      width: calc(52px + 35px + 50vw + 35px + 52px);
+      /*
+        52px : offsetWidth of sentence-before
+        35px : left border
+        50vw : content width of tested orthogonal block
+        35px : right border
+        52px : offsetWidth of sentence-after
+      */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 35px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-005.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-005.xht
new file mode 100644
index 0000000..b1bcced
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-005.xht
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-005-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 35px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-006-expected.xht
new file mode 100644
index 0000000..e205bbe
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-006-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      width: 50vw;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-006.xht
new file mode 100644
index 0000000..c938d1c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-006.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vlr-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-007-expected.xht
new file mode 100644
index 0000000..d92bc47
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-007-expected.xht
@@ -0,0 +1,84 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      width: 310px;
+      /*
+        52px :
+     +
+         3px :
+     +
+       200px :
+     +
+         3px :
+     +
+        52px :
+    ============
+       310px
+      */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-lr;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-007.xht
new file mode 100644
index 0000000..f8b7fa02
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-007.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-008-expected.xht
new file mode 100644
index 0000000..01d4241
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-008-expected.xht
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      width: 200px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-008.xht
new file mode 100644
index 0000000..3aa4989b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vlr-008.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-lr' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vlr-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vlr tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vlr-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vlr-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-001-expected.xht
new file mode 100644
index 0000000..77e59ad
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-001-expected.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      padding: 0px 84px;
+      left: calc(50% - 136px - 35px - 35px - 136px);
+      width: calc(136px + 35px + 50vw + 35px + 136px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 35px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-001.xht
new file mode 100644
index 0000000..d71830a8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-001.xht
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 35px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-002-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-002-expected.xht
new file mode 100644
index 0000000..8235ca7b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-002-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      position: absolute;
+      right: 100px;
+      width: 50vw;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-002.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-002.xht
new file mode 100644
index 0000000..1612a009
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-002.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-002-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-003-expected.xht
new file mode 100644
index 0000000..2c56c37
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-003-expected.xht
@@ -0,0 +1,87 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-27T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-04T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 478px);
+      padding: 0px 84px;
+      position: absolute;
+      width: 478px;
+      /*
+      136px :
+    +
+        3px :
+    +
+      200px :
+    +
+        3px :
+    +
+      136px :
+    ==========
+      478px
+      */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-003.xht
new file mode 100644
index 0000000..9071e72
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-003.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-19T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-004-expected.xht
new file mode 100644
index 0000000..4730eb7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-004-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-27T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      position: absolute;
+      right: 100px;
+      width: 200px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-004.xht
new file mode 100644
index 0000000..b3330f9
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-004.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 100px;
+      margin-right: 100px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-005-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-005-expected.xht
new file mode 100644
index 0000000..32e2c87
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-005-expected.xht
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      position: absolute;
+      right: 0px;
+      width: calc(52px + 35px + 50vw + 35px + 52px);
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 35px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-005.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-005.xht
new file mode 100644
index 0000000..aebb478
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-005.xht
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-005-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 35px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-006-expected.xht
new file mode 100644
index 0000000..075f8bd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-006-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      right: 0px;
+      position: absolute;
+      width: 50%;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-006.xht
new file mode 100644
index 0000000..7c9cd719
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-006.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside auto-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the width of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the width of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#auto-sized-vrl-containing-block
+    {
+      width: auto;
+      /*
+      'width: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-007-expected.xht
new file mode 100644
index 0000000..04351ff
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-007-expected.xht
@@ -0,0 +1,86 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin: 8px 0px;
+    }
+
+  table
+    {
+      border-spacing: 0px;
+      left: calc(100% - 310px);
+      position: absolute;
+      width: 310px;
+      /*
+         52px :
+      +
+          3px :
+      +
+        200px :
+      +
+          3px :
+      +
+         52px :
+     ===========
+        310px
+      */
+    }
+
+  td
+    {
+      padding: 0px;
+      vertical-align: top;
+    }
+
+  td#after, td#before
+    {
+      width: 52px;
+    }
+
+  p#sentence-after, p#sentence-before
+    {
+      writing-mode: vertical-rl;
+    }
+
+  td#data
+    {
+      border: blue solid 3px;
+      display: block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <table>
+
+    <tr>
+
+      <td id="after"><p id="sentence-after">Sentence&nbsp;after.</p></td>
+
+      <td id="data">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</td>
+
+      <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
+
+    </tr>
+
+  </table>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-007.xht
new file mode 100644
index 0000000..65b31212
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-007.xht
@@ -0,0 +1,80 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-008-expected.xht
new file mode 100644
index 0000000..22627bd1e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-008-expected.xht
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      position: absolute;
+      right: 0px;
+      width: 200px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-008.xht
new file mode 100644
index 0000000..5c8273f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-htb-in-vrl-008.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'horizontal-tb' block with percent inline-size inside definite-sized 'vertical-rl' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-htb-in-vrl-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the width of the containing block is definite, therefore 50% is applied on the width of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-htb-in-vrl tests:
+  001-004: body has 100px margin-left and 100px margin-right
+  005-008: body has no horizontal margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's width is 'auto' therefore indefinite
+  003-004: containing block's width is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-left: 0px;
+      margin-right: 0px;
+    }
+
+  div#sized-400px-vrl-containing-block
+    {
+      width: 400px;
+    }
+
+  div#ortho-block-htb
+    {
+      border: blue solid 3px;
+      width: 50%;
+      writing-mode: horizontal-tb;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-vrl-containing-block">
+
+    <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-001-expected.xht
new file mode 100644
index 0000000..cf5253a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-001-expected.xht
@@ -0,0 +1,76 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+      width: auto;
+    }
+
+  p#sentence-after
+    {
+      top: calc(100px - 16px + 52px + 35px + 50vh + 35px);
+      /*
+      50vh means 50 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 50vh == half of the height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+      padding-bottom: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-001.xht
new file mode 100644
index 0000000..c2c4ff78
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-001.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 35px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-002-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-002-expected.xht
new file mode 100644
index 0000000..022478df
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-002-expected.xht
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-002.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-002.xht
new file mode 100644
index 0000000..691d2917
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-002.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-002-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-003-expected.xht
new file mode 100644
index 0000000..6180852
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-003-expected.xht
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 222px; /* 600px - 342px - 36px == 222px */
+      top: 342px; /* 100px - 16px + 52px + 3px + 200px + 3px == 342px */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-003.xht
new file mode 100644
index 0000000..1d1983a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-003.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-004-expected.xht
new file mode 100644
index 0000000..bf1c5ee
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-004-expected.xht
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 400px;
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-004.xht
new file mode 100644
index 0000000..4e7ad2b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-004.xht
@@ -0,0 +1,70 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-005-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-005-expected.xht
new file mode 100644
index 0000000..12c1e08
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-005-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(52px + 35px + 50vh + 35px);
+      /*
+      50vh means 50 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 50vh == half of the height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-005.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-005.xht
new file mode 100644
index 0000000..ed626bf29
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-005.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-005-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 35px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-006-expected.xht
new file mode 100644
index 0000000..283e270
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-006-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-006.xht
new file mode 100644
index 0000000..0927638
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-006.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-007-expected.xht
new file mode 100644
index 0000000..5ed2748
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-007-expected.xht
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 122px;
+      top: 258px; /* 52px + 3px + 200px + 3px == 258px */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-007.xht
new file mode 100644
index 0000000..47316719
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-007.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-008-expected.xht
new file mode 100644
index 0000000..5c5fd41
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-008-expected.xht
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 400px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-008.xht
new file mode 100644
index 0000000..c3a2c4c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vlr-in-htb-008.xht
@@ -0,0 +1,70 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vlr-in-htb-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vlr-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-001-expected.xht
new file mode 100644
index 0000000..42525c2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-001-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(100px - 16px + 52px + 35px + 50vh + 35px);
+      /*
+      50vh means 50 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 50vh == half of the height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+      padding-bottom: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-001.xht
new file mode 100644
index 0000000..73e180b6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-001.xht
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 35px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-002-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-002-expected.xht
new file mode 100644
index 0000000..3ce9fbf
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-002-expected.xht
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-002.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-002.xht
new file mode 100644
index 0000000..8877e00b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-002.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-002-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-003-expected.xht
new file mode 100644
index 0000000..1d4635d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-003-expected.xht
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 222px; /* 600px - 342px - 36px == 222px */
+      top: 342px; /* 100px - 16px + 52px + 3px + 200px + 3px == 342px */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-003.xht
new file mode 100644
index 0000000..197c0c8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-003.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-004-expected.xht
new file mode 100644
index 0000000..03a2c2c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-004-expected.xht
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 400px;
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-004.xht
new file mode 100644
index 0000000..73d83d57
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-004.xht
@@ -0,0 +1,70 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-005-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-005-expected.xht
new file mode 100644
index 0000000..b61cef29
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-005-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(52px + 35px + 50vh + 35px);
+      /*
+      50vh means 50 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 50vh == half of the height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-005.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-005.xht
new file mode 100644
index 0000000..d49f9dcb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-005.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-005-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 35px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-006-expected.xht
new file mode 100644
index 0000000..371cae56c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-006-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 50%;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-006.xht
new file mode 100644
index 0000000..05e8343
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-006.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is '50%' and its containing block's block size is 'auto'. Since the height of the containing block is indefinite in this test, then the initial containing block's size is used as a fallback which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-007-expected.xht
new file mode 100644
index 0000000..3fddeb0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-007-expected.xht
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 122px;
+      top: 258px; /* 52px + 3px + 200px + 3px == 258px */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-007.xht
new file mode 100644
index 0000000..2589b77f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-007.xht
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-008-expected.xht
new file mode 100644
index 0000000..c6e20352
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-008-expected.xht
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-22T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 400px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 200px;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-008.xht
new file mode 100644
index 0000000..11c8d20
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-prct-vrl-in-htb-008.xht
@@ -0,0 +1,70 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with percent inline-size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-auto" title="7.3.1 Available Sizes in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-prct-vrl-in-htb-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the height of the containing block is definite, therefore 50% is applied on the height of such containing block which is, in this test, 400px." />
+
+  <!--
+
+  Inside this batch of 8 sizing-orthog-prct-vrl-in-htb tests:
+  001-004: body has 100px margin-bottom and 100px margin-top
+  005-008: body has no vertical margins
+
+  Inside each sub-batch of 4 tests:
+  001-002: containing block's height is 'auto' therefore indefinite
+  003-004: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 2 tests:
+  001: containing block has 1 sentence before and after
+  002: containing block has no sentence before and no sentence after
+
+  001 and 005 tests use a 35px thick border.
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: 50%;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-001-expected.xht
new file mode 100644
index 0000000..0b594e3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-001-expected.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 100%;
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      height: 100%;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 100px;
+      top: calc(100px - 16px + 52px + 100vh);
+      /*
+      100vh means 100 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 100vh == height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-001.xht
new file mode 100644
index 0000000..49cfa83
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-001.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-003-expected.xht
new file mode 100644
index 0000000..059af54
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-003-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(136px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+      padding-bottom: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-003.xht
new file mode 100644
index 0000000..357c5171
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-003.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-004-expected.xht
new file mode 100644
index 0000000..fed458c4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-004-expected.xht
@@ -0,0 +1,48 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 100%;
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      height: 100%;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-004.xht
new file mode 100644
index 0000000..318c97c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-004.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-006-expected.xht
new file mode 100644
index 0000000..cad74c8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-006-expected.xht
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-006.xht
new file mode 100644
index 0000000..366749f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-006.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-007-expected.xht
new file mode 100644
index 0000000..edcb185
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-007-expected.xht
@@ -0,0 +1,69 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 400px;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 28px; /* 600px - 536px -52px + 16px ==  28px */
+      top: 536px; /* 100px - 16px + 52px + 400px == 536px */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-007.xht
new file mode 100644
index 0000000..b52ae55
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-007.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-008-expected.xht
new file mode 100644
index 0000000..cf93c7c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-008-expected.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2016-12-29T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      left: 8px;
+      padding-bottom: 16px;
+      position: absolute;
+      top: calc(136px + 3px + 50ch + 3px);
+      /*
+      50ch means 50 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-008.xht
new file mode 100644
index 0000000..1faa3b88
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-008.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, min-content inline size is presumed to be greater than the height (400px) of the containing block. Therefore the content edges of the inline size of the orthogonal block will be its min-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-009-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-009-expected.xht
new file mode 100644
index 0000000..fdb1954
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-009-expected.xht
@@ -0,0 +1,97 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: calc(600px - 100px + 16px - 52px - 3px - 15ch - 3px - 52px + 16px);
+      /*
+      600px
+   -
+      100px
+   +
+       16px : margin collapsing of p#sentence-before's margin-top with body's margin-top
+   -
+       52px
+   -
+        3px
+   -
+       15ch
+   -
+        3px
+   -
+       52px
+   +
+       16px : margin collapsing of p#sentence-after's margin-bottom with body's margin-bottom
+  ============
+   approx. 270px
+      */
+
+      top: calc(136px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-009.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-009.xht
new file mode 100644
index 0000000..8f81bce
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-009.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-009-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content will be smaller than the height of the containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-010-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-010-expected.xht
new file mode 100644
index 0000000..e22e591
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-010-expected.xht
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 400px;
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 394px;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-010.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-010.xht
new file mode 100644
index 0000000..db786b2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-010.xht
@@ -0,0 +1,96 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-010-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-011-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-011-expected.xht
new file mode 100644
index 0000000..2a6720e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-011-expected.xht
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-011.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-011.xht
new file mode 100644
index 0000000..e973ee3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-011.xht
@@ -0,0 +1,96 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-011-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, we assume that the 50 characters long word is greater than the height of div#sized-400px-htb-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012 : body has 100px margin-top and 100px margin-bottom
+  013-024 : body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-012-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-012-expected.xht
new file mode 100644
index 0000000..6276e89
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-012-expected.xht
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 92px 0px;
+      height: 416px;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      display: inline-block;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-012.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-012.xht
new file mode 100644
index 0000000..e1eb5f8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-012.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-012-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-013-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-013-expected.xht
new file mode 100644
index 0000000..8f56415
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-013-expected.xht
@@ -0,0 +1,76 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 100%;
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      height: 100%;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 1em;
+      top: calc(52px + 100vh);
+      /*
+      100vh means 100 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 100vh == height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-013.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-013.xht
new file mode 100644
index 0000000..cd42dd68
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-013.xht
@@ -0,0 +1,103 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-013-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-015-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-015-expected.xht
new file mode 100644
index 0000000..b691d29
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-015-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(52px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-015.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-015.xht
new file mode 100644
index 0000000..9d9de14
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-015.xht
@@ -0,0 +1,103 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-015-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-016-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-016-expected.xht
new file mode 100644
index 0000000..206eb95
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-016-expected.xht
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-016.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-016.xht
new file mode 100644
index 0000000..e26e14dc
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-016.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-016-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 35px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-018-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-018-expected.xht
new file mode 100644
index 0000000..370a614
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-018-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-018.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-018.xht
new file mode 100644
index 0000000..51c0bdd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-018.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-019-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-019-expected.xht
new file mode 100644
index 0000000..e47426b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-019-expected.xht
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 394px;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      top: 452px; /* 52px + 400px == 452px */
+      padding-bottom: 1em;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-019.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-019.xht
new file mode 100644
index 0000000..86760b0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-019.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-019-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-020-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-020-expected.xht
new file mode 100644
index 0000000..b809bc77
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-020-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      left: 8px;
+      padding-bottom: 1em;
+      position: absolute;
+      top: calc(52px + 3px + 50ch + 3px);
+      /*
+      50ch means 50 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-020.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-020.xht
new file mode 100644
index 0000000..c70f103c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-020.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-020-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, min-content will be greater than the height of the containing block. Therefore, the inline size of the orthogonal block will be its min-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-021-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-021-expected.xht
new file mode 100644
index 0000000..b691d29
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-021-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(52px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-021.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-021.xht
new file mode 100644
index 0000000..1b3706066
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-021.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-015-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content of the orthogonal block will be less than the height of its definite containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-022-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-022-expected.xht
new file mode 100644
index 0000000..701cabf
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-022-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 394px;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-022.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-022.xht
new file mode 100644
index 0000000..bb1a9af
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-022.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-022-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-023-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-023-expected.xht
new file mode 100644
index 0000000..76e5ead
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-023-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-023.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-023.xht
new file mode 100644
index 0000000..9cfb956
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-023.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-023-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, we assume that the 50 characters long word is greater than the height of div#sized-400px-htb-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-024-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-024-expected.xht
new file mode 100644
index 0000000..370a614
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-024-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-lr;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-024.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-024.xht
new file mode 100644
index 0000000..156d9e6a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vlr-in-htb-024.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-lr' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vlr-in-htb-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content will be smaller than the height of the containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vlr-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' its max-content inline-size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vlr
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-lr;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vlr">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-001-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-001-expected.xht
new file mode 100644
index 0000000..d3f4041
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-001-expected.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 100%;
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      height: 100%;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 100px;
+      top: calc(100px - 16px + 52px + 100vh);
+      /*
+      100vh means 100 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 100vh == height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-001.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-001.xht
new file mode 100644
index 0000000..c19ab6c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-001.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-001-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-02T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-003-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-003-expected.xht
new file mode 100644
index 0000000..3e7b4fc3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-003-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 100px;
+      top: calc(136px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-003.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-003.xht
new file mode 100644
index 0000000..a6100201
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-003.xht
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-003-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-08T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-004-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-004-expected.xht
new file mode 100644
index 0000000..e73a8692
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-004-expected.xht
@@ -0,0 +1,48 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 100%;
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      height: 100%;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-004.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-004.xht
new file mode 100644
index 0000000..478a6a4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-004.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-004-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-006-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-006-expected.xht
new file mode 100644
index 0000000..8587fdb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-006-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-006.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-006.xht
new file mode 100644
index 0000000..80955af9
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-006.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-006-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-007-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-007-expected.xht
new file mode 100644
index 0000000..679b684
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-007-expected.xht
@@ -0,0 +1,69 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 400px;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 28px; /* 600px - 536px -52px + 16px ==  28px */
+      top: 536px; /* 100px - 16px + 52px + 400px == 536px */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-007.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-007.xht
new file mode 100644
index 0000000..fb3c91d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-007.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-007-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-008-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-008-expected.xht
new file mode 100644
index 0000000..9328c47b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-008-expected.xht
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 1em;
+      top: calc(136px + 3px + 50ch + 3px);
+      /*
+      50ch means 50 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-008.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-008.xht
new file mode 100644
index 0000000..e28ae4c8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-008.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-008-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, min-content inline size is presumed to be greater than the height (400px) of the containing block. Therefore the content edges of the inline size of the orthogonal block will be its min-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-009-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-009-expected.xht
new file mode 100644
index 0000000..0c74a8e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-009-expected.xht
@@ -0,0 +1,97 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 0px;
+      top: 100px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 136px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: calc(600px - 100px + 16px - 52px - 3px - 15ch - 3px - 52px + 16px);
+      /*
+      600px
+   -
+      100px
+   +
+       16px : margin collapsing of p#sentence-before's margin-top with body's margin-top
+   -
+       52px
+   -
+        3px
+   -
+       15ch
+   -
+        3px
+   -
+       52px
+   +
+       16px : margin collapsing of p#sentence-after's margin-bottom with body's margin-bottom
+  ============
+   approx. 270px
+      */
+
+      top: calc(136px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-009.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-009.xht
new file mode 100644
index 0000000..399ce8f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-009.xht
@@ -0,0 +1,100 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-009-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content will be smaller than the height of the containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-010-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-010-expected.xht
new file mode 100644
index 0000000..cf87d6a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-010-expected.xht
@@ -0,0 +1,47 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 400px;
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 400px;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-010.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-010.xht
new file mode 100644
index 0000000..5b0f4fa
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-010.xht
@@ -0,0 +1,96 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-010-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-011-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-011-expected.xht
new file mode 100644
index 0000000..b7454cc
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-011-expected.xht
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      padding: 100px 0px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-011.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-011.xht
new file mode 100644
index 0000000..fa2ee6b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-011.xht
@@ -0,0 +1,96 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-011-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, we assume that the 50 characters long word is greater than the height of div#sized-400px-htb-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+      /* Nota bene: margin-top of p#sentence-before will collapse with body's margin-top */
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-012-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-012-expected.xht
new file mode 100644
index 0000000..882a82d0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-012-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-10-04T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 600px;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      left: 8px;
+      position: absolute;
+      top: 100px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-012.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-012.xht
new file mode 100644
index 0000000..1504ed97
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-012.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-012-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-15T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-08T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 100px;
+      margin-top: 100px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-013-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-013-expected.xht
new file mode 100644
index 0000000..f274aafa
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-013-expected.xht
@@ -0,0 +1,76 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      height: 100%;
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      height: 100%;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 1em;
+      top: calc(52px + 100vh);
+      /*
+      100vh means 100 vh unit where each vh is equal to
+      1% of the height of the initial containing block.
+      So 100vh == height of initial containing block
+      5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units
+      https://www.w3.org/TR/css3-values/#vh
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-013.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-013.xht
new file mode 100644
index 0000000..4ccc0d0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-013.xht
@@ -0,0 +1,103 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-013-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-015-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-015-expected.xht
new file mode 100644
index 0000000..93f8b02
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-015-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(52px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-015.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-015.xht
new file mode 100644
index 0000000..4b88733
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-015.xht
@@ -0,0 +1,103 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-015-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-016-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-016-expected.xht
new file mode 100644
index 0000000..38d4cee
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-016-expected.xht
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div
+    {
+      border: blue solid 35px;
+      box-sizing: border-box;
+      height: 100%;
+      left: 8px;
+      position: absolute;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-016.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-016.xht
new file mode 100644
index 0000000..bbe2cdb2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-016.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-016-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 35px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-018-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-018-expected.xht
new file mode 100644
index 0000000..2c5b8401
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-018-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-018.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-018.xht
new file mode 100644
index 0000000..ab341935
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-018.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside auto-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is also 'auto'. Since the height of the containing block is indefinite in this test, then constrain is the height of initial containing block which is, in this test, equal to the height of the viewport. In this test, the max-content will be smaller than the height of the initial containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#auto-sized-htb-containing-block
+    {
+      height: auto;
+      /*
+      'height: auto' causes the measurement of the orthogonal
+      box's containing block to be indefinite
+      */
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="auto-sized-htb-containing-block">
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-019-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-019-expected.xht
new file mode 100644
index 0000000..64b2d2c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-019-expected.xht
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 394px;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 1em;
+      top: 452px;
+      /*
+        52px :
+     +
+         3px :
+     +
+       394px :
+     +
+         3px :
+    ============
+       452px
+      */
+    }
+
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-019.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-019.xht
new file mode 100644
index 0000000..e4cebf2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-019.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-019-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-020-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-020-expected.xht
new file mode 100644
index 0000000..3119e85b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-020-expected.xht
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      padding-bottom: 1em;
+      top: calc(52px + 3px + 50ch + 3px);
+      /*
+      50ch means 50 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-020.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-020.xht
new file mode 100644
index 0000000..8cb55fef
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-020.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-020-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-285T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, min-content will be greater than the height of the containing block. Therefore, the inline size of the orthogonal block will be its min-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">01020304050607080910111213141516171819202122232425</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-021-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-021-expected.xht
new file mode 100644
index 0000000..93f8b02
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-021-expected.xht
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  p
+    {
+      left: 8px;
+      position: absolute;
+      writing-mode: horizontal-tb;
+    }
+
+  p#sentence-before
+    {
+      margin-top: 8px;
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 52px;
+    }
+
+  p#sentence-after
+    {
+      top: calc(52px + 3px + 15ch + 3px);
+      /*
+      15ch means 15 ch unit where each ch is equal to
+      the used advance measure of the "0" (ZERO, U+0030) glyph found
+      in the font used to render it.
+      5.1.1. Font-relative lengths: the em, ex, ch, rem units
+      https://www.w3.org/TR/css3-values/#ch
+      */
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <p id="sentence-before">Sentence before.</p>
+
+  <div>123456789012345</div>
+
+  <p id="sentence-after">Sentence after.</p>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-021.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-021.xht
new file mode 100644
index 0000000..44e085a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-021.xht
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-015-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content of the orthogonal block will be less than the height of its definite containing block. Therefore the inline size of div#ortho-block-vlr will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <p id="sentence-before">Sentence before.</p>
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+    <p id="sentence-after">Sentence after.</p>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-022-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-022-expected.xht
new file mode 100644
index 0000000..1e906f61
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-022-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: 394px;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-022.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-022.xht
new file mode 100644
index 0000000..a47986da
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-022.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-022-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-023-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-023-expected.xht
new file mode 100644
index 0000000..391ddb69
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-023-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>01020304050607080910111213141516171819202122232425</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-023.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-023.xht
new file mode 100644
index 0000000..fbc6dea
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-023.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-023-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, we assume that the 50 characters long word is greater than the height of div#sized-400px-htb-containing-block. Therefore, min-content is greater than constraint." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">01020304050607080910111213141516171819202122232425</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-024-expected.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-024-expected.xht
new file mode 100644
index 0000000..2c5b8401
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-024-expected.xht
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Reftest Reference</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+
+  <meta name="DC.date.created" content="2016-12-20T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta content="" name="flags" />
+
+  <style type="text/css"><![CDATA[
+  html
+    {
+      writing-mode: vertical-rl;
+    }
+
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+    }
+
+  div
+    {
+      border: blue solid 3px;
+      height: auto;
+      left: 8px;
+      position: absolute;
+      top: 0px;
+    }
+  ]]></style>
+ </head>
+
+ <body>
+
+  <div>123456789012345</div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-024.xht b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-024.xht
new file mode 100644
index 0000000..c4c0b03
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/csswg-test/css-writing-modes-3/sizing-orthog-vrl-in-htb-024.xht
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+
+  <title>CSS Writing Modes Test: sizing of orthogonal 'vertical-rl' block with 'auto' inline size inside definite-sized 'horizontal-tb' containing block</title>
+
+  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
+  <link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#auto-multicol" title="7.3.2. Auto-sizing Block Containers in Orthogonal Flows" />
+  <link rel="match" href="sizing-orthog-vrl-in-htb-018-ref.xht" />
+
+  <meta name="DC.date.created" content="2016-09-28T09:54:03+11:00" scheme="W3CDTF" />
+  <meta name="DC.date.modified" content="2017-01-03T09:54:03+11:00" scheme="W3CDTF" />
+
+  <meta name="flags" content="" />
+  <meta name="assert" content="In this test, the inline size of the orthogonal block is 'auto' and its containing block's block size is '400px'. Since the height of the containing block is definite in this test, then constrain is the height of such containing block which is, in this test, 400px. This test presumes that the initial containing block's height is greater than 400px. In this test, the max-content will be smaller than the height of the containing block. Therefore the inline size of div#ortho-block-vrl will be its max-content." />
+
+  <!--
+
+  shrink-to-fit formula is: min(max-content, max(min-content, constraint))
+
+  max-content inline size: narrowest inline size needed to fit its contents
+  if none of the soft wrap opportunities within the box were taken. Eg:
+  max-content of "I am a text sentence." is "I&nbsp;am&nbsp;a&nbsp;text&nbsp;sentence."
+  https://www.w3.org/TR/css-sizing-3/#max-content-inline-size
+
+  min-content inline size of the box: longest word in a sentence or longest non-breakable
+  inline box (inline replaced or inline-block). Eg: min-content of "I am a text sentence."
+  is "sentence."
+  https://www.w3.org/TR/css-sizing-3/#min-content-inline-size
+
+  contraint: min(available space, initial containing block's size)
+
+  available space: this is either a measurement of its containing block
+  (if that is definite) or an infinite size (when it is indefinite).
+  https://drafts.csswg.org/css-sizing-4/#available
+
+  - - - - - - - - - - - - -
+
+  Inside this batch of 24 sizing-orthog-vrl-in-htb tests:
+  001-012: body has 100px margin-top and 100px margin-bottom
+  013-024: body has no vertical margins
+
+  Inside each sub-batch of 12 tests:
+  001-006: containing block's height is 'auto' therefore indefinite
+  007-012: containing block's height is 400px therefore definite
+
+  Inside each sub-sub-batch of 6 tests:
+  001-003: containing block has 1 sentence before and after
+  004-006: containing block has no sentence before and no sentence after
+
+  Inside each sub-sub-sub-batch of 3 tests:
+  001: orthogonal block's height is 'auto'
+  002: orthogonal block's height is 'auto' and its min-content
+  inline size is greater than containing-block's (definite) height (1 very long word)
+  003: orthogonal block's height is 'auto' and its max-content inline size
+  is smaller than containing-block's height (short sentence)
+
+  -->
+
+  <style type="text/css"><![CDATA[
+  body
+    {
+      font-size: 16px;
+      line-height: 1.25; /* therefore, each line box is 20px tall */
+      margin-bottom: 0px;
+      margin-top: 0px;
+    }
+
+  div#sized-400px-htb-containing-block
+    {
+      height: 400px;
+    }
+
+  div#ortho-block-vrl
+    {
+      border: blue solid 3px;
+      height: auto;
+      writing-mode: vertical-rl;
+    }
+  ]]></style>
+
+ </head>
+
+ <body>
+
+  <div id="sized-400px-htb-containing-block">
+
+    <div id="ortho-block-vrl">123456789012345</div>
+
+  </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html
index 25a7cc93..c667fada 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html
@@ -17,53 +17,40 @@
             // as long as the associated MediaKeys object is around.
 
             // For this test, create a MediaKeySession and verify lifetime.
-            async_test(function(test)
+            promise_test(function(test)
             {
-                gc();
                 var initDataType;
                 var initData;
                 var mediaKeys;
-                var startingMediaKeysCount = window.internals.mediaKeysCount();
-                var startingMediaKeySessionCount = window.internals.mediaKeySessionCount();
 
-                function numMediaKeysCreated()
-                {
-                    return window.internals.mediaKeysCount() - startingMediaKeysCount;
-                }
+                // Even though there should be no existing objects, start by
+                // running gc() and verifying that none exist. This also
+                // allows the failures to be reported from inside a promise
+                // so that the test fails properly.
+                return createGCPromise().then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After initial gc()');
 
-                function numMediaKeySessionCreated()
-                {
-                    return window.internals.mediaKeySessionCount() - startingMediaKeySessionCount;
-                }
-
-                // Create a MediaKeys object with a session.
-                navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
+                    // Create a MediaKeys object with a session.
+                    return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration());
+                }).then(function(access) {
                     initDataType = access.getConfiguration().initDataTypes[0];
                     initData = getInitData(initDataType);
                     return access.createMediaKeys();
                 }).then(function(result) {
                     mediaKeys = result;
-
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.create()');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'After final gc()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'MediaKeys.create()');
 
                     var mediaKeySession = mediaKeys.createSession();
                     return mediaKeySession.generateRequest(initDataType, initData);
                 }).then(function() {
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession()');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 1, 'MediaKeys.createSession()');
 
                     // Run gc(), should not affect MediaKeys object nor the
                     // session since we still have a reference to it.
-
-                    // When enabling oilpan GC, the in-active
-                    // ScriptPromiseResolvers will be destroyed.
                     return createGCPromise();
                 }).then(function(result) {
                     assert_equals(typeof mediaKeys.createSession, 'function');
-
-                    assert_equals(numMediaKeysCreated(), 1, 'After gc()');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'After gc()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 1, 'After gc()');
 
                     // Drop reference to the MediaKeys object and run gc()
                     // again. Object should be collected this time. Since
@@ -78,12 +65,7 @@
                 }).then(function(result) {
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 0, 'After final gc()');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'After final gc()');
-
-                    test.done();
-                }).catch(function(error) {
-                    forceTestFailureFromPromise(test, error);
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After final gc()');
                 });
             }, 'MediaKeys lifetime with session');
         </script>
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html
index b1235fb9..7e86dc5f 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html
@@ -13,71 +13,57 @@
             //   OR (MediaKeys is around
             //       AND the session has not received a close() event)
 
-            async_test(function(test)
+            promise_test(function(test)
             {
-                gc();
                 var mediaKeys;
                 var mediaKeySession1;
                 var mediaKeySession2;
                 var mediaKeySession3;
                 var initDataType;
                 var initData;
-                var startingMediaKeysCount = window.internals.mediaKeysCount();
-                var startingMediaKeySessionCount = window.internals.mediaKeySessionCount();
 
-                function numMediaKeysCreated()
-                {
-                    return window.internals.mediaKeysCount() - startingMediaKeysCount;
-                }
+                // Even though there should be no existing objects, start by
+                // running gc() and verifying that none exist. This also
+                // allows the failures to be reported from inside a promise
+                // so that the test fails properly.
+                return createGCPromise().then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After initial gc()');
 
-                function numMediaKeySessionCreated()
-                {
-                    return window.internals.mediaKeySessionCount() - startingMediaKeySessionCount;
-                }
-
-                navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
+                    return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration());
+                }).then(function(access) {
                     initDataType = access.getConfiguration().initDataTypes[0];
                     initData = getInitData(initDataType);
                     return access.createMediaKeys();
                 }).then(function(result) {
                     mediaKeys = result;
                     assert_equals(typeof mediaKeys.createSession, 'function');
-
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.create()');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'After final gc()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'MediaKeys.create()');
 
                     // Create 3 sessions.
                     mediaKeySession1 = mediaKeys.createSession();
                     return mediaKeySession1.generateRequest(initDataType, initData);
                 }).then(function() {
                     assert_true(mediaKeySession1.sessionId && mediaKeySession1.sessionId.length > 0);
-
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession(1)');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession(1)');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 1, 'MediaKeys.createSession(1)');
 
                     mediaKeySession2 = mediaKeys.createSession();
                     return mediaKeySession2.generateRequest(initDataType, initData);
                 }).then(function() {
                     assert_true(mediaKeySession2.sessionId && mediaKeySession2.sessionId.length > 0);
-
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSession(2)');
-                    assert_equals(numMediaKeySessionCreated(), 2, 'mediaKeys.createSession(2)');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 2, 'mediaKeys.createSession(2)');
 
                     mediaKeySession3 = mediaKeys.createSession();
                     return mediaKeySession3.generateRequest(initDataType, initData);
                 }).then(function() {
                     assert_true(mediaKeySession3.sessionId && mediaKeySession3.sessionId.length > 0);
-
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSession(3)');
-                    assert_equals(numMediaKeySessionCreated(), 3, 'mediaKeys.createSession(3)');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 3, 'mediaKeys.createSession(3)');
 
                     // Run gc(). All sessions should remain as we have a
                     // reference to each one. However, running gc()
                     // asynchronously should free up the last PromiseResolver.
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 1, 'After gc()');
-                    assert_equals(numMediaKeySessionCreated(), 3, 'After gc()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 3, 'After gc()');
 
                     // Now drop references to 2 of the sessions. Even though we
                     // don't have a reference, MediaKeys is still around (and
@@ -89,8 +75,7 @@
                 }).then(function(result) {
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 1, 'After second gc()');
-                    assert_equals(numMediaKeySessionCreated(), 3, 'After second gc()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 3, 'After second gc()');
 
                     // Now drop the reference to MediaKeys. It and the 2
                     // unreferenced sessions should be collected. Since
@@ -105,20 +90,14 @@
                 }).then(function(result) {
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 0, 'After mediaKeys = null');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'After mediaKeys = null');
+                    verifyMediaKeyAndMediaKeySessionCount(0, 1, 'After mediaKeys = null');
 
                     // Drop the reference to the last session. It should get
                     // collected now since MediaKeys is gone.
                     mediaKeySession3 = null;
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 0, 'After final gc()');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'After final gc()');
-
-                    test.done();
-                }).catch(function(error) {
-                    forceTestFailureFromPromise(test, error);
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After final gc()');
                 });
             }, 'MediaKeySession lifetime without release()');
         </script>
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html
index 60019a1..a66800a 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html
@@ -12,61 +12,49 @@
             //   JavaScript has a reference to it
             //   OR (MediaKeys is around
             //       AND the session has not received a close() event)
-            async_test(function(test)
+            promise_test(function(test)
             {
-                gc();
                 var initDataType;
                 var initData;
-                var startingMediaKeysCount = window.internals.mediaKeysCount();
-                var startingMediaKeySessionCount = window.internals.mediaKeySessionCount();
-
-                function numMediaKeysCreated()
-                {
-                    return window.internals.mediaKeysCount() - startingMediaKeysCount;
-                }
-
-                function numMediaKeySessionCreated()
-                {
-                    return window.internals.mediaKeySessionCount() - startingMediaKeySessionCount;
-                }
 
                 // Create 2 sessions.
                 var mediaKeys;
                 var mediaKeySession1;
                 var mediaKeySession2;
 
-                navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
+                // Even though there should be no existing objects, start by
+                // running gc() and verifying that none exist. This also
+                // allows the failures to be reported from inside a promise
+                // so that the test fails properly.
+                return createGCPromise().then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After initial gc()');
+
+                    return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration());
+                }).then(function(access) {
                     initDataType = access.getConfiguration().initDataTypes[0];
                     initData = getInitData(initDataType);
                     return access.createMediaKeys();
                 }).then(function(result) {
                     mediaKeys = result;
-
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.create()');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'MediaKeys.create()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'MediaKeys.create()');
 
                     mediaKeySession1 = mediaKeys.createSession();
                     return mediaKeySession1.generateRequest(initDataType, initData);
                 }).then(function() {
                     assert_true(mediaKeySession1.sessionId && mediaKeySession1.sessionId.length > 0);
-
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession(1)');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession(1)');
+                    verifyMediaKeyAndMediaKeySessionCount(1,  1, 'MediaKeys.createSession(1)');
 
                     mediaKeySession2 = mediaKeys.createSession();
                     return mediaKeySession2.generateRequest(initDataType, initData);
                 }).then(function() {
                     assert_true(mediaKeySession2.sessionId && mediaKeySession2.sessionId.length > 0);
+                    verifyMediaKeyAndMediaKeySessionCount(1, 2, 'mediaKeys.createSession(2)');
 
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSession(2)');
-                    assert_equals(numMediaKeySessionCreated(), 2, 'mediaKeys.createSession(2)');
-                }).then(function(result) {
                     // Run gc(). All sessions should remain as we have a
                     // reference to each one.
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 1, 'After gc()');
-                    assert_equals(numMediaKeySessionCreated(), 2, 'After gc()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 2, 'After gc()');
 
                     // Close the sessions. Once the close() event is received,
                     // they should get garbage collected as there are no JS
@@ -81,8 +69,7 @@
                 }).then(function(result) {
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession1 not collected');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'mediaKeySession1 not collected');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 1, 'mediaKeySession1 not collected');
 
                     var promise = mediaKeySession2.close();
                     mediaKeySession2 = null;
@@ -94,13 +81,8 @@
                 }).then(function(result) {
                     return createGCPromise();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession2 not collected');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'mediaKeySession2 not collected');
-
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'mediaKeySession2 not collected');
                     assert_not_equals(mediaKeys, null);
-                    test.done();
-                }).catch(function(error) {
-                    forceTestFailureFromPromise(test, error);
                 });
             }, 'MediaKeySession lifetime after release() without references');
         </script>
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html
index 39d3db1e..689aec5 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html
@@ -12,49 +12,40 @@
             //   JavaScript has a reference to it
             //   OR (MediaKeys is around
             //       AND the session has not received a close() event)
-            async_test(function(test)
+            promise_test(function(test)
             {
-                gc();
                 var mediaKeys;
                 var mediaKeySession1;
                 var mediaKeySession2;
                 var initDataType;
                 var initData;
-                var startingMediaKeysCount = window.internals.mediaKeysCount();
-                var startingMediaKeySessionCount = window.internals.mediaKeySessionCount();
-
-                function numMediaKeysCreated()
-                {
-                    return window.internals.mediaKeysCount() - startingMediaKeysCount;
-                }
-
-                function numMediaKeySessionCreated()
-                {
-                    return window.internals.mediaKeySessionCount() - startingMediaKeySessionCount;
-                }
 
                 // Create 2 sessions.
-                navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
+                // Even though there should be no existing objects, start by
+                // running gc() and verifying that none exist. This also
+                // allows the failures to be reported from inside a promise
+                // so that the test fails properly.
+                return createGCPromise().then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After initial gc()');
+
+                    return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration());
+                }).then(function(access) {
                     initDataType = access.getConfiguration().initDataTypes[0];
                     initData = getInitData(initDataType);
                     return access.createMediaKeys();
                 }).then(function(result) {
                     mediaKeys = result;
-
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.create()');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'MediaKeys.create()');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'MediaKeys.create()');
 
                     mediaKeySession1 = mediaKeys.createSession();
                     return mediaKeySession1.generateRequest(initDataType, initData);
                 }).then(function() {
-                    assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession(1)');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession(1)');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 1, 'MediaKeys.createSession(1)');
 
                     mediaKeySession2 = mediaKeys.createSession();
                     return mediaKeySession2.generateRequest(initDataType, initData);
                 }).then(function() {
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSession(2)');
-                    assert_equals(numMediaKeySessionCreated(), 2, 'mediaKeys.createSession(2)');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 2, 'mediaKeys.createSession(2)');
 
                     // Close the sessions. Once completed, only the JS
                     // reference to them keeps them around.
@@ -65,23 +56,17 @@
                     // Since both sessions have been closed, dropping the
                     // reference to them from JS will result in the session
                     // being garbage-collected.
-                    assert_equals(numMediaKeysCreated(), 1, 'after close');
-                    assert_equals(numMediaKeySessionCreated(), 2, 'after close');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 2, 'after close');
 
                     mediaKeySession1 = null;
                     return createGCPromise();
                 }).then(function() {
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession1 not collected');
-                    assert_equals(numMediaKeySessionCreated(), 1, 'mediaKeySession1 not collected');
+                    verifyMediaKeyAndMediaKeySessionCount(1, 1, 'mediaKeySession1 not collected');
 
                     mediaKeySession2 = null;
                     return createGCPromise();
                 }).then(function() {
-                    assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession2 not collected');
-                    assert_equals(numMediaKeySessionCreated(), 0, 'mediaKeySession2 not collected');
-                    test.done();
-                }).catch(function(error) {
-                    forceTestFailureFromPromise(test, error);
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'mediaKeySession2 not collected');
                 });
             }, 'MediaKeySession lifetime after release()');
         </script>
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-multiple-mediakeys.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-multiple-mediakeys.html
index 2ccba75e..dc65e58 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-multiple-mediakeys.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-multiple-mediakeys.html
@@ -9,16 +9,13 @@
     <body>
         <script>
             // For this test, create several MediaKeys and verify lifetime.
-            async_test(function(test)
+            promise_test(function(test)
             {
-                gc();
-                var mediaKeys;
-                var startingMediaKeysCount = window.internals.mediaKeysCount();
-
-                function numMediaKeysCreated()
-                {
-                    return window.internals.mediaKeysCount() - startingMediaKeysCount;
-                }
+                var mediaKeys1;
+                var mediaKeys2;
+                var mediaKeys3;
+                var mediaKeys4;
+                var mediaKeys5;
 
                 // Create a MediaKeys object. Returns a promise that resolves
                 // with the new MediaKeys object.
@@ -26,60 +23,79 @@
                 {
                     return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
                         return access.createMediaKeys();
-                    }).then(function(mediaKeys) {
-                        return mediaKeys;
                     });
                 }
 
-                // Create a few MediaKeys objects. Only keep a reference to the
-                // last one created.
-                createMediaKeys().then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 1);
+                // Create a few MediaKeys objects. Keep references to them,
+                // to avoid issues if gc() runs.
+                // Even though there should be no existing objects, start by
+                // running gc() and verifying that none exist. This also
+                // allows the failures to be reported from inside a promise
+                // so that the test fails properly.
+                return createGCPromise().then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After initial gc()');
 
                     return createMediaKeys();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 2);
+                    assert_not_equals(result, null);
+                    mediaKeys1 = result;
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'Create first MediaKeys');
 
                     return createMediaKeys();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 3);
+                    assert_not_equals(result, null);
+                    mediaKeys2 = result;
+                    verifyMediaKeyAndMediaKeySessionCount(2, 0, 'Create second MediaKeys');
 
                     return createMediaKeys();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 4);
+                    assert_not_equals(result, null);
+                    mediaKeys3 = result;
+                    verifyMediaKeyAndMediaKeySessionCount(3, 0, 'Create third MediaKeys');
 
                     return createMediaKeys();
                 }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 5);
+                    assert_not_equals(result, null);
+                    mediaKeys4 = result;
+                    verifyMediaKeyAndMediaKeySessionCount(4, 0, 'Create fourth MediaKeys');
 
-                    // |mediaKeys| refers to the most recently created MediaKeys
-                    // object.
-                    mediaKeys = result;
+                    return createMediaKeys();
+                }).then(function(result) {
+                    assert_not_equals(result, null);
+                    mediaKeys5 = result;
+                    verifyMediaKeyAndMediaKeySessionCount(5, 0, 'Create fifth MediaKeys');
 
                     // In order for the MediaKey objects to be garbage
                     // collected, it needs time to process any pending events.
                     return delayToAllowEventProcessingPromise();
-                }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 5);
+                }).then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(5, 0, 'All alive');
 
-                    // As we only have a reference (|mediaKeys|) to the last
-                    // created MediaKeys object, the other 4 MediaKeys objects
-                    // are available to be garbage collected.
+                    // Now run garbage collection. Since we have references to
+                    // all 5 MediaKeys, none will be collected.
                     return createGCPromise();
-                }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 1);
-                    assert_equals(typeof mediaKeys.createSession, 'function');
+                }).then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(5, 0, 'All still alive');
+
+                    // Drop references to 4 of the MediaKeys. As we will only
+                    // have a reference to the last created MediaKeys object,
+                    // the other 4 MediaKeys objects are available to be
+                    // garbage collected.
+                    mediaKeys1 = null;
+                    mediaKeys2 = null;
+                    mediaKeys3 = null;
+                    mediaKeys4 = null;
+                    return createGCPromise();
+                }).then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(1, 0, 'Only 1 left');
 
                     // Release the last MediaKeys object created.
-                    mediaKeys = null;
+                    mediaKeys5 = null;
 
                     // Run gc() again to reclaim the remaining MediaKeys object.
                     return createGCPromise();
-                }).then(function(result) {
-                    assert_equals(numMediaKeysCreated(), 0);
-                    test.done();
-                }).catch(function(error) {
-                    forceTestFailureFromPromise(test, error);
+                }).then(function() {
+                    verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After final gc()');
                 });
             }, 'Multiple MediaKeys lifetime');
         </script>
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js
index 3c8cbf9..7da4129 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js
@@ -329,3 +329,16 @@
         });
     });
 }
+
+// Verifies that the number of existing MediaKey and MediaKeySession objects
+// match what is expected.
+function verifyMediaKeyAndMediaKeySessionCount(
+    expectedMediaKeysCount, expectedMediaKeySessionCount, description)
+{
+    assert_equals(window.internals.mediaKeysCount(),
+                  expectedMediaKeysCount,
+                  description + ', MediaKeys:');
+    assert_equals(window.internals.mediaKeySessionCount(),
+                  expectedMediaKeySessionCount,
+                  description + ', MediaKeySession:');
+}
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/left-top-right-bottom-expected.txt b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/left-top-right-bottom-expected.txt
deleted file mode 100644
index 7837ef88..0000000
--- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/left-top-right-bottom-expected.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-This is a testharness.js-based test.
-PASS Setting left, top, right, bottom works with a SimpleLength 
-PASS Setting left, top, right, bottom works with a Simple percentage 
-PASS Setting left, top, right, bottom works with a CalcLength 
-PASS Getting left works with a SimpleLength 
-PASS Getting top works with a SimpleLength 
-PASS Getting right works with a SimpleLength 
-PASS Getting bottom works with a SimpleLength 
-PASS Getting left works with a simple percent 
-PASS Getting top works with a simple percent 
-PASS Getting right works with a simple percent 
-PASS Getting bottom works with a simple percent 
-FAIL Getting left works with a simple percent assert_equals: expected function "function CSSCalcLength() { [native code] }" but got function "function CSSStyleValue() { [native code] }"
-FAIL Getting top works with a simple percent assert_equals: expected function "function CSSCalcLength() { [native code] }" but got function "function CSSStyleValue() { [native code] }"
-FAIL Getting right works with a simple percent assert_equals: expected function "function CSSSimpleLength() { [native code] }" but got function "function CSSStyleValue() { [native code] }"
-FAIL Getting bottom works with a simple percent assert_equals: expected function "function CSSSimpleLength() { [native code] }" but got function "function CSSStyleValue() { [native code] }"
-Harness: the test ran to completion.
-
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/left-top-right-bottom.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/left-top-right-bottom.html
deleted file mode 100644
index f0e30f98..0000000
--- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/left-top-right-bottom.html
+++ /dev/null
@@ -1,161 +0,0 @@
-<!DOCTYPE html>
-<script src="../../resources/testharness.js"></script>
-<script src="../../resources/testharnessreport.js"></script>
-
-<div id="testElement"></div>
-
-<script>
-
-var styleMap = testElement.styleMap;
-
-test(function() {
-  testElement.style = "";
-
-  styleMap.set('left', new CSSSimpleLength(10, 'px'));
-  styleMap.set('top', new CSSSimpleLength(20, 'px'));
-  styleMap.set('right', new CSSSimpleLength(30, 'px'));
-  styleMap.set('bottom', new CSSSimpleLength(40, 'px'));
-
-  assert_equals(testElement.style.left, '10px');
-  assert_equals(testElement.style.top, '20px');
-  assert_equals(testElement.style.right, '30px');
-  assert_equals(testElement.style.bottom, '40px');
-}, "Setting left, top, right, bottom works with a SimpleLength");
-
-test(function() {
-  testElement.style = "";
-
-  styleMap.set('left', new CSSSimpleLength(10, 'percent'));
-  styleMap.set('top', new CSSSimpleLength(20, 'percent'));
-  styleMap.set('right', new CSSSimpleLength(30, 'percent'));
-  styleMap.set('bottom', new CSSSimpleLength(40, 'percent'));
-
-  assert_equals(testElement.style.left, '10%');
-  assert_equals(testElement.style.top, '20%');
-  assert_equals(testElement.style.right, '30%');
-  assert_equals(testElement.style.bottom, '40%');
-}, "Setting left, top, right, bottom works with a Simple percentage");
-
-test(function() {
-  testElement.style = "";
-
-  styleMap.set('left', new CSSCalcLength({pt: 50, percent: 30}));
-  styleMap.set('top', new CSSCalcLength({percent: 10, em: 4}));
-  styleMap.set('right', new CSSCalcLength({px: 500, percent: 30}));
-  styleMap.set('bottom', new CSSCalcLength({vmin: 0.5, percent: 10}));
-
-  assert_equals(testElement.style.left, 'calc(30% + 50pt)');
-  assert_equals(testElement.style.top, 'calc(10% + 4em)');
-  assert_equals(testElement.style.right, 'calc(30% + 500px)');
-  assert_equals(testElement.style.bottom, 'calc(10% + 0.5vmin)');
-}, "Setting left, top, right, bottom works with a CalcLength");
-
-test(function() {
-  testElement.style = "left:50vmax;";
-
-  var left = styleMap.get('left');
-  assert_equals(left.constructor, CSSSimpleLength);
-  assert_equals(left.value, 50);
-  assert_equals(left.type, 'vmax');
-}, "Getting left works with a SimpleLength");
-
-test(function() {
-  testElement.style = "top:60px;";
-
-  var top = styleMap.get('top');
-  assert_equals(top.constructor, CSSSimpleLength);
-  assert_equals(top.value, 60);
-  assert_equals(top.type, 'px');
-}, "Getting top works with a SimpleLength");
-
-test(function() {
-  testElement.style = "right:70pc;";
-
-  var right = styleMap.get('right');
-  assert_equals(right.constructor, CSSSimpleLength);
-  assert_equals(right.value, 70);
-  assert_equals(right.type, 'pc');
-}, "Getting right works with a SimpleLength");
-
-test(function() {
-  testElement.style = "bottom:80rem;";
-
-  var bottom = styleMap.get('bottom');
-  assert_equals(bottom.constructor, CSSSimpleLength);
-  assert_equals(bottom.value, 80);
-  assert_equals(bottom.type, 'rem');
-}, "Getting bottom works with a SimpleLength");
-
-test(function() {
-  testElement.style = "left:50%;";
-
-  var left = styleMap.get('left');
-  assert_equals(left.constructor, CSSSimpleLength);
-  assert_equals(left.value, 50);
-  assert_equals(left.type, 'percent');
-}, "Getting left works with a simple percent");
-
-test(function() {
-  testElement.style = "top:60%;";
-
-  var top = styleMap.get('top');
-  assert_equals(top.constructor, CSSSimpleLength);
-  assert_equals(top.value, 60);
-  assert_equals(top.type, 'percent');
-}, "Getting top works with a simple percent");
-
-test(function() {
-  testElement.style = "right:70%;";
-
-  var right = styleMap.get('right');
-  assert_equals(right.constructor, CSSSimpleLength);
-  assert_equals(right.value, 70);
-  assert_equals(right.type, 'percent');
-}, "Getting right works with a simple percent");
-
-test(function() {
-  testElement.style = "bottom:80%;";
-
-  var bottom = styleMap.get('bottom');
-  assert_equals(bottom.constructor, CSSSimpleLength);
-  assert_equals(bottom.value, 80);
-  assert_equals(bottom.type, 'percent');
-}, "Getting bottom works with a simple percent");
-
-test(function() {
-  testElement.style = "left:calc(60% + 20px);";
-
-  var left = styleMap.get('left');
-  assert_equals(left.constructor, CSSCalcLength);
-  assert_equals(left.percent, 60);
-  assert_equals(left.px, 20);
-}, "Getting left works with a simple percent");
-
-test(function() {
-  testElement.style = "top:calc(70% - 50px);";
-
-  var top = styleMap.get('top');
-  assert_equals(top.constructor, CSSCalcLength);
-  assert_equals(top.percent, 70);
-  assert_equals(top.px, -50);
-}, "Getting top works with a simple percent");
-
-test(function() {
-  testElement.style = "right:calc(80% + 20em);";
-
-  var right = styleMap.get('right');
-  assert_equals(right.constructor, CSSSimpleLength);
-  assert_equals(right.percent, 80);
-  assert_equals(right.em, 20);
-}, "Getting right works with a simple percent");
-
-test(function() {
-  testElement.style = "bottom:calc(80% - 30rem);";
-
-  var bottom = styleMap.get('bottom');
-  assert_equals(bottom.constructor, CSSSimpleLength);
-  assert_equals(bottom.value, 80);
-  assert_equals(bottom.rem, -30);
-}, "Getting bottom works with a simple percent");
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/properties/bottom-expected.txt b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/properties/bottom-expected.txt
deleted file mode 100644
index 8ca5f42..0000000
--- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/properties/bottom-expected.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-This is a testharness.js-based test.
-PASS Setting bottom to auto 
-PASS Setting bottom to initial 
-PASS Setting bottom to inherit 
-PASS Setting bottom to unset 
-PASS Setting bottom to CSSSimpleLength with value 1px 
-PASS Setting bottom to CSSSimpleLength with value 2% 
-PASS Setting bottom to CSSSimpleLength with value 3em 
-PASS Setting bottom to CSSCalcLength with value calc(10% + 1px) 
-PASS Setting bottom to invalid value CSSNumberValue throws 
-PASS Setting bottom to invalid value null throws 
-PASS Setting bottom to invalid value undefined throws 
-PASS Setting bottom to invalid value true throws 
-PASS Setting bottom to invalid value false throws 
-PASS Setting bottom to invalid value 1 throws 
-PASS Setting bottom to invalid value hello throws 
-PASS Setting bottom to invalid value [object Object] throws 
-PASS Setting bottom to invalid value CSSKeywordValue throws 
-PASS Getting bottom when it is set to auto 
-PASS Getting bottom when it is set to initial 
-PASS Getting bottom when it is set to inherit 
-PASS Getting bottom when it is set to unset 
-PASS Getting bottom with a CSSSimpleLength whose value is 1px 
-PASS Getting bottom with a CSSSimpleLength whose value is 2% 
-PASS Getting bottom with a CSSSimpleLength whose value is 3em 
-FAIL Getting bottom with a CSSCalcLength whose value is calc(10% + 1px) assert_equals: typeof result expected "CSSCalcLength" but got "CSSStyleValue"
-PASS getAll for single-valued bottom 
-PASS Delete bottom removes the value from the styleMap 
-PASS bottom shows up in getProperties 
-PASS Setting bottom to a sequence throws 
-PASS Appending to bottom throws 
-Harness: the test ran to completion.
-
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/properties/bottom.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/properties/bottom.html
index b6886b1aa..4669161c 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/properties/bottom.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/properties/bottom.html
@@ -16,8 +16,50 @@
     new CSSSimpleLength(1, 'px'),
     new CSSSimpleLength(2, 'percent'),
     new CSSSimpleLength(3, 'em'),
-    new CSSCalcLength({px: 1, percent: 10}),
+    new CSSSimpleLength(4, 'ex'),
+    new CSSSimpleLength(5, 'ch'),
+    new CSSSimpleLength(6, 'rem'),
+    new CSSSimpleLength(7, 'vw'),
+    new CSSSimpleLength(8, 'vh'),
+    new CSSSimpleLength(9, 'vmin'),
+    new CSSSimpleLength(10, 'vmax'),
+    new CSSSimpleLength(11, 'cm'),
+    new CSSSimpleLength(12, 'mm'),
+    new CSSSimpleLength(13, 'in'),
+    new CSSSimpleLength(14, 'pc'),
+    new CSSSimpleLength(15, 'pt'),
+    // Fully populated calc
+    new CSSCalcLength({
+      px: 1.2,
+      percent: -2.3,
+      em: 4.5,
+      ex: -6.7,
+      ch: 8.9,
+      rem: -10,
+      vw: 1.1,
+      vh: -1.2,
+      vmin: 1.3,
+      vmax: -1.4,
+      cm: 1.56,
+      mm: -1.7,
+      in: 1.8,
+      pc: -1.9,
+      pt: 2.1}),
+    // Contains only px
+    new CSSCalcLength({px: 10}),
+    // Contains only percent
+    new CSSCalcLength({percent: 10}),
+    // Contains px and percent
+    new CSSCalcLength({px: 6, percent: 10}),
+    // Contains neither pixels or percent
+    new CSSCalcLength({vmin: 5, in: 10}),
   ],
+  validStringMappings: {
+    // Contains multiplication
+    'calc(3 * (5px - 2%))': new CSSCalcLength({px: 15, percent: -6}),
+    // Contains division
+    'calc((5vmin + 1mm) / 2)': new CSSCalcLength({vmin: 2.5, mm: 0.5}),
+  },
   supportsMultiple: false,
   invalidObjects: [new CSSNumberValue(1)]
 });
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/width-height-expected.txt b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/width-height-expected.txt
deleted file mode 100644
index 2543f4c3..0000000
--- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/width-height-expected.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-This is a testharness.js-based test.
-PASS Setting width, height works with a SimpleLength. 
-PASS Setting width, height works with a Simple percentage. 
-PASS Setting width, height works with a CalcLength containing a percentage. 
-PASS Getting width works with a SimpleLength. 
-PASS Getting width works with a simple percentage. 
-FAIL Getting width works with a CalcLength. assert_equals: expected function "function CSSCalcLength() { [native code] }" but got function "function CSSStyleValue() { [native code] }"
-PASS Getting height works with a SimpleLength. 
-PASS Getting height works with a simple percentage. 
-FAIL Getting height works with a CalcLength. assert_equals: expected function "function CSSCalcLength() { [native code] }" but got function "function CSSStyleValue() { [native code] }"
-Harness: the test ran to completion.
-
diff --git a/third_party/WebKit/Source/bindings/bindings.gni b/third_party/WebKit/Source/bindings/bindings.gni
index 0b930966..e95f9b0 100644
--- a/third_party/WebKit/Source/bindings/bindings.gni
+++ b/third_party/WebKit/Source/bindings/bindings.gni
@@ -92,6 +92,8 @@
                     "core/v8/ScriptEventListener.h",
                     "core/v8/ScriptFunction.cpp",
                     "core/v8/ScriptFunction.h",
+                    "core/v8/ScriptModule.cpp",
+                    "core/v8/ScriptModule.h",
                     "core/v8/ScriptPromise.cpp",
                     "core/v8/ScriptPromise.h",
                     "core/v8/ScriptPromiseProperties.h",
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp
new file mode 100644
index 0000000..3642e50
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "bindings/core/v8/ScriptModule.h"
+
+#include "bindings/core/v8/V8Binding.h"
+
+namespace blink {
+
+ScriptModule::ScriptModule(v8::Isolate* isolate, v8::Local<v8::Module> module)
+    : m_module(SharedPersistent<v8::Module>::create(module, isolate)) {}
+
+ScriptModule::~ScriptModule() {}
+
+ScriptModule ScriptModule::compile(v8::Isolate* isolate,
+                                   const String& source,
+                                   const String& fileName) {
+  v8::TryCatch tryCatch(isolate);
+  tryCatch.SetVerbose(true);
+  v8::Local<v8::Module> module;
+  if (!v8Call(V8ScriptRunner::compileModule(isolate, source, fileName), module,
+              tryCatch)) {
+    // TODO(adamk): Signal failure somehow.
+    return ScriptModule(isolate, module);
+  }
+  return ScriptModule(isolate, module);
+}
+
+v8::MaybeLocal<v8::Module> dummyCallback(v8::Local<v8::Context> context,
+                                         v8::Local<v8::String> specifier,
+                                         v8::Local<v8::Module> referrer) {
+  return v8::MaybeLocal<v8::Module>();
+}
+
+bool ScriptModule::instantiate(ScriptState* scriptState) {
+  DCHECK(!isNull());
+  v8::Local<v8::Context> context = scriptState->context();
+  // TODO(adamk): pass in a real callback.
+  return m_module->newLocal(scriptState->isolate())
+      ->Instantiate(context, &dummyCallback);
+}
+
+void ScriptModule::evaluate(ScriptState* scriptState) {
+  v8::Isolate* isolate = scriptState->isolate();
+  v8::TryCatch tryCatch(isolate);
+  tryCatch.SetVerbose(true);
+  v8::Local<v8::Value> result;
+  if (!v8Call(V8ScriptRunner::evaluateModule(m_module->newLocal(isolate),
+                                             scriptState->context(), isolate),
+              result, tryCatch)) {
+    // TODO(adamk): report error
+  }
+}
+
+}  // namespace blink
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h
new file mode 100644
index 0000000..951117d6
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h
@@ -0,0 +1,41 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ScriptModule_h
+#define ScriptModule_h
+
+#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/SharedPersistent.h"
+#include "core/CoreExport.h"
+#include "wtf/Allocator.h"
+#include "wtf/text/WTFString.h"
+#include <v8.h>
+
+namespace blink {
+
+class CORE_EXPORT ScriptModule final {
+  DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
+
+ public:
+  static ScriptModule compile(v8::Isolate*,
+                              const String& source,
+                              const String& fileName);
+
+  ScriptModule(const ScriptModule& module) : m_module(module.m_module) {}
+  ~ScriptModule();
+
+  bool instantiate(ScriptState*);
+  void evaluate(ScriptState*);
+
+  bool isNull() const { return m_module->isEmpty(); }
+
+ private:
+  ScriptModule(v8::Isolate*, v8::Local<v8::Module>);
+
+  RefPtr<SharedPersistent<v8::Module>> m_module;
+};
+
+}  // namespace blink
+
+#endif  // ScriptModule_h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
index 9e618c7..288b523 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
@@ -493,6 +493,18 @@
   return (*compileFn)(isolate, code, origin);
 }
 
+v8::MaybeLocal<v8::Module> V8ScriptRunner::compileModule(
+    v8::Isolate* isolate,
+    const String& source,
+    const String& fileName) {
+  TRACE_EVENT1("v8", "v8.compileModule", "fileName", fileName.utf8());
+  // TODO(adamk): Add Inspector integration?
+  // TODO(adamk): Pass more info into ScriptOrigin.
+  v8::ScriptOrigin origin(v8String(isolate, fileName));
+  v8::ScriptCompiler::Source scriptSource(v8String(isolate, source), origin);
+  return v8::ScriptCompiler::CompileModule(isolate, &scriptSource);
+}
+
 v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledScript(
     v8::Isolate* isolate,
     v8::Local<v8::Script> script,
@@ -660,6 +672,16 @@
   return result;
 }
 
+v8::MaybeLocal<v8::Value> V8ScriptRunner::evaluateModule(
+    v8::Local<v8::Module> module,
+    v8::Local<v8::Context> context,
+    v8::Isolate* isolate) {
+  TRACE_EVENT0("v8", "v8.evaluateModule");
+  v8::MicrotasksScope microtasksScope(isolate,
+                                      v8::MicrotasksScope::kRunMicrotasks);
+  return module->Evaluate(context);
+}
+
 v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObject(
     v8::Isolate* isolate,
     v8::Local<v8::ObjectTemplate> objectTemplate) {
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h
index 6dfbb3a0..b2e697a 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h
@@ -81,6 +81,9 @@
       CachedMetadataHandler* = nullptr,
       AccessControlStatus = SharableCrossOrigin,
       V8CacheOptions = V8CacheOptionsDefault);
+  static v8::MaybeLocal<v8::Module> compileModule(v8::Isolate*,
+                                                  const String& source,
+                                                  const String& fileName);
   static v8::MaybeLocal<v8::Value> runCompiledScript(v8::Isolate*,
                                                      v8::Local<v8::Script>,
                                                      ExecutionContext*);
@@ -110,6 +113,9 @@
                                                 int argc,
                                                 v8::Local<v8::Value> info[],
                                                 v8::Isolate*);
+  static v8::MaybeLocal<v8::Value> evaluateModule(v8::Local<v8::Module>,
+                                                  v8::Local<v8::Context>,
+                                                  v8::Isolate*);
   static v8::MaybeLocal<v8::Object> instantiateObject(
       v8::Isolate*,
       v8::Local<v8::ObjectTemplate>);
diff --git a/third_party/WebKit/Source/core/css/CSSCalculationValue.cpp b/third_party/WebKit/Source/core/css/CSSCalculationValue.cpp
index fc1115d..b1be505 100644
--- a/third_party/WebKit/Source/core/css/CSSCalculationValue.cpp
+++ b/third_party/WebKit/Source/core/css/CSSCalculationValue.cpp
@@ -255,6 +255,20 @@
   CSSPrimitiveValue::UnitType typeWithCalcResolved() const override {
     return m_value->typeWithCalcResolved();
   }
+  const CSSCalcExpressionNode* leftExpressionNode() const {
+    NOTREACHED();
+    return nullptr;
+  }
+
+  const CSSCalcExpressionNode* rightExpressionNode() const {
+    NOTREACHED();
+    return nullptr;
+  }
+
+  CalcOperator operatorType() const {
+    NOTREACHED();
+    return CalcAdd;
+  }
 
   DEFINE_INLINE_VIRTUAL_TRACE() {
     visitor->trace(m_value);
@@ -554,6 +568,13 @@
   }
 
   Type getType() const override { return CssCalcBinaryOperation; }
+  const CSSCalcExpressionNode* leftExpressionNode() const { return m_leftSide; }
+
+  const CSSCalcExpressionNode* rightExpressionNode() const {
+    return m_rightSide;
+  }
+
+  CalcOperator operatorType() const { return m_operator; }
 
   CSSPrimitiveValue::UnitType typeWithCalcResolved() const override {
     switch (m_category) {
diff --git a/third_party/WebKit/Source/core/css/CSSCalculationValue.h b/third_party/WebKit/Source/core/css/CSSCalculationValue.h
index 9fccae6..086aba2 100644
--- a/third_party/WebKit/Source/core/css/CSSCalculationValue.h
+++ b/third_party/WebKit/Source/core/css/CSSCalculationValue.h
@@ -82,6 +82,9 @@
     return m_category == other.m_category && m_isInteger == other.m_isInteger;
   }
   virtual Type getType() const = 0;
+  virtual const CSSCalcExpressionNode* leftExpressionNode() const = 0;
+  virtual const CSSCalcExpressionNode* rightExpressionNode() const = 0;
+  virtual CalcOperator operatorType() const = 0;
 
   CalculationCategory category() const { return m_category; }
   virtual CSSPrimitiveValue::UnitType typeWithCalcResolved() const = 0;
diff --git a/third_party/WebKit/Source/core/css/CSSProperties.in b/third_party/WebKit/Source/core/css/CSSProperties.in
index e67c54f..0c04f86 100644
--- a/third_party/WebKit/Source/core/css/CSSProperties.in
+++ b/third_party/WebKit/Source/core/css/CSSProperties.in
@@ -368,7 +368,7 @@
 stroke-width interpolable, inherited, svg, converter=convertUnzoomedLength
 table-layout
 tab-size inherited, converter=convertLengthOrTabSpaces, type_name=TabSize
-text-align inherited, independent, custom_value, keyword_only, keywords=[left|right|center|justify|webkitLeft|webkitRight|webkitCenter|start|end], initial_keyword=start
+text-align inherited, custom_value, keyword_only, keywords=[left|right|center|justify|webkitLeft|webkitRight|webkitCenter|start|end], initial_keyword=start
 text-align-last inherited, type_name=TextAlignLast
 text-anchor inherited, svg
 text-combine-upright inherited, type_name=TextCombine, name_for_methods=TextCombine
@@ -393,7 +393,7 @@
 translate runtime_flag=CSSIndependentTransformProperties, converter=convertTranslate, interpolable, api_class
 rotate runtime_flag=CSSIndependentTransformProperties, converter=convertRotate, interpolable
 scale runtime_flag=CSSIndependentTransformProperties, converter=convertScale, interpolable
-unicode-bidi type_name=UnicodeBidi
+unicode-bidi type_name=UnicodeBidi, keyword_only, keywords=[normal|embed|bidi-override|isolate|plaintext|isolate-override], initial_keyword=normal, field_storage_type=platform/text/UnicodeBidi
 vector-effect svg
 vertical-align interpolable, custom_inherit, custom_value
 visibility interpolable, inherited, independent, keyword_only, keywords=[visible|hidden|collapse], initial_keyword=visible
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp b/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp
index c574e216..9ba993e 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp
@@ -16,6 +16,7 @@
 namespace {
 
 static CSSPrimitiveValue::UnitType unitFromIndex(int index) {
+  DCHECK(index < CSSLengthValue::kNumSupportedUnits);
   int lowestValue = static_cast<int>(CSSPrimitiveValue::UnitType::Percentage);
   return static_cast<CSSPrimitiveValue::UnitType>(index + lowestValue);
 }
@@ -141,7 +142,66 @@
 std::unique_ptr<CSSCalcLength::UnitData>
 CSSCalcLength::UnitData::fromExpressionNode(
     const CSSCalcExpressionNode* expressionNode) {
-  return nullptr;
+  CalculationCategory category = expressionNode->category();
+  DCHECK(category == CalculationCategory::CalcLength ||
+         category == CalculationCategory::CalcPercentLength ||
+         category == CalculationCategory::CalcPercent);
+
+  if (expressionNode->getType() ==
+      CSSCalcExpressionNode::Type::CssCalcPrimitiveValue) {
+    CSSPrimitiveValue::UnitType unit = expressionNode->typeWithCalcResolved();
+    DCHECK(CSSLengthValue::isSupportedLengthUnit(unit));
+    std::unique_ptr<UnitData> result(new UnitData());
+    result->set(unit, expressionNode->doubleValue());
+    return result;
+  }
+
+  const CSSCalcExpressionNode* left = expressionNode->leftExpressionNode();
+  const CSSCalcExpressionNode* right = expressionNode->rightExpressionNode();
+  CalcOperator op = expressionNode->operatorType();
+
+  if (op == CalcMultiply) {
+    std::unique_ptr<UnitData> unitData = nullptr;
+    double argument = 0;
+    // One side should be a number.
+    if (left->category() == CalculationCategory::CalcNumber) {
+      unitData = UnitData::fromExpressionNode(right);
+      argument = left->doubleValue();
+    } else if (right->category() == CalculationCategory::CalcNumber) {
+      unitData = UnitData::fromExpressionNode(left);
+      argument = right->doubleValue();
+    } else {
+      NOTREACHED();
+      return nullptr;
+    }
+    DCHECK(unitData);
+    unitData->multiply(argument);
+    return unitData;
+  }
+
+  if (op == CalcDivide) {
+    // Divisor must always be on the RHS.
+    DCHECK_EQ(right->category(), CalculationCategory::CalcNumber);
+    std::unique_ptr<UnitData> unitData = UnitData::fromExpressionNode(left);
+    DCHECK(unitData);
+    unitData->divide(right->doubleValue());
+    return unitData;
+  }
+
+  // Add and subtract.
+  std::unique_ptr<UnitData> leftUnitData = UnitData::fromExpressionNode(left);
+  std::unique_ptr<UnitData> rightUnitData = UnitData::fromExpressionNode(right);
+  DCHECK(leftUnitData);
+  DCHECK(rightUnitData);
+
+  if (op == CalcAdd)
+    leftUnitData->add(*rightUnitData);
+  else if (op == CalcSubtract)
+    leftUnitData->subtract(*rightUnitData);
+  else
+    NOTREACHED();
+
+  return leftUnitData;
 }
 
 CSSCalcExpressionNode* CSSCalcLength::UnitData::toCSSCalcExpressionNode()
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.h b/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.h
index 2b11187..9916c41f 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.h
+++ b/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.h
@@ -18,6 +18,20 @@
   DEFINE_WRAPPERTYPEINFO();
 
  public:
+  static const int kNumSupportedUnits = 15;
+
+  static CSSLengthValue* from(const String& cssText, ExceptionState&);
+  static CSSLengthValue* from(double value,
+                              const String& typeStr,
+                              ExceptionState&);
+  static CSSLengthValue* from(const CSSCalcDictionary&, ExceptionState&);
+
+  static bool isSupportedLengthUnit(CSSPrimitiveValue::UnitType unit) {
+    return (CSSPrimitiveValue::isLength(unit) ||
+            unit == CSSPrimitiveValue::UnitType::Percentage) &&
+           unit != CSSPrimitiveValue::UnitType::QuirkyEms &&
+           unit != CSSPrimitiveValue::UnitType::UserUnits;
+  }
   static CSSPrimitiveValue::UnitType unitFromName(const String& name);
   static CSSLengthValue* fromCSSValue(const CSSPrimitiveValue&);
 
@@ -28,28 +42,13 @@
 
   virtual bool containsPercent() const = 0;
 
-  static CSSLengthValue* from(const String& cssText, ExceptionState&);
-  static CSSLengthValue* from(double value,
-                              const String& typeStr,
-                              ExceptionState&);
-  static CSSLengthValue* from(const CSSCalcDictionary&, ExceptionState&);
-
  protected:
-  static const int kNumSupportedUnits = 15;
-
   CSSLengthValue() {}
 
   virtual CSSLengthValue* addInternal(const CSSLengthValue* other);
   virtual CSSLengthValue* subtractInternal(const CSSLengthValue* other);
   virtual CSSLengthValue* multiplyInternal(double);
   virtual CSSLengthValue* divideInternal(double);
-
-  static bool isSupportedLengthUnit(CSSPrimitiveValue::UnitType unit) {
-    return (CSSPrimitiveValue::isLength(unit) ||
-            unit == CSSPrimitiveValue::UnitType::Percentage) &&
-           unit != CSSPrimitiveValue::UnitType::QuirkyEms &&
-           unit != CSSPrimitiveValue::UnitType::UserUnits;
-  }
 };
 
 DEFINE_TYPE_CASTS(CSSLengthValue,
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
index 06565694..e42c5e6 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -6,8 +6,10 @@
 
 #include "core/css/CSSImageValue.h"
 #include "core/css/CSSValue.h"
+#include "core/css/cssom/CSSCalcLength.h"
 #include "core/css/cssom/CSSKeywordValue.h"
 #include "core/css/cssom/CSSNumberValue.h"
+#include "core/css/cssom/CSSOMTypes.h"
 #include "core/css/cssom/CSSSimpleLength.h"
 #include "core/css/cssom/CSSStyleValue.h"
 #include "core/css/cssom/CSSStyleVariableReferenceValue.h"
@@ -38,6 +40,13 @@
       // TODO(meade): Implement other properties.
       break;
   }
+  if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isCalculated()) {
+    // TODO(meade): Handle other calculated types, e.g. angles here.
+    if (CSSOMTypes::propertyCanTakeType(propertyID,
+                                        CSSStyleValue::CalcLengthType)) {
+      return CSSCalcLength::fromCSSValue(toCSSPrimitiveValue(value));
+    }
+  }
   return nullptr;
 }
 
diff --git a/third_party/WebKit/Source/core/css/resolver/TransformBuilder.cpp b/third_party/WebKit/Source/core/css/resolver/TransformBuilder.cpp
index 95c4d2d6..ad887b3 100644
--- a/third_party/WebKit/Source/core/css/resolver/TransformBuilder.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/TransformBuilder.cpp
@@ -53,6 +53,8 @@
 static TransformOperation::OperationType getTransformOperationType(
     CSSValueID type) {
   switch (type) {
+    default:
+      NOTREACHED();
     case CSSValueScale:
       return TransformOperation::Scale;
     case CSSValueScaleX:
@@ -95,10 +97,6 @@
       return TransformOperation::Matrix3D;
     case CSSValuePerspective:
       return TransformOperation::Perspective;
-    default:
-      ASSERT_NOT_REACHED();
-      // FIXME: We shouldn't have a type None since we never create them
-      return TransformOperation::None;
   }
 }
 
diff --git a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
index bf29056..09e5172 100644
--- a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
+++ b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
@@ -265,6 +265,41 @@
                    .enclosingBoundingBox();
 }
 
+// Convert a local point into the coordinate system of backing coordinates.
+// Also returns the backing layer if needed.
+FloatPoint RenderedPosition::localToInvalidationBackingPoint(
+    const LayoutPoint& localPoint,
+    GraphicsLayer** graphicsLayerBacking) const {
+  const LayoutBoxModelObject& paintInvalidationContainer =
+      m_layoutObject->containerForPaintInvalidation();
+  DCHECK(paintInvalidationContainer.layer());
+
+  FloatPoint containerPoint = m_layoutObject->localToAncestorPoint(
+      FloatPoint(localPoint), &paintInvalidationContainer,
+      TraverseDocumentBoundaries);
+
+  // A layoutObject can have no invalidation backing if it is from a detached
+  // frame, or when forced compositing is disabled.
+  if (paintInvalidationContainer.layer()->compositingState() == NotComposited)
+    return containerPoint;
+
+  PaintLayer::mapPointInPaintInvalidationContainerToBacking(
+      paintInvalidationContainer, containerPoint);
+
+  // Must not use the scrolling contents layer, so pass
+  // |paintInvalidationContainer|.
+  if (GraphicsLayer* graphicsLayer =
+          paintInvalidationContainer.layer()->graphicsLayerBacking(
+              &paintInvalidationContainer)) {
+    if (graphicsLayerBacking)
+      *graphicsLayerBacking = graphicsLayer;
+
+    containerPoint.move(-graphicsLayer->offsetFromLayoutObject());
+  }
+
+  return containerPoint;
+}
+
 void RenderedPosition::positionInGraphicsLayerBacking(
     CompositedSelectionBound& bound,
     bool selectionStart) const {
@@ -275,17 +310,16 @@
     return;
 
   LayoutRect rect = m_layoutObject->localCaretRect(m_inlineBox, m_offset);
-  PaintLayer* layer = nullptr;
   if (m_layoutObject->style()->isHorizontalWritingMode()) {
-    bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(
-        rect.minXMinYCorner(), &layer);
-    bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(
-        rect.minXMaxYCorner(), nullptr);
+    bound.edgeTopInLayer =
+        localToInvalidationBackingPoint(rect.minXMinYCorner(), &bound.layer);
+    bound.edgeBottomInLayer =
+        localToInvalidationBackingPoint(rect.minXMaxYCorner(), nullptr);
   } else {
-    bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(
-        rect.minXMinYCorner(), &layer);
-    bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(
-        rect.maxXMinYCorner(), nullptr);
+    bound.edgeTopInLayer =
+        localToInvalidationBackingPoint(rect.minXMinYCorner(), &bound.layer);
+    bound.edgeBottomInLayer =
+        localToInvalidationBackingPoint(rect.maxXMinYCorner(), nullptr);
 
     // When text is vertical, it looks better for the start handle baseline to
     // be at the starting edge, to enclose the selection fully between the
@@ -299,8 +333,6 @@
     // Flipped blocks writing mode is not only vertical but also right to left.
     bound.isTextDirectionRTL = m_layoutObject->hasFlippedBlocksWritingMode();
   }
-
-  bound.layer = layer ? layer->graphicsLayerBacking() : nullptr;
 }
 
 bool layoutObjectContainsPosition(LayoutObject* target,
diff --git a/third_party/WebKit/Source/core/editing/RenderedPosition.h b/third_party/WebKit/Source/core/editing/RenderedPosition.h
index cff1a95..5d014a42 100644
--- a/third_party/WebKit/Source/core/editing/RenderedPosition.h
+++ b/third_party/WebKit/Source/core/editing/RenderedPosition.h
@@ -38,6 +38,8 @@
 
 namespace blink {
 
+class GraphicsLayer;
+class LayoutPoint;
 class LayoutUnit;
 class LayoutObject;
 struct CompositedSelectionBound;
@@ -102,6 +104,10 @@
   bool atRightBoundaryOfBidiRun(ShouldMatchBidiLevel,
                                 unsigned char bidiLevelOfRun) const;
 
+  FloatPoint localToInvalidationBackingPoint(
+      const LayoutPoint& localPoint,
+      GraphicsLayer** graphicsLayerBacking) const;
+
   LayoutObject* m_layoutObject;
   InlineBox* m_inlineBox;
   int m_offset;
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index ca896f73..ae2594c 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -2315,35 +2315,6 @@
   return transformState.accumulatedTransform();
 }
 
-FloatPoint LayoutObject::localToInvalidationBackingPoint(
-    const LayoutPoint& localPoint,
-    PaintLayer** backingLayer) {
-  const LayoutBoxModelObject& paintInvalidationContainer =
-      containerForPaintInvalidation();
-  DCHECK(paintInvalidationContainer.layer());
-
-  if (backingLayer)
-    *backingLayer = paintInvalidationContainer.layer();
-  FloatPoint containerPoint =
-      localToAncestorPoint(FloatPoint(localPoint), &paintInvalidationContainer,
-                           TraverseDocumentBoundaries);
-
-  // A layoutObject can have no invalidation backing if it is from a detached
-  // frame, or when forced compositing is disabled.
-  if (paintInvalidationContainer.layer()->compositingState() == NotComposited)
-    return containerPoint;
-
-  PaintLayer::mapPointInPaintInvalidationContainerToBacking(
-      paintInvalidationContainer, containerPoint);
-
-  if (GraphicsLayer* backingLayer =
-          paintInvalidationContainer.layer()->graphicsLayerBacking(this)) {
-    containerPoint.move(-backingLayer->offsetFromLayoutObject());
-  }
-
-  return containerPoint;
-}
-
 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const {
   ASSERT(o == container());
   return o->hasOverflowClip()
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h
index 830f3d9..3b28df1 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.h
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -1204,12 +1204,6 @@
     return localToAncestorTransform(nullptr, mode);
   }
 
-  // Convert a local point into the coordinate system of backing coordinates.
-  // Also returns the backing layer if needed.
-  FloatPoint localToInvalidationBackingPoint(
-      const LayoutPoint&,
-      PaintLayer** backingLayer = nullptr);
-
   // Return the offset from the container() layoutObject (excluding transforms
   // and multicol).
   virtual LayoutSize offsetFromContainer(const LayoutObject*) const;
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.cpp b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
index 0b60c5b..148d751 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -375,7 +375,6 @@
   m_nonInheritedData.m_clear = other.m_nonInheritedData.m_clear;
   m_nonInheritedData.m_position = other.m_nonInheritedData.m_position;
   m_nonInheritedData.m_tableLayout = other.m_nonInheritedData.m_tableLayout;
-  m_nonInheritedData.m_unicodeBidi = other.m_nonInheritedData.m_unicodeBidi;
   m_nonInheritedData.m_hasViewportUnits =
       other.m_nonInheritedData.m_hasViewportUnits;
   m_nonInheritedData.m_breakBefore = other.m_nonInheritedData.m_breakBefore;
@@ -819,8 +818,7 @@
   if (m_nonInheritedData.m_overflowX != other.m_nonInheritedData.m_overflowX ||
       m_nonInheritedData.m_overflowY != other.m_nonInheritedData.m_overflowY ||
       m_nonInheritedData.m_clear != other.m_nonInheritedData.m_clear ||
-      m_nonInheritedData.m_unicodeBidi !=
-          other.m_nonInheritedData.m_unicodeBidi ||
+      getUnicodeBidi() != other.getUnicodeBidi() ||
       floating() != other.floating() ||
       m_nonInheritedData.m_originalDisplay !=
           other.m_nonInheritedData.m_originalDisplay)
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.h b/third_party/WebKit/Source/core/style/ComputedStyle.h
index 9423cfc55..441d58b 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.h
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.h
@@ -228,9 +228,8 @@
              m_verticalAlign == other.m_verticalAlign &&
              m_clear == other.m_clear && m_position == other.m_position &&
              m_tableLayout == other.m_tableLayout &&
-             m_unicodeBidi == other.m_unicodeBidi
              // hasViewportUnits
-             && m_breakBefore == other.m_breakBefore &&
+             m_breakBefore == other.m_breakBefore &&
              m_breakAfter == other.m_breakAfter &&
              m_breakInside == other.m_breakInside;
       // styleType
@@ -259,7 +258,6 @@
     unsigned m_clear : 2;             // EClear
     unsigned m_position : 3;          // EPosition
     unsigned m_tableLayout : 1;       // ETableLayout
-    unsigned m_unicodeBidi : 3;       // UnicodeBidi
 
     // This is set if we used viewport units when resolving a length.
     // It is mutable so we can pass around const ComputedStyles to resolve
@@ -317,8 +315,6 @@
     m_nonInheritedData.m_clear = initialClear();
     m_nonInheritedData.m_position = initialPosition();
     m_nonInheritedData.m_tableLayout = initialTableLayout();
-    m_nonInheritedData.m_unicodeBidi =
-        static_cast<unsigned>(initialUnicodeBidi());
     m_nonInheritedData.m_breakBefore = initialBreakBefore();
     m_nonInheritedData.m_breakAfter = initialBreakAfter();
     m_nonInheritedData.m_breakInside = initialBreakInside();
@@ -1855,15 +1851,6 @@
     SET_VAR(m_rareNonInheritedData, m_touchAction, t);
   }
 
-  // unicode-bidi
-  static UnicodeBidi initialUnicodeBidi() { return UnicodeBidi::kNormal; }
-  UnicodeBidi getUnicodeBidi() const {
-    return static_cast<UnicodeBidi>(m_nonInheritedData.m_unicodeBidi);
-  }
-  void setUnicodeBidi(UnicodeBidi b) {
-    m_nonInheritedData.m_unicodeBidi = static_cast<unsigned>(b);
-  }
-
   // vertical-align
   static EVerticalAlign initialVerticalAlign() {
     return EVerticalAlign::Baseline;
diff --git a/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/closure_runner.jar b/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/closure_runner.jar
index 012dfd4..fd5fc791 100644
--- a/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/closure_runner.jar
+++ b/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/closure_runner.jar
Binary files differ
diff --git a/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/src/org/chromium/devtools/compiler/Runner.java b/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/src/org/chromium/devtools/compiler/Runner.java
index d94a098..bcea380 100644
--- a/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/src/org/chromium/devtools/compiler/Runner.java
+++ b/third_party/WebKit/Source/devtools/scripts/closure/closure_runner/src/org/chromium/devtools/compiler/Runner.java
@@ -197,14 +197,17 @@
         protected Compiler createCompiler() {
             Compiler compiler = new Compiler();
             final LightweightMessageFormatter formatter = new LightweightMessageFormatter(compiler);
-            compiler.setErrorManager(new PrintStreamErrorManager(formatter, getErrorPrintStream()) {
+            PrintStreamErrorManager errorManager =
+                    new PrintStreamErrorManager(formatter, getErrorPrintStream()) {
                 @Override
                 public void report(CheckLevel level, JSError error) {
                     String text = formatter.formatError(error);
                     if (text.indexOf("access on a struct") == -1 || text.indexOf("Symbol") == -1)
                         super.report(level, error);
                 }
-            });
+            };
+            errorManager.setSummaryDetailLevel(3);
+            compiler.setErrorManager(errorManager);
             return compiler;
         }
 
diff --git a/third_party/WebKit/Source/devtools/scripts/visualize_deps/generate_dot.js b/third_party/WebKit/Source/devtools/scripts/visualize_deps/generate_dot.js
index b079f218..1448ef8 100644
--- a/third_party/WebKit/Source/devtools/scripts/visualize_deps/generate_dot.js
+++ b/third_party/WebKit/Source/devtools/scripts/visualize_deps/generate_dot.js
@@ -15,13 +15,31 @@
 function main() {
   const modules = new Set();
   const moduleToDependencyList = ['digraph dependencies {'];
+  moduleToDependencyList.push('fixedsize = true;')
   fs.readdirSync(FRONTEND_PATH).forEach(function(file) {
     const moduleJSONPath = path.join(FRONTEND_PATH, file, 'module.json');
     if (fs.statSync(path.join(FRONTEND_PATH, file)).isDirectory() &&
       utils.isFile(moduleJSONPath)) {
       const module = file;
+      if (module === 'audits2_worker')
+        return;
       modules.add(module);
       const moduleJSON = require(moduleJSONPath);
+      let moduleSize = 0;
+
+      let resources = (moduleJSON.scripts || []).concat((moduleJSON.resources || []));
+      for (let script of resources) {
+        if (fs.existsSync(path.join(FRONTEND_PATH, module, script))) {
+          console.log(path.join(FRONTEND_PATH, module, script));
+          moduleSize += fs.statSync(path.join(FRONTEND_PATH, module, script)).size;
+        }
+      }
+      moduleSize /= 200000;
+      moduleSize = Math.max(0.5, moduleSize);
+      let fontSize = Math.max(moduleSize*14, 14);
+
+      moduleToDependencyList.push(`${module} [width=${moduleSize}, height=${moduleSize} fontsize=${fontSize}];`);
+
       if (moduleJSON.dependencies) {
         for (let d of moduleJSON.dependencies) {
           moduleToDependencyList.push(`  ${module} -> ${d}`);
diff --git a/third_party/WebKit/Source/platform/animation/AnimationTranslationUtil.cpp b/third_party/WebKit/Source/platform/animation/AnimationTranslationUtil.cpp
index b6f9f765a..ea2e7ae 100644
--- a/third_party/WebKit/Source/platform/animation/AnimationTranslationUtil.cpp
+++ b/third_party/WebKit/Source/platform/animation/AnimationTranslationUtil.cpp
@@ -120,8 +120,8 @@
       case TransformOperation::Identity:
         outTransformOperations->appendIdentity();
         break;
-      case TransformOperation::None:
-        // Do nothing.
+      default:
+        NOTREACHED();
         break;
     }  // switch
   }    // for each operation
diff --git a/third_party/WebKit/Source/platform/geometry/FloatRect.cpp b/third_party/WebKit/Source/platform/geometry/FloatRect.cpp
index 1f5659b..fe35f38 100644
--- a/third_party/WebKit/Source/platform/geometry/FloatRect.cpp
+++ b/third_party/WebKit/Source/platform/geometry/FloatRect.cpp
@@ -184,13 +184,6 @@
   return result;
 }
 
-IntRect enclosingIntRect(const FloatRect& rect) {
-  IntPoint location = flooredIntPoint(rect.minXMinYCorner());
-  IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner());
-
-  return IntRect(location, maxPoint - location);
-}
-
 IntRect enclosedIntRect(const FloatRect& rect) {
   IntPoint location = ceiledIntPoint(rect.minXMinYCorner());
   IntPoint maxPoint = flooredIntPoint(rect.maxXMaxYCorner());
diff --git a/third_party/WebKit/Source/platform/geometry/FloatRect.h b/third_party/WebKit/Source/platform/geometry/FloatRect.h
index d950586..00de1b83 100644
--- a/third_party/WebKit/Source/platform/geometry/FloatRect.h
+++ b/third_party/WebKit/Source/platform/geometry/FloatRect.h
@@ -29,6 +29,7 @@
 
 #include "platform/geometry/FloatPoint.h"
 #include "platform/geometry/FloatRectOutsets.h"
+#include "platform/geometry/IntRect.h"
 #include "third_party/skia/include/core/SkRect.h"
 #include "wtf/Allocator.h"
 #include "wtf/Forward.h"
@@ -49,7 +50,6 @@
 
 namespace blink {
 
-class IntRect;
 class LayoutRect;
 class LayoutSize;
 
@@ -256,7 +256,12 @@
   return a.location() != b.location() || a.size() != b.size();
 }
 
-PLATFORM_EXPORT IntRect enclosingIntRect(const FloatRect&);
+inline IntRect enclosingIntRect(const FloatRect& rect) {
+  IntPoint location = flooredIntPoint(rect.minXMinYCorner());
+  IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner());
+
+  return IntRect(location, maxPoint - location);
+}
 
 // Returns a valid IntRect contained within the given FloatRect.
 PLATFORM_EXPORT IntRect enclosedIntRect(const FloatRect&);
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
index b0d30a4..5ad87f8 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -923,8 +923,9 @@
   // If the context is lost, we don't know if we should be producing GPU or
   // software frames, until we get a new context, since the compositor will
   // be trying to get a new context and may change modes.
-  if (m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() !=
-      GL_NO_ERROR)
+  if (!m_contextProvider ||
+      m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() !=
+          GL_NO_ERROR)
     return false;
 
   sk_sp<SkImage> image =
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
index b40311d4..f5744863 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
@@ -250,6 +250,36 @@
         bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
   }
 
+  void prepareMailboxWhenContextIsLostWithFailedRestore() {
+    FakeGLES2Interface gl;
+    std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
+        WTF::wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
+    Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
+        std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
+        Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr,
+        kN32_SkColorType)));
+
+    // TODO(junov): The PrepareTextureMailbox() method will fail a DCHECK if we
+    // don't do this before calling it the first time when the context is lost.
+    bridge->prepareSurfaceForPaintingIfNeeded();
+
+    // When the context is lost we are not sure if we should still be producing
+    // GL frames for the compositor or not, so fail to generate frames.
+    gl.setIsContextLost(true);
+    EXPECT_FALSE(bridge->checkSurfaceValid());
+
+    // Restoration will fail because
+    // Platform::createSharedOffscreenGraphicsContext3DProvider() is stubbed
+    // in unit tests.  This simulates what would happen when attempting to
+    // restore while the GPU process is down.
+    bridge->restoreSurface();
+
+    cc::TextureMailbox textureMailbox;
+    std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
+    EXPECT_FALSE(
+        bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
+  }
+
   void prepareMailboxAndLoseResourceTest() {
     // Prepare a mailbox, then report the resource as lost.
     // This test passes by not crashing and not triggering assertions.
@@ -344,6 +374,11 @@
   prepareMailboxWhenContextIsLost();
 }
 
+TEST_F(Canvas2DLayerBridgeTest,
+       PrepareMailboxWhenContextIsLostWithFailedRestore) {
+  prepareMailboxWhenContextIsLostWithFailedRestore();
+}
+
 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxAndLoseResource) {
   prepareMailboxAndLoseResourceTest();
 }
diff --git a/third_party/WebKit/Source/platform/heap/TraceTraits.h b/third_party/WebKit/Source/platform/heap/TraceTraits.h
index e2e3146..49f5b51 100644
--- a/third_party/WebKit/Source/platform/heap/TraceTraits.h
+++ b/third_party/WebKit/Source/platform/heap/TraceTraits.h
@@ -690,9 +690,9 @@
     // key-value entry is leaked.  To avoid unexpected leaking, we disallow
     // this case, but if you run into this assert, please reach out to Blink
     // reviewers, and we may relax it.
-    const bool keyIsWeak =
+    constexpr bool keyIsWeak =
         Traits::KeyTraits::weakHandlingFlag == WeakHandlingInCollections;
-    const bool valueIsWeak =
+    constexpr bool valueIsWeak =
         Traits::ValueTraits::weakHandlingFlag == WeakHandlingInCollections;
     const bool keyHasStrongRefs =
         IsTraceableInCollectionTrait<typename Traits::KeyTraits>::value;
diff --git a/third_party/WebKit/Source/platform/transforms/TransformOperation.h b/third_party/WebKit/Source/platform/transforms/TransformOperation.h
index 004226e4..968cbba4 100644
--- a/third_party/WebKit/Source/platform/transforms/TransformOperation.h
+++ b/third_party/WebKit/Source/platform/transforms/TransformOperation.h
@@ -64,7 +64,6 @@
     Interpolated,
     Identity,
     RotateAroundOrigin,
-    None
   };
 
   TransformOperation() {}
diff --git a/third_party/WebKit/Source/platform/transforms/TransformOperations.cpp b/third_party/WebKit/Source/platform/transforms/TransformOperations.cpp
index 8473f492..305bd02 100644
--- a/third_party/WebKit/Source/platform/transforms/TransformOperations.cpp
+++ b/third_party/WebKit/Source/platform/transforms/TransformOperations.cpp
@@ -283,16 +283,10 @@
         (i < fromSize) ? from.operations()[i] : nullptr;
     RefPtr<TransformOperation> toOperation =
         (i < toSize) ? operations()[i] : nullptr;
-    if (fromOperation && fromOperation->type() == TransformOperation::None)
-      fromOperation = nullptr;
 
-    if (toOperation && toOperation->type() == TransformOperation::None)
-      toOperation = nullptr;
-
+    DCHECK(fromOperation || toOperation);
     TransformOperation::OperationType interpolationType =
-        toOperation
-            ? toOperation->type()
-            : fromOperation ? fromOperation->type() : TransformOperation::None;
+        toOperation ? toOperation->type() : fromOperation->type();
     if (fromOperation && toOperation &&
         !fromOperation->canBlendWith(*toOperation.get()))
       return false;
@@ -408,8 +402,6 @@
         }
       }
         continue;
-      case TransformOperation::None:
-        continue;
       case TransformOperation::Matrix:
       case TransformOperation::Matrix3D:
       case TransformOperation::Interpolated:
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
index 2d6713c..5df98a5 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -475,6 +475,9 @@
   if (type.isVolatileQualified())
     return false;
 
+  if (decl.isConstexpr())
+    return true;
+
   // Parameters should not be renamed to |kFooBar| style (even if they are
   // const and have an initializer (aka default value)).
   if (clang::isa<clang::ParmVarDecl>(&decl))
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 7b36704..f0f798a 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -64702,6 +64702,16 @@
   </summary>
 </histogram>
 
+<histogram name="Storage.Blob.CleanupSuccess" enum="Boolean">
+  <owner>dmurph@chromium.org</owner>
+  <summary>
+    Recorded when the old blob storage directories are cleared. This occurs on
+    storage partition initialization, and is not recorded if there are no
+    directories to clear. The value indicates if the file operations were a
+    success.
+  </summary>
+</histogram>
+
 <histogram name="Storage.Blob.CreateDirectoryResult" enum="PlatformFileError">
   <owner>dmurph@chromium.org</owner>
   <summary>
@@ -64752,6 +64762,26 @@
   </summary>
 </histogram>
 
+<histogram name="Storage.Blob.MaxDiskSpace" units="MB">
+  <owner>dmurph@chromium.org</owner>
+  <summary>
+    Records the calculated max disk space the blob storage system can use.
+    Recorded on storage partition initialization.
+  </summary>
+</histogram>
+
+<histogram name="Storage.Blob.MaxDiskSpaceAdjustment"
+    enum="BlobStorageDiskSpaceAdjustment">
+  <owner>dmurph@chromium.org</owner>
+  <summary>
+    Recorded when the blob system changes adjustment types on its disk size. The
+    disk can either be Frozen, Adjusted (near min external available disk
+    space), or Normal. We record when we transition between these states, which
+    can happen after any file operations in the blob system (paging data to disk
+    or saving a new blob directly to disk).
+  </summary>
+</histogram>
+
 <histogram name="Storage.Blob.PageFileSize" units="KB">
   <owner>dmurph@chromium.org</owner>
   <summary>
@@ -78079,6 +78109,25 @@
   <int value="5" label="Referenced blob broken"/>
 </enum>
 
+<enum name="BlobStorageDiskSpaceAdjustment" type="int">
+  <summary>
+    When the blob storage system adjusts its max disk space, it can be frozen,
+    adjusted (near min external disk availability), or normal. These values
+    record the transitions between those states.
+  </summary>
+  <int value="0"
+      label="Disk usage frozen because minimum disk availability was reached."/>
+  <int value="1"
+      label="Max disk usage reduced from a normal state because disk space is
+             approaching minimum disk availability."/>
+  <int value="2"
+      label="Max disk usage increased from a frozen state to adjusted, as
+             minimum external disk availability is still close."/>
+  <int value="3"
+      label="Max disk usage restored to desired limit after being adjusted or
+             frozen."/>
+</enum>
+
 <enum name="BluetoothAvailability" type="int">
   <int value="0" label="Unexpected error"/>
   <int value="1" label="Not available"/>
diff --git a/tools/perf/generate_perf_json.py b/tools/perf/generate_perf_json.py
index 7819421..62c807b 100755
--- a/tools/perf/generate_perf_json.py
+++ b/tools/perf/generate_perf_json.py
@@ -430,7 +430,8 @@
        'perf_tests': [
          ('cc_perftests', 2),
          ('load_library_perf_tests', 2),
-         ('tracing_perftests', 2)]
+         ('tracing_perftests', 2),
+         ('media_perftests', 3)]
       }
     ])
 
diff --git a/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp b/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp
index f5974fb4d1..a654cab 100644
--- a/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp
+++ b/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp
@@ -7,7 +7,6 @@
       'target_name': 'cr_policy_indicator_behavior',
       'dependencies': [
         '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
-        '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
       ],
       'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
     },
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js b/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js
index 832c0a30..5367637b 100644
--- a/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js
@@ -6,6 +6,19 @@
  * @fileoverview Behavior for policy controlled indicators.
  */
 
+/**
+ * Strings required for policy indicators. These must be set at runtime.
+ * Chrome OS only strings may be undefined.
+ * @type {{
+ *   controlledSettingPolicy: string,
+ *   controlledSettingRecommendedMatches: string,
+ *   controlledSettingRecommendedDiffers: string,
+ *   controlledSettingShared: (string|undefined),
+ *   controlledSettingOwner: (string|undefined),
+ * }}
+ */
+var CrPolicyStrings;
+
 /** @enum {string} */
 var CrPolicyIndicatorType = {
   DEVICE_POLICY: 'devicePolicy',
@@ -58,34 +71,29 @@
   },
 
   /**
-   * @param {string} id The id of the string to translate.
-   * @param {string=} opt_name An optional name argument.
-   * @return The translated string.
-   */
-  i18n_: function(id, opt_name) {
-    return loadTimeData.getStringF(id, opt_name);
-  },
-
-  /**
    * @param {CrPolicyIndicatorType} type
-   * @param {string} name The name associated with the controllable. See
+   * @param {string} name The name associated with the indicator. See
    *     chrome.settingsPrivate.PrefObject.controlledByName
+   * @param {boolean=} opt_matches For RECOMMENDED only, whether the indicator
+   *     value matches the recommended value.
    * @return {string} The tooltip text for |type|.
    */
-  getPolicyIndicatorTooltip: function(type, name) {
+  getPolicyIndicatorTooltip: function(type, name, opt_matches) {
+    if (!CrPolicyStrings)
+      return '';  // Tooltips may not be defined, e.g. in OOBE.
     switch (type) {
       case CrPolicyIndicatorType.PRIMARY_USER:
-        return this.i18n_('controlledSettingShared', name);
+        return CrPolicyStrings.controlledSettingShared.replace('$1', name);
       case CrPolicyIndicatorType.OWNER:
-        return this.i18n_('controlledSettingOwner', name);
+        return CrPolicyStrings.controlledSettingOwner.replace('$1', name);
       case CrPolicyIndicatorType.USER_POLICY:
       case CrPolicyIndicatorType.DEVICE_POLICY:
-        return this.i18n_('controlledSettingPolicy');
+        return CrPolicyStrings.controlledSettingPolicy;
       case CrPolicyIndicatorType.RECOMMENDED:
-        // This case is not handled here since it requires knowledge of the
-        // value and recommended value associated with the controllable.
-        assertNotReached();
+        return opt_matches ?
+            CrPolicyStrings.controlledSettingRecommendedMatches :
+            CrPolicyStrings.controlledSettingRecommendedDiffers;
     }
     return '';
-  }
+  },
 };
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js b/ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js
index 38e0d0f..16dae611 100644
--- a/ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js
@@ -75,18 +75,14 @@
    * @private
    */
   getTooltip_: function() {
-    if (this.indicatorType == CrPolicyIndicatorType.NONE)
-      return '';
-    if (this.indicatorType == CrPolicyIndicatorType.RECOMMENDED) {
-      if (!this.property)
-        return '';
+    var matches;
+    if (this.indicatorType == CrPolicyIndicatorType.RECOMMENDED &&
+        this.property) {
       var value = this.property.Active;
       if (value == undefined && this.property.Effective)
         value = this.property[this.property.Effective];
-      if (value == this.recommended_)
-        return this.i18n_('controlledSettingRecommendedMatches');
-      return this.i18n_('controlledSettingRecommendedDiffers');
+      matches = value == this.recommended_;
     }
-    return this.getPolicyIndicatorTooltip(this.indicatorType, '');
+    return this.getPolicyIndicatorTooltip(this.indicatorType, '', matches);
   }
 });
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js b/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js
index a76a4c6..dcb58c4 100644
--- a/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js
@@ -37,11 +37,8 @@
    * @private
    */
   getTooltip_: function(type, pref) {
-    if (type == CrPolicyIndicatorType.RECOMMENDED) {
-      if (pref && pref.value == pref.recommendedValue)
-        return this.i18n_('controlledSettingRecommendedMatches');
-      return this.i18n_('controlledSettingRecommendedDiffers');
-    }
-    return this.getPolicyIndicatorTooltip(type, pref.controlledByName || '');
+    var matches = pref && pref.value == pref.recommendedValue;
+    return this.getPolicyIndicatorTooltip(
+        type, pref.controlledByName || '', matches);
   }
 });