summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/html/html_frame_element_test.cc
blob: f44e9d6c371cdea46bcd051251d5d69f9acdabd5 (plain)
1
2
3
4
5
6
7
8
9
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
// 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 "third_party/blink/renderer/core/html/html_frame_element.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/feature_policy/feature_policy.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_init.h"
#include "third_party/blink/renderer/platform/heap/heap.h"

namespace blink {

class HTMLFrameElementTest : public testing::Test {};

// Test that the correct container policy is constructed on a frame element.
// Frame elements do not have any container-policy related attributes, but the
// fullscreen feature should be unconditionally disabled.
TEST_F(HTMLFrameElementTest, DefaultContainerPolicy) {
  const KURL document_url("http://example.com");
  DocumentInit init =
      DocumentInit::Create()
          .ForTest()
          .WithInitiatorOrigin(SecurityOrigin::Create(document_url))
          .WithURL(document_url);
  auto* document = MakeGarbageCollected<Document>(init);

  auto* frame_element = MakeGarbageCollected<HTMLFrameElement>(*document);

  frame_element->setAttribute(html_names::kSrcAttr, "http://example.net/");
  frame_element->UpdateContainerPolicyForTests();

  const ParsedFeaturePolicy& container_policy =
      frame_element->GetFramePolicy().container_policy;
  EXPECT_EQ(1UL, container_policy.size());
  // Fullscreen should be disabled in this frame
  EXPECT_EQ(mojom::blink::FeaturePolicyFeature::kFullscreen,
            container_policy[0].feature);
  EXPECT_TRUE(container_policy[0].allowed_origins.empty());
  EXPECT_GE(false, container_policy[0].fallback_value);
}

}  // namespace blink